Skip to main content

🚀 fastapi-simple-scaffold

Modular FastAPI, SQLAlchemy 2.0 & Alembic REST API Scaffolding & CLI Code Generator

fastapi-simple-scaffold is a powerful CLI tool and code generator that scaffolds production-ready, modular FastAPI backend projects and component stacks (modules, models, routers, services, middleware, migrations, seeders, relationships, cron jobs, background tasks, email notifications, and pytest suites) in seconds.


⚡ Quick Start

Installation via pip

pip install fastapi-simple-scaffold

After installation, you can run generator commands using the CLI shortcut:

  • fastapi-scaffold [command] (or fscaffold [command])

💡 Note: If running via python -m, use underscores for the Python module name: python -m fastapi_simple_scaffold.cli [command]


🚀 Creating a New FastAPI Project

# Create project structure in a new directory:
fastapi-scaffold my-api

# Or create inside the current working directory:
cd my-api
fastapi-scaffold structure

Once generated, start your server in 2 commands:

cd my-api
pip install -r requirements.txt
python run.py

Your API with Swagger UI is live at: http://127.0.0.1:8000/docs 🎉


🛠️ CLI Generator Commands

Run generator commands directly inside your scaffolded project:

# Launch interactive CLI Dashboard Studio
fastapi-scaffold

# Scaffold a full resource stack (Model + Migration + Module)
fastapi-scaffold make:resource Product

# Generate a layered feature module (Router, Schemas, Service, Repository)
fastapi-scaffold make:module Payment

# Generate a SQLAlchemy 2.0 mapped model
fastapi-scaffold make:model Order

# Generate a standalone APIRouter
fastapi-scaffold make:router Invoice

# Generate a Service business logic layer
fastapi-scaffold make:service Analytics

# Generate custom FastAPI / Starlette middleware
fastapi-scaffold make:middleware RateLimiter

# Generate a timestamped Alembic database migration
fastapi-scaffold make:migration create_orders_table

# Generate a database seeder script
fastapi-scaffold make:seeder Product

# Scaffold foreign key relationship between models
fastapi-scaffold make:relation User Order has_many

# Generate an HTML email notification service & template
fastapi-scaffold make:notification WelcomeEmail

# Generate a scheduled cron / background worker job
fastapi-scaffold make:cron DailyReport "0 0 * * *"

# Generate an automated pytest test suite
fastapi-scaffold make:test Product

# Display formatted table of all registered API endpoints
fastapi-scaffold route:list

# Run system health diagnostics
fastapi-scaffold doctor

📋 Command Reference Table

Command Shortcut / Alias Description
fastapi-scaffold fscaffold Interactive CLI studio dashboard
fastapi-scaffold [dir] fastapi-scaffold init [dir] Generate complete backend project structure
make:resource <Name> make:resource Product Full resource stack (Model + Module + Migration)
make:module <Name> make:module Payment Layered feature module (Router, Schemas, Service, Repository)
make:model <Name> make:model Vehicle Generates SQLAlchemy 2.0 mapped model
make:router <Name> make:controller <Name> Generates a standalone APIRouter
make:service <Name> make:service Payment Generates a service class
make:middleware <Name> make:middleware Auth Generates custom Starlette/FastAPI middleware
make:migration <Name> make:migration add_orders Generates timestamped Alembic migration revision
make:seeder <Name> make:seed <Name> Generates database seeder script
make:relation <Src> <Tgt> make:association User Order Scaffolds model foreign key relationship
make:notification <Name> make:email <Name> Generates email notification service and HTML template
make:cron <Name> [expr] make:job <Name> Generates scheduled background worker job
make:test <Name> make:test Auth Generates automated pytest test suite
route:list routes Displays formatted table of all registered endpoints
doctor cli:doctor Performs health check on env, DB, and dependencies

📂 Project Structure Generated

Running fastapi-scaffold my-api creates a clean, modular layout:

my-api/
├── app/
│   ├── core/               # Settings (Pydantic), DB Engine, Security, Lifespan
│   ├── models/             # SQLAlchemy 2.0 mapped models
│   ├── modules/            # Domain feature modules (Auth, Users, etc.)
│   │   └── [feature]/
│   │       ├── router.py       # API endpoints & dependency injection
│   │       ├── schemas.py      # Pydantic v2 schemas
│   │       ├── service.py      # Business logic
│   │       └── repository.py   # SQLAlchemy database queries
│   ├── middleware/         # CORS, Timing, Error Handlers
│   ├── notifications/      # HTML email templates & mailer services
│   ├── jobs/               # Background tasks & cron scheduler
│   ├── utils/              # Standard JSON response envelope & logger
│   ├── database/           # Seeders & DB initializers
│   └── main.py             # FastAPI entrypoint with OpenAPI docs
├── alembic/                # Alembic database migrations
├── tests/                  # Automated integration & unit tests
├── .env.example            # Environment configuration template
├── .env                    # Active local environment
├── requirements.txt        # Production dependencies
├── run.py                  # Dev server runner
└── README.md

📄 License

MIT License - Developed with ❤️ by Krishna Pawar.

Metadata

Release files for fastapi-simple-scaffold 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-simple-scaffold 1.0.1
File Size Uploaded
fastapi_simple_scaffold-1.0.1.tar.gz 35.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-simple-scaffold 1.0.1
File Interpreter ABI Platform
fastapi_simple_scaffold-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 78.0 kB

Release files / fastapi_simple_scaffold-1.0.1.tar.gz

Download URL fastapi_simple_scaffold-1.0.1.tar.gz
Size 35.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4868195dad72a4c7f61c4b54ba13308afd464084b0406b9ff5251642736d02b9
BLAKE2b-256 checksum
How to use checksums
f6018f889f7211f100bf0e12a512c4738e4910a1fec0497390fb0c6ff8cedd78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Release files / fastapi_simple_scaffold-1.0.1-py3-none-any.whl

Download URL fastapi_simple_scaffold-1.0.1-py3-none-any.whl
Size 42.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6a73105d338e652edf28e1e19d7a46a2f82808d4c96f64f13508914cb093683
BLAKE2b-256 checksum
How to use checksums
ccf5af5138a1a77b34c504ab9a3313e494c0fa198868fa39ecff55349f2608ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

1.0.2

2 release files

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page