A powerful CLI tool to scaffold production-ready FastAPI projects with flexible database, auth, broker, and deployment options.
Project description
⚡ fastapi-spawn
The most complete FastAPI project scaffolding CLI — built for modern Python development.
Why fastapi-spawn?
fastapi-spawn generates production-ready FastAPI projects in seconds. No boilerplate, no guesswork — just run one command and get a fully structured, configured project with the exact stack you need.
| Feature | scaffold-fastapi | fastapi-spawn |
|---|---|---|
| Interactive TUI | Basic prompts | ✅ Rich questionary TUI |
| Databases | PostgreSQL, MongoDB, SQLite | ✅ + MySQL |
| ORM | None | ✅ SQLAlchemy 2.x, Tortoise, Beanie |
| Migrations | ❌ | ✅ Alembic (async), Aerich |
| Auth | ❌ | ✅ JWT, OAuth2, API Key |
| Message brokers | Redis, RabbitMQ | ✅ + Kafka |
| File storage | ❌ | ✅ AWS S3 (boto3) |
| AI integration | ❌ | ✅ OpenAI, Anthropic |
| Config style | Single URL | ✅ Individual fields + @property URL |
| Entry point | app/main.py | ✅ Root main.py (uv run main.py) |
| CI/CD | GitHub Actions | ✅ GitHub Actions + GitLab CI |
| Observability | ❌ | ✅ /health /readiness /liveness |
| Logging | None | ✅ loguru / structlog / standard |
| Package manager | uv | ✅ uv (with [tool.uv] config) |
| Dry-run mode | ❌ | ✅ Preview tree before generating |
Installation
pip install fastapi-spawn
# or
uv pip install fastapi-spawn
Quick Start
# Fully interactive — guided TUI
fastapi-spawn new my-api
# One-liner (all flags)
fastapi-spawn new my-api \
--db postgresql \
--orm sqlalchemy \
--migration alembic \
--auth jwt \
--broker redis \
--storage s3 \
--ai openai \
--stack full \
--ci github \
--log-lib loguru
# Preview without writing files
fastapi-spawn new my-api --dry-run
Generated Project Structure
my-api/
├── app/
│ ├── api/
│ │ └── v1/
│ │ ├── health.py # /health /readiness /liveness
│ │ └── auth.py # JWT login + refresh
│ ├── core/
│ │ ├── config.py # Pydantic Settings v2 (individual env fields)
│ │ ├── logging.py # loguru / structlog / standard
│ │ ├── exceptions.py # Custom exception hierarchy
│ │ ├── security.py # JWT + bcrypt (when auth enabled)
│ │ ├── storage.py # AWS S3 utils (when s3 chosen)
│ │ └── ai.py # OpenAI / Anthropic client (when AI chosen)
│ ├── db/
│ │ └── session.py # Async SQLAlchemy / Tortoise / Beanie
│ ├── models/ # ORM models
│ ├── schemas/ # Pydantic schemas
│ ├── services/ # Business logic layer
│ └── repositories/ # Data access layer
├── tasks/ # Celery workers (root-level)
│ ├── celery_app.py
│ └── sample_tasks.py
├── migrations/ # Alembic migrations
│ ├── env.py # Async-compatible env
│ └── versions/
├── infra/
│ ├── docker/
│ ├── helm/
│ └── terraform/
├── tests/
│ ├── conftest.py
│ └── test_health.py
├── main.py # uv run main.py entry point
├── alembic.ini
├── Dockerfile # Uses uv for fast builds
├── docker-compose.yml # All services pre-configured
├── .env # gitignored
├── .env.example
├── .gitignore
├── .pre-commit-config.yaml
├── Makefile
└── pyproject.toml # uv-compatible
Environment Variables
fastapi-spawn generates individual env fields (not URL strings) for every service, assembled into URLs via @property:
# PostgreSQL — assembled into DATABASE_URL by settings
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=my_api_db
# OpenAI — supports custom base URL for Azure / LM Studio
OPENAI_API_KEY=sk-placeholder
OPENAI_MODEL=gpt-4o
OPENAI_BASE_URL= # blank = api.openai.com
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_DB=0
All Options
fastapi-spawn new [OPTIONS] PROJECT_NAME
--db postgresql | mysql | mongodb | sqlite | none
--orm sqlalchemy | tortoise | beanie | none
--migration alembic | aerich | none
--auth jwt | oauth2 | api-key | none
--broker redis | rabbitmq | kafka | none
--cache redis | memcached | none
--storage s3 | local | none
--ai openai | anthropic | none
--stack minimal | standard | full
--ci github | gitlab | both | none
--log-lib loguru | structlog | standard
--no-docker Skip Docker files
--no-tests Skip test suite
--dry-run Preview file tree only
--force / -f Overwrite existing directory
--output / -o Output directory (default: .)
Subcommands
fastapi-spawn list-templates # Show all options + ORM/DB compatibility
fastapi-spawn validate FILE # Validate a .fastapi-spawn.toml
After Scaffolding
cd my-api
uv sync # Install all dependencies
uv run alembic upgrade head # Run DB migrations (if alembic)
docker compose up --build # Start all services
# or
uv run main.py # Run locally
ORM ↔ Database Compatibility
| ORM | Compatible Databases |
|---|---|
sqlalchemy |
postgresql, mysql, sqlite |
tortoise |
postgresql, mysql, sqlite |
beanie |
mongodb |
none |
any |
Contributing
git clone https://github.com/Bishwajitgarai/fastapi-spawn
cd fastapi-spawn
uv sync --all-extras
uv run pytest
PRs are welcome! See CONTRIBUTING.md.
License
MIT © Bishwajit Garai
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_spawn-0.1.0.tar.gz.
File metadata
- Download URL: fastapi_spawn-0.1.0.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4fef64dcbfa064934cd6516673be478303098b15e8078e55626c8b4b402497c
|
|
| MD5 |
76ab344c0ffbd3c63cab44e0110d1acd
|
|
| BLAKE2b-256 |
36a5330b12b200635005d6c6acf55b7b036f1048f19ccdc90149c99f554b2ae0
|
File details
Details for the file fastapi_spawn-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fastapi_spawn-0.1.0-py3-none-any.whl
- Upload date:
- Size: 46.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
752aebcb8a21cc2b64b1d16bd688a4ce64d559956894a242042402ace89b0263
|
|
| MD5 |
50296983655580c0267fd730d9c2c4bd
|
|
| BLAKE2b-256 |
f8a50b08efb19b5cff1a8c633aba809af570f1c063d4ed04b14437c61372376d
|