Product
AI generated code

AI generated code

How to Automate Code Generation in Qlerify

Introduction

Code generation with AI is a powerful way to accelerate development. Unlike other tools that rely solely on text prompts, Qlerify uses your Domain Model as a living blueprint for your application. This ensures you maintain complete control while producing high-quality, structured, and consistent code.

With Qlerify's new code generation engine, you're not just creating code once; you're entering a continuous development loop. Start with a solid architectural foundation, generate your code, and then, as your domain model evolves, intelligently update your application with AI assistance, all the way to a git commit.

Why Use Code Generation?

Code generation with AI helps teams to:

  • Deliver more in less time: Automate the creation of boilerplate and repetitive code.
  • Reduce time to market: Quickly scaffold new features and adapt to changes.
  • Reduce delays: Streamline development workflows from design to deployment.
  • Minimize errors and bugs: Produce consistent code that adheres to best practices.

Step-by-Step Guide to Code Generation in Qlerify

The new code generation is a guided, iterative process. Before you begin, ensure you have a Domain Model built using techniques like Event Storming or Event Modeling. This model is the source of truth for the AI.

After creating your Domain Model, open the Code View for the Bounded Context you wish to work on. Here, you'll find the main code generation interface.

The Domain-Centric View

On the left side of the Code View, you'll see a unique file tree that directly mirrors your Domain Model. Instead of a standard folder structure, your project is organized by domain concepts:

  • Commands (e.g. create-todo, update-todo)
  • Entities (e.g. todo)
  • GWTs (your Given-When-Then test scenarios)
  • Read Models (e.g. get-all-todos)

This view provides instant feedback on the state of your generated code:

  • A red dot indicates that the underlying domain element has changed since the code was last generated. It's time to update!
  • A yellow dot signifies that the AI has generated changes, but they haven't been approved yet.

This powerful view closes the loop between your design and the actual code, making it easy to see what needs attention, as well as making sure your documentation is always aligned with your codebase.

Step 1: Choose Your Architecture with a Starter Template

Every great application starts with a solid foundation. You begin by selecting a Starter Template from the "Code Generation Steps" panel. Think of this as a professional, full-stack framework boilerplate for your project.

In the near future, you will be able to choose from a variety of modern architectures, such as:

  • JavaScript with Express for your backend.
  • TypeScript with NestJS for your backend.
  • Python with FastAPI for your backend.
  • Java with Spring Boot for your backend.
  • C# with ASP.NET for your backend.
  • Go with Fiber for your backend.
  • PHP with Laravel for your backend.
  • More templates are being added continuously!

Selecting a template instantly populates your project with a well-organized file structure for a server, client, or both.

Step 2: Review Your API Specification

With your architecture in place, Qlerify automatically translates your Domain Model into a standard OpenAPI (Swagger) specification. This spec details all the endpoints, request/response models that will be generated.

Before the AI writes a single line of code, you can click to review this specification. This is a crucial validation step that ensures the AI will build exactly what you designed in your Domain Model.

Step 3: Generate and Update Code with AI

This is where the magic happens. You have two ways to generate code:

  1. Generate All: Click the Generate/Update API button. Qlerify’s AI will scan all the changes in your domain model (the items with red dots) and build out the necessary features across your application. This includes:
    • Backend API endpoints for your Commands.
    • Data models and logic for your Entities.
    • Query handlers for your Read Models.
    • Business logic and validation for your Commands, along with the unit tests to prove it, all derived from your GWT scenarios.
    • A complete React frontend application with forms and views that are automatically wired up to your API, giving you an interactive prototype in seconds.

The Qlerify tool will only change the parts of your codebase that are directly affected by your domain changes, leaving the rest of your code untouched.

  1. Generate Per-Item: For more fine-grained control, you can generate code for a single domain item. Simply click the menu next to a command, entity, read model or GWT in the domain tree and select "Generate" or "Regenerate". This flexible approach enables you to save time only generating what you need at the moment.

As you evolve your Domain Model, simply repeat the process. The system intelligently detects what has changed and surgically updates only the relevant parts of your codebase.

Step 4: Review, Approve, and Manage Changes

The AI's work is presented to you as a diff, similar to a Git pull request. You can clearly see the original code and the newly generated suggestions side-by-side. On the left, you have the current state of your code. On the right, you see the AI's proposed changes highlighted in green.

This gives you maximum control. Once you're satisfied, you can:

  • Approve changes for individual files by clicking "Apply". This allows you to review and accept the code on a granular level.
  • Click "Approve all changes" in the main steps panel to accept all the AI's suggestions at once. Use this when you're confident in the AI's output.

This workflow ensures you are always the final authority, using AI as a powerful assistant.

Step 5: Commit Directly to GitHub or Download as ZIP

Now you have the option to either download your updated code as a ZIP file or commit it directly to your GitHub repository.

Navigate to the GitHub Tab where you can:

  1. Connect your Qlerify project to a new or existing GitHub repository.
  2. View a diff of all your approved changes against the code in your repository.
  3. Write a commit message and commit and push your changes directly to your selected branch.

If you prefer not to use GitHub, you can always download the entire project as a ZIP file and manage it locally.

  1. Navigate to the Code View tab.
  2. Click the Download button in the action menu located at the top of the left panel.

Advanced Controls

Beyond the main workflow, Qlerify provides additional tools to give you full control over your project.

Selecting Your AI Model

Qlerify puts you in control by allowing you to choose the specific Large Language Model (LLM) used for code generation. You can experiment with different models to see which one best fits your needs. This option is available in the AI model selector, located at the bottom of the "Code Generation Steps" panel.

Resetting Your Code View

If you ever want to start over from a clean slate — perhaps to choose a different Starter Template or just to clear out an experiment — the **Reset Code View** button provides a safe way to do this. This action will:

  • Permanently delete all generated code *within this Bounded Context in Qlerify
  • Unlink the connected GitHub repository
  • Allow you to select a new Starter Template

Important: This action does not affect your code on GitHub; it only resets the project within the Qlerify interface.

From domain modeling to a live commit, your entire workflow is now unified in one place.

Best Practices for Code Generation in Qlerify
  • State changing events: Focus on capturing state-changing events in the workflow. Ensure that each state-changing event corresponds to a single command invoked on one Entity (or Aggregate).
  • Bounded Contexts: Aim for loose coupling between contexts. This approach ensures that each Bounded Context is independently evolvable and maintainable.

Conclusion

By generating code with a Domain Model as a base, the team can maintain control over the design and architecture of the solution. The generated code can be based on existing Entities or Data Models.

If you haven't tried code generation in Qlerify yet, now is the perfect time to explore its capabilities and boost your development workflow! To sign up for a Qlerify account, click on the link in the footer.

///SOCIAL SHARE