A CLI tool to bootstrap FastAPI applications with best practices
Project description
๐ fastinit - FastAPI Project Generator CLI
A powerful, production-ready CLI tool built with Typer that bootstraps FastAPI applications with best practices, database support, JWT authentication, and more.
โจ Features
๐ฏ Project Initialization
- One-command project setup with intelligent defaults
- Interactive mode for guided configuration
- Multiple Python version support (3.8+)
๐๏ธ Database Integration
- PostgreSQL, MySQL, and SQLite support
- Pre-configured SQLAlchemy setup
- Alembic migrations with automatic settings import from pydantic_settings
- Database health checks included
๐ JWT Authentication
- PyJWT integration for token creation/verification
- PyJWKClient support for remote JWK verification
- Configurable JWKS endpoints
- Protected route examples
๐ Logging & Configuration
- Structured logging setup
- Environment-based configuration with Pydantic Settings
.envfile support
๐ณ Docker Ready
- Optimized Dockerfile
- Docker Compose with database services
๐จ Code Generation
- Generate SQLAlchemy models
- Generate service layers
- Generate API routes
- CRUD generators - create everything in one command
Installation
Install from source
pip install -e .
Install as a package (once published)
pip install fastinit
Install as dev dependency
pip install --dev fastinit
Usage
Initialize a new FastAPI project
# Basic project
fastinit init my-project
# With database support
fastinit init my-project --db
# With JWT authentication
fastinit init my-project --jwt
# With logging
fastinit init my-project --logging
# All features
fastinit init my-project --db --jwt --logging --docker
# Interactive mode
fastinit init my-project --interactive
Generate new components
# Generate a new model
fastinit new model User --fields "name:str,email:str,age:int"
# Generate Pydantic schemas (for request/response validation)
fastinit new schema User --fields "name:str,email:str,age:int"
# Generate a new service
fastinit new service UserService --model User
# Generate a new route/controller
fastinit new route users --service UserService
# Generate all at once (model + schema + service + route)
fastinit new crud User --fields "name:str,email:str,age:int"
# Generate with different pagination strategies
fastinit new crud Product --pagination cursor # Cursor-based pagination
fastinit new route users --pagination none # No pagination
fastinit new service UserService --pagination cursor # Custom pagination for service
Configuration Options
# Choose database type
fastinit init my-project --db --db-type postgresql
# Options: postgresql, mysql, sqlite
# Specify Python version
fastinit init my-project --python-version 3.11
Project Structure
my-project/
โโโ app/
โ โโโ __init__.py
โ โโโ main.py
โ โโโ config.py
โ โโโ api/
โ โ โโโ __init__.py
โ โ โโโ routes/
โ โ โ โโโ __init__.py
โ โ โ โโโ health.py
โ โ โโโ deps.py
โ โโโ core/
โ โ โโโ __init__.py
โ โ โโโ config.py
โ โ โโโ security.py (if --jwt)
โ โโโ models/
โ โ โโโ __init__.py
โ โโโ schemas/
โ โ โโโ __init__.py
โ โโโ services/
โ โ โโโ __init__.py
โ โโโ db/
โ โโโ __init__.py
โ โโโ session.py (if --db)
โโโ tests/
โ โโโ __init__.py
โโโ .env.example
โโโ .gitignore
โโโ requirements.txt
โโโ README.md
โโโ Dockerfile (if --docker)
Examples
Basic FastAPI App
fastinit init my-api
cd my-api
pip install -r requirements.txt
uvicorn app.main:app --reload
Full-Featured App
fastinit init my-api --db --jwt --logging --docker
cd my-api
docker-compose up
Generate CRUD Components
cd my-api
fastinit new crud Product --fields "name:str,price:float,description:text"
# Creates:
# - app/models/product.py (SQLAlchemy model)
# - app/schemas/product.py (Pydantic schemas for validation)
# - app/services/product_service.py (Business logic)
# - app/api/routes/products.py (REST API endpoints)
๐ Documentation
- Quick Start - Get started in 5 minutes
- Usage Guide - Complete reference
- Visual Guide - Visual diagrams and examples
- Alembic Integration - Database migrations with auto-import settings
- Features - Complete feature list
- Examples - Code examples
๐ ๏ธ Development
- Contributing - How to contribute
- Changelog - Version history
- Scripts - Development and demo scripts
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
๐ License
MIT License - see LICENSE for details
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 fastinit-0.2.0.tar.gz.
File metadata
- Download URL: fastinit-0.2.0.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67ea5fb6cde10fa7064b043641603297244f54098781d4382d961c41a403809d
|
|
| MD5 |
526f3054b5f7d8c474e6a50d8a194d60
|
|
| BLAKE2b-256 |
a984b4cecf431b3b0f9b58e5eb72a594f2ba35148f8bd4334c1a60bb9d44b572
|
File details
Details for the file fastinit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: fastinit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 34.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c5968b6eed14551d27b1f34c4664075f0a8cc935b4e71c2fc885bf5836a462d
|
|
| MD5 |
9ae0dcd7aad1aaf81bce29c739f7ca3a
|
|
| BLAKE2b-256 |
e7f6397778bbb49c3cea72b7e119c817ad2429a7496dd84929b8aaeac3bd3301
|