DEV Community

Kashish
Kashish

Posted on

I Got Tired of Setting Up FastAPI Projects Manually — So I Built a CLI to Do It For Me

I'm a third year engineering student still learning FastAPI.
I came across this problem while building a project — had to create
all these files manually and thought there has to be a better way.

Here's what that painful setup looks like every single time:

  • Create the folder structure
  • Write models.py
  • Wire up the routes
  • Set up the database config
  • Write main.py
  • Install dependencies

I literally did all of this manually for one of my projects — typing
every file, every folder, every import from scratch in the terminal.
And halfway through I thought... why am I doing this again?

So over two nights I built a CLI that does all of it for me.

How it works

You define your models in a simple JSON file:

{
  "models": {
    "User": { "id": "int", "name": "str", "email": "str" },
    "Item": { "id": "int", "name": "str", "price": "float" }
  },
  "routes": ["User", "Item"]
}
Enter fullscreen mode Exit fullscreen mode

Then run one command:

python -m generator.cli myapp --json schema.json --db --install --run
Enter fullscreen mode Exit fullscreen mode

And you get a fully working FastAPI backend — SQLAlchemy models,
CRUD routes, database setup, everything — live at /docs in seconds.

No more copy pasting. No more manual setup.

What it generates

  • SQLAlchemy ORM models
  • Full CRUD routes for every model
  • Database configuration
  • FastAPI app entry point
  • requirements.txt

What I learned

Honestly building this taught me more about how FastAPI and SQLAlchemy
actually work under the hood than any tutorial did. When you're
generating the code yourself, you really have to understand every
single line of it.

Try it out

GitHub: https://github.com/CrestXcode/API-BOILERPLATE-GENERATOR

It's my first open source project and I'd love feedback — what's
missing, what could be better, would you actually use this? Drop
a comment! 🙏

And if it saved you even 10 minutes — that's enough for me!

Top comments (0)