A modern FastAPI project scaffolding CLI tool
Project description
๐ฅ Forge
A modern, interactive FastAPI project scaffolding CLI tool
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:
- ๐ API: http://localhost:8000
- ๐ Docs: http://localhost:8000/docs
- ๐ ReDoc: http://localhost:8000/redoc
๐๏ธ Architecture
Forge follows a "Configuration-First" design principle:
- Init Command collects user preferences interactively
- Configuration File (
.forge/config.json) is saved first - ProjectGenerator reads the config and generates code accordingly
This separation ensures:
- โ Configuration persistence and traceability
- โ Clear separation of concerns
- โ Easy project regeneration and updates
- โ Configuration sharing and templates
๐ฏ 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)
- 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)
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
โ โ โ โโโ settings.py
โ โ โ โโโ modules/ # Config modules (app, database, jwt, etc.)
โ โ โโโ database/ # Database connection
โ โ โ โโโ connection.py
โ โ โ โโโ postgresql.py / mysql.py
โ โ โโโ security.py # Security utilities
โ โโโ models/ # Database models
โ โโโ schemas/ # Pydantic schemas
โ โโโ crud/ # CRUD operations
โ โโโ services/ # Business logic
โ โโโ routers/ # API routes
โ โ โโโ v1/ # API version 1
โ โโโ utils/ # Utility functions
โโโ 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
โโโ alembic/ # Database migrations (if enabled)
โโโ docker-compose.yml # Docker Compose configuration (if enabled)
โโโ Dockerfile # Docker configuration (if enabled)
โโโ pyproject.toml # Project dependencies
โโโ .env.example # Environment variables template
โโโ 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
โ โโโ config_reader.py # Configuration file reader
โ โโโ project_generator.py # Project generator
โ โโโ generators/ # Code generators
โ โ โโโ structure.py # Project structure generator
โ โ โโโ orchestrator.py # 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
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
# Clone the repository
git clone https://github.com/yourusername/forge.git
cd forge
# Install dependencies
uv sync
# Run tests (if available)
pytest
# Test build
./scripts/test_build.sh
Publishing
See PUBLISHING.md for detailed instructions on publishing to PyPI.
๐ License
MIT License
๐ 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.0.tar.gz.
File metadata
- Download URL: ningfastforge-0.1.0.tar.gz
- Upload date:
- Size: 69.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32aff13bce2f4e0e567191349edf06e6f6ab898426cb6bf36b5eec08b9f78710
|
|
| MD5 |
7204280a2c9a7d9a38bda664a53ad782
|
|
| BLAKE2b-256 |
773582ff47d9e7b8db6b9cbc49078bccc444ec5c09d042d2c205d6751e696685
|
Provenance
The following attestation bundles were made for ningfastforge-0.1.0.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.0.tar.gz -
Subject digest:
32aff13bce2f4e0e567191349edf06e6f6ab898426cb6bf36b5eec08b9f78710 - Sigstore transparency entry: 792063524
- Sigstore integration time:
-
Permalink:
ning3739/forge@54669342df97c775137deff80c8c099ef5fb9b4a -
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@54669342df97c775137deff80c8c099ef5fb9b4a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ningfastforge-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ningfastforge-0.1.0-py3-none-any.whl
- Upload date:
- Size: 94.3 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 |
4c6ab64bed5378d643c611412d95f791acafbbc7d0a2648d752f6b78fa80255e
|
|
| MD5 |
6a51e6c9bf841864c99ddc2edeb25810
|
|
| BLAKE2b-256 |
840a7fb8b3fc57d7067847d853efff50f2bf0d4ce6adeebf2a0e8d9d17bb919e
|
Provenance
The following attestation bundles were made for ningfastforge-0.1.0-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.0-py3-none-any.whl -
Subject digest:
4c6ab64bed5378d643c611412d95f791acafbbc7d0a2648d752f6b78fa80255e - Sigstore transparency entry: 792063612
- Sigstore integration time:
-
Permalink:
ning3739/forge@54669342df97c775137deff80c8c099ef5fb9b4a -
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@54669342df97c775137deff80c8c099ef5fb9b4a -
Trigger Event:
workflow_dispatch
-
Statement type: