A modern FastAPI project scaffolding CLI tool
Project description
Forge is a powerful command-line tool that helps you quickly bootstrap production-ready FastAPI projects with best practices, intelligent defaults, and a beautiful interactive interface.
โจ Features
- ๐จ Beautiful Interactive UI - Stunning terminal interface with gradient colors and smooth animations
- ๐ Smart Presets - Carefully curated presets for testing, dev tools, deployment, and monitoring
- ๐ Authentication Ready - Built-in support for JWT authentication (Basic & Complete)
- ๐๏ธ Database Flexibility - Support for PostgreSQL and MySQL with SQLModel/SQLAlchemy
- ๐ฆ Modular Architecture - Choose only the features you need
- ๐งช Testing Built-in - Pre-configured pytest with async support and coverage
- ๐ณ Docker Ready - Production-ready Docker and Docker Compose configurations
- ๐ Type Safe - Full type hints throughout generated code
- โก Async First - Optimized for FastAPI's async capabilities
๐ Requirements
- Python 3.9+
- uv (recommended) or pip
๐ Quick Start
Installation
From PyPI (Recommended)
pip install ningfastforge
From Source
# Clone the repository
git clone https://github.com/ning3739/forge.git
cd forge
# Install with uv (recommended)
uv sync
# Or with pip
pip install -e .
Create Your First Project
# Interactive mode (recommended)
forge init
# Or specify project name
forge init my-awesome-api
# Non-interactive mode with defaults
forge init my-api --no-interactive
Run Your Project
cd my-awesome-api
uv sync
uv run uvicorn app.main:app --reload
# Visit:
http://127.0.0.1:8000/docs # docs
http://127.0.0.1:8000/redoc #redoc
๐๏ธ Architecture
Forge follows a "Configuration-First" design principle with a dynamic generator system:
- Init Command collects user preferences interactively
- Configuration File (
.forge/config.json) is saved first - Dynamic Generator System automatically discovers and executes generators based on configuration
Dynamic Generator System
Forge uses a decorator-based system for automatic generator discovery and management:
@Generator(
category="model",
priority=40,
requires=["DatabaseConnectionGenerator"],
enabled_when=lambda c: c.has_auth()
)
class UserModelGenerator:
def generate(self):
# Generate user model code
Benefits:
- โ Automatic generator discovery - no manual registration needed
- โ Dependency resolution - generators execute in correct order
- โ Conditional execution - only enabled generators run
- โ Easy extensibility - add new generators by creating files
This separation ensures:
- โ Configuration persistence and traceability
- โ Clear separation of concerns
- โ Easy project regeneration and updates
- โ Configuration sharing and templates
- โ Modular and maintainable codebase
๐ฏ Configuration Options
Database Options
- PostgreSQL (Recommended) - Robust, feature-rich, excellent for production
- MySQL - Popular, widely supported relational database
ORM Support
- SQLModel (Recommended) - Modern, type-safe ORM built on SQLAlchemy and Pydantic
- SQLAlchemy - Mature and powerful ORM with extensive features
Authentication & Security
Authentication Options
- Complete JWT Auth (Recommended) - Full-featured authentication system
- Login & Register
- Email Verification
- Password Reset (Forgot Password)
- Email Service (SMTP)
- Refresh Token
- Basic JWT Auth - Simple authentication
- Login & Register only
- Optional Refresh Token
Security Features
- CORS (Configurable)
- Rate Limiting (Built-in decorator - auto-included)
- Input Validation (Pydantic - auto-included)
- Password Hashing (bcrypt - auto-included with auth)
- SQL Injection Protection (ORM - auto-included)
- XSS Protection (FastAPI - auto-included)
Core Features
All projects include:
- Logging - Structured logging (automatically included)
- API Documentation - Swagger UI and ReDoc (automatically included)
- Health Check - Basic health check endpoint (automatically included)
- Rate Limiting - Decorator-based rate limiting for API protection (automatically included)
Development Tools
- Standard (Recommended) - Black (formatter) + Ruff (linter)
- None - Skip dev tools
Testing Setup
When you enable testing, Forge generates:
- pytest - Testing framework with async support
- httpx - HTTP client for testing
- pytest-cov - Code coverage
- pytest-asyncio - Async test support
Generated Test Files:
tests/conftest.py- Pytest configuration with database fixturestests/test_main.py- Tests for main API endpoints (health check, docs)tests/api/test_auth.py- Authentication endpoint teststests/api/test_users.py- User endpoint tests
Running Tests:
# Run all tests
pytest
# Run with coverage
pytest --cov=app tests/
# Run specific test file
pytest tests/test_main.py
# Run with verbose output
pytest -v
Deployment
- Docker - Dockerfile and docker-compose.yml
- Includes database service configuration
- Production-ready setup
๐ Generated Project Structure
my-awesome-api/
โโโ app/
โ โโโ __init__.py
โ โโโ main.py # FastAPI application entry point
โ โโโ core/
โ โ โโโ config/ # Configuration management
โ โ โ โโโ base.py # Base configuration
โ โ โ โโโ settings.py # Settings aggregator
โ โ โ โโโ modules/ # Config modules (app, database, jwt, cors, email, logger)
โ โ โโโ database/ # Database connection
โ โ โ โโโ connection.py
โ โ โ โโโ dependencies.py
โ โ โ โโโ postgresql.py / mysql.py
โ โ โโโ deps.py # Global dependencies
โ โ โโโ logger.py # Logging configuration
โ โ โโโ security.py # Security utilities (password hashing, JWT)
โ โโโ decorators/ # Custom decorators
โ โ โโโ rate_limit.py # Rate limiting decorator
โ โโโ models/ # Database models
โ โ โโโ user.py
โ โ โโโ token.py # (if refresh token enabled)
โ โโโ schemas/ # Pydantic schemas
โ โ โโโ user.py
โ โ โโโ token.py
โ โโโ crud/ # CRUD operations
โ โ โโโ user.py
โ โ โโโ token.py # (if refresh token enabled)
โ โโโ services/ # Business logic
โ โ โโโ auth.py
โ โโโ routers/ # API routes
โ โ โโโ v1/ # API version 1
โ โ โโโ __init__.py # Router aggregator
โ โ โโโ auth.py
โ โ โโโ users.py
โ โโโ utils/ # Utility functions
โ โโโ email.py # (if complete auth enabled)
โโโ tests/ # Test files (if enabled)
โ โโโ conftest.py # Pytest configuration and fixtures
โ โโโ test_main.py # Main API endpoint tests
โ โโโ api/
โ โ โโโ test_auth.py # Authentication tests
โ โ โโโ test_users.py # User endpoint tests
โ โโโ unit/ # Unit tests directory
โโโ alembic/ # Database migrations (if enabled)
โ โโโ versions/ # Migration versions
โ โโโ env.py # Alembic environment
โ โโโ script.py.mako # Migration template
โ โโโ README.md
โโโ static/ # Static files
โ โโโ email_template/ # Email templates (if complete auth)
โ โโโ base.html
โ โโโ verification.html
โ โโโ password_reset.html
โ โโโ welcome.html
โโโ secret/ # Environment files
โ โโโ .env.example # Environment variables template
โ โโโ .env.development # Development environment
โ โโโ .env.production # Production environment
โโโ docker-compose.yml # Docker Compose configuration (if enabled)
โโโ Dockerfile # Docker configuration (if enabled)
โโโ .dockerignore # Docker ignore file (if enabled)
โโโ .gitignore # Git ignore file
โโโ pyproject.toml # Project dependencies
โโโ uv.lock # UV lock file
โโโ README.md # Project documentation
๐จ Smart Features
Intelligent Defaults
- Database: PostgreSQL with SQLModel
- Migration: Alembic enabled
- Authentication: Complete JWT Auth with Refresh Token
- Security: CORS enabled
- Dev Tools: Black + Ruff
- Testing: pytest with coverage
- Deployment: Docker + Docker Compose
Technology Recommendations
- PostgreSQL for database (production-ready, feature-rich)
- SQLModel for ORM (modern, type-safe, FastAPI-friendly)
- JWT for authentication (stateless, scalable, API-friendly)
- Alembic for migrations (industry standard)
๐ ๏ธ Commands
forge init
Initialize a new FastAPI project with interactive prompts.
# Interactive mode
forge init
# Specify project name
forge init my-project
# Non-interactive mode (uses defaults)
forge init my-project --no-interactive
forge --version
Show the current version of Forge.
forge --version
# or
forge -v
๐ฏ Best Practices
For API Projects
โ
PostgreSQL + SQLModel
โ
Complete JWT Auth
โ
CORS enabled
โ
Black + Ruff
โ
pytest with coverage
โ
Docker deployment
For Simple Projects
โ
PostgreSQL + SQLModel
โ
Basic JWT Auth (or no auth)
โ
CORS enabled
โ
Docker deployment
๐ Project Structure
Forge/
โโโ commands/ # CLI command modules
โ โโโ __init__.py # Command exports
โ โโโ init.py # Project initialization command
โโโ core/ # Core business logic
โ โโโ decorators/ # Decorator system
โ โ โโโ generator.py # @Generator decorator and registry
โ โโโ config_reader.py # Configuration file reader
โ โโโ project_generator.py # Project generator
โ โโโ generators/ # Code generators
โ โ โโโ structure.py # Project structure generator
โ โ โโโ orchestrator.py # Dynamic generator coordinator
โ โ โโโ configs/ # Config file generators
โ โ โโโ deployment/ # Deployment config generators
โ โ โโโ templates/ # Application code generators
โ โโโ utils/ # Utility functions
โโโ ui/ # User interface components
โ โโโ colors.py # Color management system
โ โโโ components.py # UI components
โ โโโ logo.py # Logo rendering
โโโ main.py # CLI entry point
โโโ pyproject.toml # Project configuration
โโโ README.md # This file
Key Components
@GeneratorDecorator - Automatic generator registration systemorchestrator.py- Discovers and executes generators in correct order- 40+ Generators - Each responsible for specific files/features
- Configuration-First - All decisions driven by
.forge/config.json
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
# Clone the repository
git clone https://github.com/ning3739/forge.git
cd forge
# Install dependencies
uv sync
# Test build
./scripts/test_build.sh
Publishing
Automated Release Process
The project uses automated publishing via GitHub Actions:
- Update version in
pyproject.toml - Update
CHANGELOG.mdwith changes - Commit and push:
git add pyproject.toml CHANGELOG.md git commit -m "Bump version to 0.1.1" git push
- Create and push tag:
git tag v0.1.1 git push origin v0.1.1
- Automatic process:
- โ CI tests run on all Python versions
- โ Package is built and validated
- โ Published to PyPI automatically
- โ GitHub Release is created
See PUBLISHING.md for detailed instructions.
๐ License
๐ Changelog
See CHANGELOG.md for version history and release notes.
๐ Acknowledgments
Built with:
- FastAPI - Modern, fast web framework
- Typer - CLI framework
- Rich - Beautiful terminal output
- Questionary - Interactive prompts
๐ง Support
For issues, questions, or suggestions, please open an issue on GitHub.
Made with โค๏ธ for the FastAPI community
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 ningfastforge-0.1.3.tar.gz.
File metadata
- Download URL: ningfastforge-0.1.3.tar.gz
- Upload date:
- Size: 85.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
675a7745353a434ecbcae24ad83e6c6cab5ca072922214eff2fca1ae83ec0cbe
|
|
| MD5 |
b416832dcbad4480108855476efbea7b
|
|
| BLAKE2b-256 |
1ebaddc9f331c9349eef37bfb905580334f40720dfc7d6689a34a97e2d0a8f55
|
Provenance
The following attestation bundles were made for ningfastforge-0.1.3.tar.gz:
Publisher:
publish.yml on ning3739/forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ningfastforge-0.1.3.tar.gz -
Subject digest:
675a7745353a434ecbcae24ad83e6c6cab5ca072922214eff2fca1ae83ec0cbe - Sigstore transparency entry: 799191287
- Sigstore integration time:
-
Permalink:
ning3739/forge@5da2aa6105c0d0ea8bacb8e3171ea6ca1d276617 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ning3739
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5da2aa6105c0d0ea8bacb8e3171ea6ca1d276617 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ningfastforge-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ningfastforge-0.1.3-py3-none-any.whl
- Upload date:
- Size: 105.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c74d050de62d68f5cb64664555ecab0cce7304defc25d6dedaab10d0f0b5f9a
|
|
| MD5 |
d7be89a9b4d8c46c4482619233efb52f
|
|
| BLAKE2b-256 |
5c2480929caa2c10e7afc1649ad2fdc54c8883c27e4458434d32262ba97bd72f
|
Provenance
The following attestation bundles were made for ningfastforge-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on ning3739/forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ningfastforge-0.1.3-py3-none-any.whl -
Subject digest:
4c74d050de62d68f5cb64664555ecab0cce7304defc25d6dedaab10d0f0b5f9a - Sigstore transparency entry: 799191290
- Sigstore integration time:
-
Permalink:
ning3739/forge@5da2aa6105c0d0ea8bacb8e3171ea6ca1d276617 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ning3739
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5da2aa6105c0d0ea8bacb8e3171ea6ca1d276617 -
Trigger Event:
push
-
Statement type: