agusmdev / fastapi-ddd-cookiecutter

This project is a backend template for a FastAPI-based application that uses the repository pattern approach to provide an abstraction layer between the business logic and the data access layer. It aims to provide a scalable and maintainable architecture for building web applications.
MIT License
41 stars 5 forks source link

About supporting the creation of multiple entities #9

Open leferrad opened 1 year ago

leferrad commented 1 year ago

Opening a discussion about pros / cons of this template allowing the user to create more than just 1 entity

leferrad commented 1 year ago

Some pros I found:

Some cons on the other hand:

leferrad commented 1 year ago

Maybe it would be convenient to specify entities + relationships in a config file (e.g. YAML file), so the prompt will ask for that config file to generate the template based on that. Otherwise, it is not nice to specify everything in a prompt (as a developer, I like to have everything well defined in a config file)

agusmdev commented 1 year ago

I was thinking a lot about this, and my conclusion was the next one: Adding the ability to automatically generate more entities without taking into account their relationship doesn't make any sense, it adds overall complexity and little to no value. Maybe we can consider making another script to generate these isolated entities from the CLI (after the cookie-cutter was executed and the architecture was all set up) with something like ./scripts/generate_entity.py --user and this creates the same structure as the original first entity but for the user entity.

That said, the best of all worlds would be generating a whole architecture from an entity-relationship diagram so we have there all the models, the entities, and how their relationships are, but I can't think of a solution to generate all this structure at once.

agusmdev commented 1 year ago

I guess we should start sharing the template and see what the community says about it and what they suggest to evolve this

agusmdev commented 1 year ago

@leferrad suggested checking https://github.com/koxudaxi/fastapi-code-generator it seems promising