Skip to main content

Modern Python scaffolding framework inspired by NestJS CLI - scaffold FastAPI projects with Docker, Alembic, and production-ready structure

Project description

BoringPy

PyPI version Python 3.13+ License: MIT

Modern Python scaffolding framework inspired by NestJS CLI - scaffold production-ready FastAPI projects in seconds.

โœจ Features

  • ๐Ÿš€ Instant FastAPI Projects - Generate complete APIs with Docker, Alembic, and tests
  • ๐Ÿ—„๏ธ Database Ready - PostgreSQL, MySQL, or SQLite with SQLModel ORM
  • ๐Ÿณ Docker First - Full docker-compose setup with hot reload
  • ๐Ÿ“ฆ UV Powered - Lightning-fast package management with uv
  • ๐ŸŽฏ Type Safe - Full type annotations and strict type checking
  • ๐Ÿ—๏ธ Monorepo Ready - Workspace support for multiple APIs and shared libraries
  • ๐Ÿงช Test Infrastructure - pytest with coverage reporting
  • ๐Ÿ“ Professional Makefile - 30+ commands for development workflow

๐Ÿ“ฆ Installation

Requirements

  • Python 3.13+
  • uv package manager

Install uv if you haven't already:

curl -LsSf https://astral.sh/uv/install.sh | sh

Install BoringPy

pip install boringpy

Or with uv:

uv tool install boringpy

๐Ÿš€ Quick Start

1. Create a Workspace

boringpy init my-workspace
cd my-workspace

This creates:

my-workspace/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ apps/       # Generated APIs
โ”‚   โ”œโ”€โ”€ libs/       # Shared libraries
โ”‚   โ””โ”€โ”€ scripts/    # Utility scripts
โ”œโ”€โ”€ boringpy.json   # Workspace config
โ”œโ”€โ”€ pyproject.toml  # UV workspace
โ””โ”€โ”€ README.md

2. Generate Your First API

boringpy generate api my_blog --port 8000 --db postgresql

This creates a complete FastAPI application with:

  • โœ… FastAPI with async/await
  • โœ… SQLModel ORM + Alembic migrations
  • โœ… Docker & docker-compose
  • โœ… Environment-based configuration
  • โœ… Structured logging
  • โœ… pytest test suite
  • โœ… Professional Makefile
  • โœ… Health check endpoints
  • โœ… API documentation (Swagger/ReDoc)

3. Run Your API

cd src/apps/my_blog

# Copy environment file
cp .env.example .env

# Start with Docker (recommended)
make docker-up

# Run migrations
make db-upgrade

# View logs
make docker-logs

# Stop containers
make docker-down

Your API is now running at http://localhost:8000!

๐Ÿ“– Usage

Commands

# Show version
boringpy --version

# Show help
boringpy --help

# Initialize workspace
boringpy init <workspace-name>

# Generate FastAPI application
boringpy generate api <name> [OPTIONS]
  --port INTEGER       API port (default: 8000)
  --db TEXT           Database type: postgresql, mysql, sqlite (default: postgresql)

# Coming soon
boringpy generate lib <name>      # Generate shared library
boringpy generate model <name>    # Generate SQLModel

Database Options

PostgreSQL (default):

boringpy generate api my_api --db postgresql

MySQL:

boringpy generate api my_api --db mysql

SQLite (no container needed):

boringpy generate api my_api --db sqlite

Generated API Makefile Commands

Every generated API includes a comprehensive Makefile:

# Development
make dev                    # Run API locally
make dev-reload             # Run with auto-reload
make test                   # Run tests
make test-cov               # Run tests with coverage

# Code Quality
make format                 # Format code with ruff
make lint                   # Lint code
make typecheck              # Type check with ty
make check                  # Run all checks

# Docker
make docker-build           # Build Docker image
make docker-up              # Start containers
make docker-down            # Stop containers
make docker-logs            # View logs
make docker-shell           # Shell into container

# Database
make db-upgrade             # Run migrations
make db-downgrade           # Rollback migration
make db-create-migration MSG="description"  # Create migration
make db-history             # View migration history
make db-shell               # Database shell

๐Ÿ—‚๏ธ Project Structure

Generated APIs follow this structure:

