fastapi-maker
🚀 FastAPI project scaffolding CLI – Generate production-ready CRUD modules in seconds with explicit field requirements, realistic examples, clean offline Swagger documentation, and database relationships.
A powerful command-line tool to bootstrap and scale FastAPI applications with a clean, maintainable architecture:
- Auto-generated SQLAlchemy models with
id,created_at,updated_at, and custom fields - Pydantic v2 DTOs (Create, Update, Response) with accurate type hints and validation
- Repository + Service pattern for separation of concerns
- Routers auto-registered in
main.pywith clean path parameters - Database relationships with interactive setup for One-to-Many, Many-to-Many, and One-to-One
- Alembic pre-configured with models auto-imported
- Offline API Documentation with Swagger UI and ReDoc (no CDN required)
- Environment management via
.envfor example:
import os
from dotenv import load_dotenv
load_dotenv()
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./app.db")
- Self-documenting OpenAPI specs with clear required/optional field indicators
Perfect for rapid prototyping, MVP development, or enforcing consistent structure across engineering teams.
✨ Features
Core Commands
fam init→ Initialize a new FastAPI project with database, Alembic, CORS, logging, and offline documentationfam create <entity> [fields...]→ Generate a full CRUD module with customizable fieldsfam relation→ Create relationships between existing entities (One-to-Many, Many-to-Many, One-to-One)fam migrate [-m "message"]→ Auto-generate and apply database migrations with Alembicfam lint [--check|--fix|--format|--all]→ Lint and format code using Ruff (default: check + format)fam audit [--fix]→ Audit dependencies for security vulnerabilities using pip-audit (by default check or fix with flag)
🛡️ Offline API Documentation
- Zero CDN dependencies - All Swagger UI and ReDoc assets served locally
- Privacy-focused - No external network requests for documentation
- Fast loading - Documentation works without internet connection
- Customizable - Easy to configure themes and favicons
- Powered by
fastapi-standalone-docs- Visit for advanced configuration options
Smart Field Definition Syntax
Define required vs optional fields using intuitive syntax:
fam create user *name:str email:str age:int is_active:bool
*name:str→ required field (namemust be provided)email:str→ optional field (emailcan be omitted)
Supported Field Types
| Type | SQL Type | Pydantic Type | Example Value |
|---|---|---|---|
str |
String(255) |
str |
"John Doe" |
text |
Text |
str |
"A detailed description…" |
int |
Integer |
int |
42 |
bigint |
BigInteger |
int |
9007199254740991 |
float |
Float |
float |
3.14 |
bool |
Boolean |
bool |
true |
date |
Date |
date |
"2023-10-05" |
datetime |
DateTime |
datetime |
"2023-10-05T14:30:00" |
email |
String(255) |
str |
"user@example.com" |
url |
String(255) |
str |
"https://example.com" |
Auto-Generated Module Structure
app/api/user/
├── user_model.py # SQLAlchemy ORM model with nullable rules
├── user_repository.py # CRUD database operations
├── user_service.py # Business logic and DTO mapping
├── user_router.py # FastAPI routes (auto-registered in main.py)
└── dto/
├── user_in_dto.py # Input validation (Create)
├── user_update_dto.py # Partial updates (Patch)
└── user_out_dto.py # API responses (with id, created_at, updated_at)
Database Relationships
Create relationships between entities with an interactive wizard:
fam relation
Supported relationship types:
- One-to-Many: e.g., User has many Orders
- Many-to-Many: e.g., Products belong to multiple Categories
- One-to-One: e.g., User has one Profile
Automatic updates include:
- SQLAlchemy ForeignKey and relationship() fields
- DTOs with relation fields (
user_idorcategory_ids) - Service layer mapping logic
- Association tables for Many-to-Many relationships
Production-Ready Swagger (OpenAPI) Docs
- Clean route display:
/users/{user_id}instead of/users/user_id - Clear field requirements: POST endpoint description lists Required and Optional fields
- Realistic examples: Type-specific values (
"user@example.com",42,true) instead of generic placeholders - Full visibility: All fields appear in schema documentation, even optional ones
- Accurate nullability: Optional fields correctly marked as nullable in responses
- Offline functionality: Documentation works completely offline using local assets
Database Support & Migrations
- Multi-database support: SQLite, PostgreSQL, and MySQL
- Auto-database creation: Automatically creates database if it doesn't exist
- Smart migrations: Alembic configured with environment-based settings
- SQLite compatibility: Proper handling of autoincrement primary keys
Safe Data Handling
- OutDTOs accept
Nonefor optional fields → prevents validation errors when DB returnsNULL - Always includes
datetimeimport in OutDTOs forcreated_at/updated_at - Parameter name consistency → no more
NameError: name 'xxx_data' is not defined
📦 Installation
pip install fastapi-maker
🚀 Quick Start
# Initialize a new project with offline documentation
fam init
# Create a User entity with required name and optional fields
fam create user *name:str email:str age:int is_active:bool
# Create an Order entity
fam create order *amount:float status:str
# Create a relationship between User and Order (One-to-Many)
fam relation
# Follow the interactive prompts to create a User -> Order relationship
# Run database migrations (auto-creates database if needed)
fam migrate -m "Add user and order tables with relationship"
# Start your FastAPI app with offline documentation
python3 -m app.main
Then visit http://localhost:8000/docs to see your auto-generated, fully-documented API - completely offline!
🔧 Advanced Configuration
Offline Documentation Customization
The generated project uses fastapi-standalone-docs for offline documentation. You can customize it in app/main.py:
from fastapi_standalone_docs import StandaloneDocs
app = FastAPI()
# Basic configuration (included by default)
StandaloneDocs(app=app)
# Advanced configuration
StandaloneDocs(
app=app,
redoc_favicon_url="/custom-favicon.png", # Custom favicon
swagger_favicon_url="/custom-favicon.png",
with_google_fonts=True, # Enable Google Fonts (disabled by default)
)
Database Configuration
Supported database URLs in your .env file:
# SQLite (default)
DATABASE_URL=sqlite:///./app.db
# PostgreSQL
DATABASE_URL=postgresql://user:password@localhost:5432/mydatabase
# MySQL
DATABASE_URL=mysql://user:password@localhost:3306/mydatabase
🎯 Use Cases
- Rapid Prototyping: Go from idea to working API in minutes
- MVP Development: Perfect for startups and hackathons
- Team Consistency: Enforce clean architecture across engineering teams
- Learning FastAPI: Excellent for understanding FastAPI best practices
- Production APIs: Solid foundation for scalable applications
- Database Modeling: Build complex data models with relationships easily
🤝 Contributing
We welcome contributions! Feel free to:
- Report bugs and suggest features
- Submit pull requests
- Improve documentation
- Share your use cases
📄 License
MIT License - feel free to use in commercial projects.
💡 Pro Tip: Use
*prefix to mark fields as required — everything else is optional by default. Your API consumers will thank you for the clarity!
🌐 Documentation Note: Your API docs work completely offline thanks to
fastapi-standalone-docs. Perfect for development in restricted environments or when privacy matters!
🔗 Relationship Tip: Use
fam relationafter creating your entities to build connected data models with proper foreign keys and DTOs.
Metadata
Release files for fastapi-maker 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapi_maker-0.2.5.tar.gz | 42.5 kB | Without provenance | Details for fastapi_maker-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_maker-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for fastapi_maker-0.2.5-py3-none-any.whl |
Total release size: 89.0 kB
Release files / fastapi_maker-0.2.5.tar.gz
| Download URL | fastapi_maker-0.2.5.tar.gz |
|---|---|
| Size | 42.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6e61229e06e4543f8fd7248fcf1af37600f2b47d557615498e2c037fae5da26
|
|
BLAKE2b-256 checksum How to use checksums |
118d2bb3ad49af8310891e00153b34e0b2594580b9e08a01a0ba468e8ced83db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / fastapi_maker-0.2.5-py3-none-any.whl
| Download URL | fastapi_maker-0.2.5-py3-none-any.whl |
|---|---|
| Size | 46.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
790f6030f6d0687a8eee552f69ccd18c686332099c554d5a525bc6e19090837a
|
|
BLAKE2b-256 checksum How to use checksums |
7aaf51e744d3c32bc356063e06c577c973fc95b71184b1d6d6774e09ac4e3aee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for fastapi-maker 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.