<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Maher Ben abdessalem</title>
    <description>The latest articles on DEV Community by Maher Ben abdessalem (@maher_benabdessalem).</description>
    <link>https://dev.to/maher_benabdessalem</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4173829%2F027477b2-42fd-4de1-87af-27d4107299c6.jpg</url>
      <title>DEV Community: Maher Ben abdessalem</title>
      <link>https://dev.to/maher_benabdessalem</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/maher_benabdessalem"/>
    <language>en</language>
    <item>
      <title>Why I built a Clean Architecture Code Generator for NestJS</title>
      <dc:creator>Maher Ben abdessalem</dc:creator>
      <pubDate>Thu, 15 Oct 2026 23:46:05 +0000</pubDate>
      <link>https://dev.to/maher_benabdessalem/why-i-built-a-clean-architecture-code-generator-for-nestjs-42d1</link>
      <guid>https://dev.to/maher_benabdessalem/why-i-built-a-clean-architecture-code-generator-for-nestjs-42d1</guid>
      <description>&lt;p&gt;TL;DR: I built a Python CLI that generates enterprise NestJS (CQRS/DDD) and React backends from YAML. It's open-source on PyPI. Here is how I architected it.&lt;br&gt;
You can check out the source code on GitHub or install the package directly from PyPI.&lt;br&gt;
For Nest.js &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/maher1719" rel="noopener noreferrer"&gt;
        maher1719
      &lt;/a&gt; / &lt;a href="https://github.com/maher1719/Nestjs-clean-architecture-crud-modules-generator" rel="noopener noreferrer"&gt;
        Nestjs-clean-architecture-crud-modules-generator
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      🚀 Python CLI to auto-generate strict Clean Architecture, DDD, and CQRS modules for NestJS from YAML. Swagger &amp;amp; TypeORM ready.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;p&gt;&lt;a href="https://pypi.org/project/nestjs-clean-gen/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/c243359954c8066df3661f86a49b63993313f71e6119ed52492a8ea0ef865439/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f6e6573746a732d636c65616e2d67656e2e737667" alt="PyPI version"&gt;&lt;/a&gt;
&lt;a href="https://pypi.org/project/nestjs-clean-gen/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/69c12bbb83a01d972c586e5e2e9347c39ec0fad1d1f0d7af0bfafe1ba5a5353e/68747470733a2f2f696d672e736869656c64732e696f2f707970692f707976657273696f6e732f6e6573746a732d636c65616e2d67656e2e737667" alt="Python 3.10+"&gt;&lt;/a&gt;
&lt;a href="https://www.gnu.org/licenses/agpl-3.0" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/a3e79d899e42547e60b531886472b3cb818e2a42dac09cc16a8d87105c077ca8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4147504c5f76332d626c75652e737667" alt="License: AGPL v3"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;🏗️ NestJS Clean Architecture CRUD Generator&lt;/h1&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Stop writing boilerplate.&lt;/strong&gt; Generate production-grade, strictly-typed &lt;strong&gt;NestJS&lt;/strong&gt; modules following &lt;strong&gt;Clean Architecture&lt;/strong&gt;, &lt;strong&gt;Domain-Driven Design (DDD)&lt;/strong&gt;, and &lt;strong&gt;CQRS&lt;/strong&gt; from a single YAML file.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Define your entity, run one command, and get a fully structured module with domain logic, CQRS handlers, TypeORM persistence, DTO validation, Swagger documentation, and REST controllers.&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;✨ Features&lt;/h2&gt;
&lt;/div&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;🏛️ &lt;strong&gt;Clean Architecture&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Strict &lt;code&gt;domain&lt;/code&gt; / &lt;code&gt;application&lt;/code&gt; / &lt;code&gt;infrastructure&lt;/code&gt; / &lt;code&gt;presentation&lt;/code&gt; layering.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⚡ &lt;strong&gt;CQRS&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Separate Commands &amp;amp; Queries with dedicated Handlers.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🔗 &lt;strong&gt;All 4 Relations&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;many-to-one&lt;/code&gt;, &lt;code&gt;one-to-many&lt;/code&gt;, &lt;code&gt;one-to-one&lt;/code&gt;, &lt;code&gt;many-to-many&lt;/code&gt; with proper FK ownership.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🧩 &lt;strong&gt;Aggregates (DDD)&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Parent validation, cascade enforcement, and auto-generated nested read routes.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🔄 &lt;strong&gt;PUT vs PATCH&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Strict separation between full &lt;code&gt;Replace&lt;/code&gt; and partial &lt;code&gt;Update&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;📊 &lt;strong&gt;Production Lists&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Built-in Pagination, Whitelisted Filtering, and Sorting (v3).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;📄 &lt;strong&gt;Swagger &amp;amp; Validation&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Auto-generated &lt;code&gt;class-validator&lt;/code&gt; DTOs and &lt;code&gt;@nestjs/swagger&lt;/code&gt; decorators.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🗂️ &lt;strong&gt;Module Manifest&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;.generator.manifest.json&lt;/code&gt; tracks every generated module for easy&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/maher1719/Nestjs-clean-architecture-crud-modules-generator" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Why choose Clean Architecture
&lt;/h2&gt;

