DEV Community

ning3739
ning3739

Posted on

From repetitive FastAPI setups to a modular CLI generator

I’ve been building FastAPI projects in production for a while, and I kept running into the same problem every time I started a new service:

  • setting up database connections (PostgreSQL / MySQL / SQLite)
  • implementing JWT authentication
  • wiring up Redis for caching
  • configuring Celery for background tasks
  • writing Docker & Docker Compose configs
  • setting up Alembic migrations
  • configuring pytest (async, fixtures, etc.)

You know the drill.

After doing this repeatedly, I decided to extract everything into a reusable, interactive CLI tool called Forge, which generates a FastAPI project based on the features you actually need.


How it works

pip install ningfastforge
forge init
Enter fullscreen mode Exit fullscreen mode

The CLI walks you through a series of prompts, and based on your choices, it generates a complete project with:

  • ✅ A clean, production-oriented FastAPI project structure
  • ✅ Database setup (PostgreSQL / MySQL / SQLite) using SQLModel or SQLAlchemy
  • ✅ JWT authentication (basic or full flow with email verification)
  • ✅ Redis integration for caching
  • ✅ Celery configuration for background tasks
  • ✅ Docker & Docker Compose ready to use
  • ✅ Alembic migrations
  • ✅ pytest setup with async support

What makes this different from other templates?

The generator is modular.

  • Don’t need Redis? Skip it.
  • No authentication required? Skip it.
  • Only want a simple API with a database? That’s fine too.

Forge only generates the files and configuration for the features you select, instead of forcing a one-size-fits-all template.


Links


I’d love to get feedback from other FastAPI users:

  • How do you usually bootstrap new FastAPI projects?
  • What parts do you find most annoying to set up repeatedly?
  • Are there features you’d expect from a tool like this but don’t see yet?

Thanks for reading 🙌


Top comments (0)