my_api/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ config.py       # Settings & configuration
โ”‚   โ”‚   โ”œโ”€โ”€ database.py     # Database connection
โ”‚   โ”‚   โ”œโ”€โ”€ logger.py       # Logging setup
โ”‚   โ”‚   โ””โ”€โ”€ lifespan.py     # App lifecycle
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ base.py         # Base SQLModel
โ”‚   โ”‚   โ””โ”€โ”€ example.py      # Example model
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”œโ”€โ”€ deps.py         # Dependencies
โ”‚   โ”‚   โ””โ”€โ”€ v1/
โ”‚   โ”‚       โ””โ”€โ”€ endpoints/
โ”‚   โ”‚           โ””โ”€โ”€ health.py
โ”‚   โ”œโ”€โ”€ services/           # Business logic
โ”‚   โ””โ”€โ”€ main.py             # FastAPI app
โ”œโ”€โ”€ migrations/             # Alembic migrations
โ”œโ”€โ”€ tests/                  # pytest tests
โ”œโ”€โ”€ docker-compose.yml      # Multi-container setup
โ”œโ”€โ”€ Dockerfile              # Multi-stage build
โ”œโ”€โ”€ Makefile                # Development commands
โ”œโ”€โ”€ .env.example            # Environment template
โ”œโ”€โ”€ alembic.ini             # Migration config
โ””โ”€โ”€ README.md               # API documentation

๐Ÿ”ง Configuration

Workspace Config (boringpy.json)

{
  "version": "0.1.0",
  "type": "workspace",
  "defaults": {
    "api": {
      "db_type": "postgresql",
      "port": 8000
    }
  },
  "workspace_members": [
    "src/apps/my_api"
  ]
}

API Environment (.env)

# Application
APP_NAME=my_api
APP_VERSION=0.1.0
DEBUG=true

# Server
HOST=0.0.0.0
PORT=8000

# Database
DATABASE_URL=postgresql://user:pass@localhost:5432/db
DB_ECHO=false
DB_POOL_SIZE=5
DB_MAX_OVERFLOW=10

# Logging
LOG_LEVEL=INFO

๐ŸŽฏ Use Cases

Single API Project

boringpy init my-project
cd my-project
boringpy generate api backend --port 8000

Microservices Monorepo

boringpy init my-company
cd my-company
boringpy generate api users_service --port 8001
boringpy generate api orders_service --port 8002
boringpy generate api payments_service --port 8003

API + Shared Libraries

boringpy init my-platform
cd my-platform
boringpy generate api web_api --port 8000
boringpy generate lib auth_utils     # Coming soon
boringpy generate lib database_models # Coming soon

๐Ÿ› ๏ธ Technology Stack

Generated projects use:

๐Ÿ“š Examples

Minimal Example

# Create and run an API in 4 commands
boringpy init blog
cd blog
boringpy generate api api --db sqlite
cd src/apps/api && make dev

Production Example

# Full production setup with PostgreSQL
boringpy init production-app
cd production-app
boringpy generate api api --port 8000 --db postgresql

cd src/apps/api
cp .env.example .env
# Edit .env with production values

make docker-build
make docker-up
make db-upgrade

๐Ÿค” Why BoringPy?

BoringPy takes the "boring" out of project setup. No more:

  • โŒ Manual FastAPI boilerplate
  • โŒ Copying docker-compose files
  • โŒ Setting up Alembic from scratch
  • โŒ Writing Makefiles
  • โŒ Configuring logging

Just run boringpy generate api and start building features immediately.

Inspired by NestJS CLI - but for Python and FastAPI.

๐Ÿ—บ๏ธ Roadmap

  • Workspace initialization
  • FastAPI API generation
  • Multi-database support
  • Docker setup
  • Alembic migrations
  • Library generation
  • SQLModel generator
  • CRUD endpoint generator
  • Authentication templates
  • AWS/GCP deployment helpers
  • Plugin system

๐Ÿค Contributing

Contributions welcome! Please check out our contributing guidelines.

๐Ÿ“„ License

MIT License - see LICENSE for details.

๐Ÿ™ Acknowledgments


Built with โค๏ธ for the Python community

โญ Star us on GitHub | ๐Ÿ“ฆ PyPI Package | ๐Ÿ“– Documentation

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

boringpy-0.1.2.tar.gz (47.3 kB view details)

Uploaded Source

Built Distribution

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

boringpy-0.1.2-py3-none-any.whl (46.1 kB view details)

Uploaded Python 3

File details

Details for the file boringpy-0.1.2.tar.gz.

File metadata

  • Download URL: boringpy-0.1.2.tar.gz
  • Upload date:
  • Size: 47.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for boringpy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d1c77706ede5be5402b24fc67fc646e017769b3122e0c4cb759513adc2531459
MD5 de8b2367a6c29ba38d7d2fc86a032954
BLAKE2b-256 3574377510e4444b354a6a3b106b353d4b2073bfcc21a727060beed650d93c3f

See more details on using hashes here.

File details

Details for the file boringpy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: boringpy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 46.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for boringpy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 029590d1e7b307a319a015e02c470212195a9bf1ca4a0de812822eb01e90ee5e
MD5 ef33e119f348cad2f86beb2aef0161f7
BLAKE2b-256 1d418707220ef41e91237e8151fd60bf967c487d45ec01cd08dd6876f3024c19

See more details on using hashes here.

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