&lt;p&gt;Let's be honest, clean architecture is a good choice when you want to make maintainable, scalable, and predictable software. It has separation of concerns, modularity, and an onion-layered architecture so that one can extend the project's tools and infrastructure. It is just good for not spaghettifying your software and locking it into dependencies you cannot remove without breaking the whole project.&lt;/p&gt;

&lt;p&gt;However, it comes with a verbose and tiresome setup. For each entity you make, you need to make many different folders and files with certain exact names. A CRUD-heavy app will probably need more setup time, effort, and verification of folder and file names than the actual code without clean architecture. Also, even with a complex enterprise app, we could have at least ten or more entities, each one coming with its own setup of, again, folders and files, and when you repeat that, you will discover you just most of the time need to copy, paste, and change names...&lt;/p&gt;

&lt;p&gt;That is a major hurdle: you spent a great amount of time on setup more than needed and testing the suitability of what you did, giving complex logic and new features less and less time. &lt;/p&gt;

&lt;p&gt;However, if we repeat and copy-paste most of the CRUD setup, why not automate it? Automating the boring and tiresome hurdle, ensuring that, with careful design of the automation, it is predictable and the same across the different entities; That will mean fewer bugs: fix one, fix for all, homogeneous, all automated, are the same; no ninja or lazy special code for just one case that is hard to debug or maintain; all team members who generate will have the same structure of code... And most of all, more time to focus on the complex, fun things.&lt;/p&gt;

&lt;p&gt;Since I started working with clean architecture, I was impressed by how ordered and clean it is, but I was tired of repetitive setup. That's why I saw the opportunity to automate the CRUD operations with code that will generate entities, their CRUD operations, and relationships.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the NestJS Automation
&lt;/h2&gt;

