Overview: Components of the Zapp Lifecycle

Zapp employs a series of interconnected components to automate code generation. This overview provides a quick glance at these essential components and explains how they function together in the Zapp lifecycle.

<br /> <img src="/images/lifecycle.png" />

Components

Specifications (Specs)

Specifications, or "Specs," are the foundational building blocks that define the logic and metadata of your application. They describe the features, functionalities, and constraints that your generated code should adhere to.

Specs serve as the initial input, driving what kind of code is generated. They act as the "blueprint" that other components refer to during the generation process.

Schemas

Schemas are structured definitions that validate the Specs. They are typically based on JSON Schema and ensure that the Specs conform to predetermined rules and formats.

Schemas work immediately after Specs, validating them to guarantee that they meet certain quality and structure requirements. This helps in preventing erroneous code generation.

Generators

Generators act as the orchestrators of the code generation process. They consume validated Specs and utilize Templates and Engines to generate the code.

Generators use the information in the Specs and the formatting rules in the Templates, churning out code that is then passed on to Processors for post-generation actions.

Templates

Templates are code skeletons that provide the structural outline for the generated code. They contain placeholders that are populated by data from the Specs.

Templates are referred to by Generators and are filled in using the Engines, based on the Specs, to produce the desired code output.

Engines

Engines are the template engines like Handlebars, Mustache, or custom TypeScript functions that populate the Templates with data from the Specs.

Engines work within Generators to manipulate Templates. They fill in the gaps in the Templates based on the Specs to create the final generated code.

Processors

Processors are components that act on the code after it has been generated. They perform tasks like formatting, analysis, and other post-generation activities.

Once the Generators produce the code, Processors act on this output to finalize it. They ensure that the code meets specific quality standards and guidelines.

Zapps

Zapps are configurations or collections that organize all the aforementioned components (Specs, Schemas, Generators, Templates, Engines, and Processors) for a specific project or module.

Zapps serve as an umbrella that houses all other components. They make it easier to manage, update, and scale the entire code generation ecosystem for a project.

The Workflow

  1. Specs define the application logic and are first validated by Schemas.
  2. Validated Specs are then picked up by Generators.
  3. Generators use Engines to populate Templates, creating the actual code.
  4. This generated code is then passed through Processors for any post-generation activities.
  5. All these components can be managed and organized effectively within a Zapp, making it easier to handle even complex projects.

By understanding how each component plays its role and works in tandem with others, you can unlock the full potential of Zapp for your code generation needs.