Skip to main content

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:

๐Ÿ—๏ธ Architecture

Forge follows a "Configuration-First" design principle:

  1. Init Command collects user preferences interactively
  2. Configuration File (.forge/config.json) is saved first
  3. 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 fixtures
  • tests/test_main.py - Tests for main API endpoints (health check, docs)
  • tests/api/test_auth.py - Authentication endpoint tests
  • tests/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:

๐Ÿ“ง Support

For issues, questions, or suggestions, please open an issue on GitHub.


Made with โค๏ธ for the FastAPI community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ningfastforge-0.1.0.tar.gz (69.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ningfastforge-0.1.0-py3-none-any.whl (94.3 kB view details)

Uploaded Python 3

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

Hashes for ningfastforge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 32aff13bce2f4e0e567191349edf06e6f6ab898426cb6bf36b5eec08b9f78710
MD5 7204280a2c9a7d9a38bda664a53ad782
BLAKE2b-256 773582ff47d9e7b8db6b9cbc49078bccc444ec5c09d042d2c205d6751e696685

See more details on using hashes here.

Provenance

The following attestation bundles were made for ningfastforge-0.1.0.tar.gz:

Publisher: publish.yml on ning3739/forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for ningfastforge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c6ab64bed5378d643c611412d95f791acafbbc7d0a2648d752f6b78fa80255e
MD5 6a51e6c9bf841864c99ddc2edeb25810
BLAKE2b-256 840a7fb8b3fc57d7067847d853efff50f2bf0d4ce6adeebf2a0e8d9d17bb919e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ningfastforge-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ning3739/forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page