&lt;p&gt;I first made a NestJS Clean Architecture code generator that handles the creation of entities with their folders and files. then I made a template of files and, inside them, the variable that need to change (e.g entity name, entity properties...), and the content of each file, since it is the same structure for each file type; only known variables need to change. It was really a blessing.&lt;br&gt;
here the template tree:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.
├── application
│&amp;nbsp;&amp;nbsp; ├── commands
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; ├── create-entity
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; ├── create-entity.command.ts.tpl
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; └── create-entity.handler.ts.tpl
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; ├── delete-entity
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; ├── delete-entity.command.ts.tpl
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; └── delete-entity.handler.ts.tpl
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; ├── replace-entity
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; ├── replace-entity.command.ts.tpl
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; └── replace-entity.handler.ts.tpl
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; └── update-entity
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp;     ├── update-entity.command.ts.tpl
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp;     └── update-entity.handler.ts.tpl
│&amp;nbsp;&amp;nbsp; └── queries
│&amp;nbsp;&amp;nbsp;     ├── get-entity
│&amp;nbsp;&amp;nbsp;     │&amp;nbsp;&amp;nbsp; ├── get-entity.handler.ts.tpl
│&amp;nbsp;&amp;nbsp;     │&amp;nbsp;&amp;nbsp; └── get-entity.query.ts.tpl
│&amp;nbsp;&amp;nbsp;     └── list-entity
│&amp;nbsp;&amp;nbsp;         ├── list-entity.handler.ts.tpl
│&amp;nbsp;&amp;nbsp;         └── list-entity.query.ts.tpl
├── domain
│&amp;nbsp;&amp;nbsp; ├── entities
│&amp;nbsp;&amp;nbsp; │&amp;nbsp;&amp;nbsp; └── entity.entity.ts.tpl
│&amp;nbsp;&amp;nbsp; └── repositories
│&amp;nbsp;&amp;nbsp;     ├── entity.repository.ts.tpl
│&amp;nbsp;&amp;nbsp;     └── list-options.ts.tpl
├── infrastructure
│&amp;nbsp;&amp;nbsp; └── persistence
│&amp;nbsp;&amp;nbsp;     ├── mappers
│&amp;nbsp;&amp;nbsp;     │&amp;nbsp;&amp;nbsp; └── entity.persistence-mapper.ts.tpl
│&amp;nbsp;&amp;nbsp;     └── typeorm
│&amp;nbsp;&amp;nbsp;         ├── entity.orm-entity.ts.tpl
│&amp;nbsp;&amp;nbsp;         └── entity.typeorm-repository.ts.tpl
├── module.ts.tpl
└── presentation
    ├── controllers
    │&amp;nbsp;&amp;nbsp; ├── entity.controller.ts.tpl
    │&amp;nbsp;&amp;nbsp; └── nested-list.controller.ts.tpl
    └── dto
        ├── create-entity.dto.ts.tpl
        ├── list-entity.dto.ts.tpl
        ├── replace-entity.dto.ts.tpl
        └── update-entity.dto.ts.tpl

20 directories, 25 files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is 20 directories and 25 files generated! And also 45 times you click "new folder" or "new file" and write the name! Imagine you have at least 10 entities; it will be 450 times. If we take 30 seconds to set up a single entity for each new file or folder, we need at least 22.5 minutes; with 10 entities, that's at least 3 hours 45 minutes just for basic setup! And 20 entities will be 7.5 hours, an entire workday of non-stop, flawless creation, without even writing any code. That alone is the most tedious.&lt;/p&gt;

&lt;p&gt;Also, for the generator to know what entities and their properties, I made it read Ya YAMLfile so we can keep track of what we will generate or update it easily. Here is an example of a comment entity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# modules/comment.yml&lt;/span&gt;
&lt;span class="na"&gt;module&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;comments&lt;/span&gt;
&lt;span class="na"&gt;parent&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;posts&lt;/span&gt;                 
&lt;span class="na"&gt;entity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Comment&lt;/span&gt;
  &lt;span class="na"&gt;table&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;comments&lt;/span&gt;
  &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;text&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;string&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postId&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;uuid&lt;/span&gt;
      &lt;span class="na"&gt;filterable&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; 
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;authorId&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;uuid&lt;/span&gt;
      &lt;span class="na"&gt;filterable&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;  &lt;span class="c1"&gt;#For sorting&lt;/span&gt;
&lt;span class="na"&gt;relations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# This is the AGGREGATE parent (must be cascade + non-nullable)&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;post&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;many-to-one&lt;/span&gt;
    &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Post&lt;/span&gt;
    &lt;span class="na"&gt;targetModule&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;posts&lt;/span&gt;
    &lt;span class="na"&gt;foreignKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postId&lt;/span&gt;
    &lt;span class="na"&gt;nullable&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="na"&gt;onDelete&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;cascade&lt;/span&gt;

  &lt;span class="c1"&gt;# This is just an association (also gets a nested GET, but not the "parent")&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;author&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;many-to-one&lt;/span&gt;
    &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;User&lt;/span&gt;
    &lt;span class="na"&gt;targetModule&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;users&lt;/span&gt;
    &lt;span class="na"&gt;foreignKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;authorId&lt;/span&gt;
    &lt;span class="na"&gt;nullable&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="na"&gt;onDelete&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;cascade&lt;/span&gt;

&lt;span class="na"&gt;operations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;create&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;list&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;get&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;update&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;delete&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have an example of an entity specification file: the name of the module, the parent name when it has aggregation, then the entity name and its database table name, its fields, its relationships, and its operations...&lt;/p&gt;

&lt;p&gt;We have enough information to make CRUD modules and write the files content. Also, when we delete, what will happen to other related entities? It follows database operations.&lt;/p&gt;

&lt;p&gt;For the generator itself, it is written in Python; here is the Python file tree&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;generator/
├── structure/
│   ├── cli.py                 # Entry point (single + bulk)
│   ├── config_loader.py       # YAML loading + aggregate validation
│   ├── generator.py           # Orchestrates file writing
│   ├── context.py             # Builds the template context
│   ├── output_mapper.py       # Template → output path mapping
│   ├── manifest.py            # .generator.manifest.json upsert
│   ├── app_module_updater.py  # Idempotent app.module.ts registration
│   ├── fields/                # Field builder package
│   │   ├── normalization.py   #   normalize fields/relations
│   │   ├── types.py           #   ts_type, typeorm_type
│   │   ├── domain.py          #   entity/command/handler builders
│   │   ├── dto.py             #   DTO + validator + swagger builders
│   │   ├── orm.py             #   ORM columns + imports
│   │   ├── mapping.py         #   domain ↔ ORM field mapping
│   │   └── registry.py        #   build_field_context orchestrator
│   └── relations/             # Relation builders
│       ├── many_to_one.py
│       ├── one_to_many.py
│       ├── one_to_one.py
│       ├── many_to_many.py
│       └── registry.py        # relation dispatcher
└── templates/                 # .tpl template sources
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With that, it will handle folder and file creation and code generation, support relations, and handle pagination and sorting.&lt;/p&gt;

&lt;p&gt;For the command to generate the modules, either specific ones or bulk generation, it will skip files that have already been generated, or you could force generation with --force:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Generate a single module&lt;/span&gt;
python &lt;span class="nt"&gt;-m&lt;/span&gt; generator.structure.cli modules/comment.yml &lt;span class="nt"&gt;--src&lt;/span&gt; src/

&lt;span class="c"&gt;# Bulk generate an entire folder&lt;/span&gt;
python &lt;span class="nt"&gt;-m&lt;/span&gt; generator.structure.cli modules/ &lt;span class="nt"&gt;--src&lt;/span&gt; src/ &lt;span class="nt"&gt;--force&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And with that, you could have the full project CRUD generated, ready for migration and already with Swagger!&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;While all this is good on day one, it is recommended to add any business custom logic outside the folders generated, so you can preserve your custom work!&lt;/p&gt;

&lt;p&gt;Also, automated testing files for generated code are not yet implemented, since I prioritized building first, but everything works with manual testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What next?
&lt;/h2&gt;

&lt;p&gt;I also made a React frontend counterpart of the generator that accords with our backend generator! I will write the next as an article!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Clean Architecture is very powerful, yet its setup overshadows its long-term benefits; with this generator, we could bypass its disadvantages to our advantage.&lt;/p&gt;

&lt;p&gt;If you're a CTO or engineering manager who values strict DDD and automated developer experience, I'm currently open to remote backend/full-stack roles. The generator is open-source on PyPI — try it out, and if it saves your team hours, let's talk.&lt;/p&gt;

&lt;p&gt;What do you think? What architecture do you use most in your project, and how do you handle the least favourite parts? Share with us in a comment so we can benefit each other!&lt;/p&gt;

</description>
      <category>python</category>
      <category>nestjs</category>
      <category>react</category>
      <category>ddd</category>
    </item>
  </channel>
</rss>
