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.0.tar.gz (95.8 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.0-py3-none-any.whl (45.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: boringpy-0.1.0.tar.gz
  • Upload date:
  • Size: 95.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for boringpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 711ff0597f175e5d9f6f54d11e57272719efd679110ae787710d0a9a92916f86
MD5 d7cccebf730d30d1c7c973ceba7bc507
BLAKE2b-256 842da7255f1e1185d26ff194c6f4a2f3fe2453c9bc86d9dc9451e77ab4c0264b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: boringpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 45.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for boringpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 34de0c583f74d84e7d80a99fb9aff757e1dd448ec1187051cef36cb723cb6bf6
MD5 43f451dbbfa0d8449d99d8d4c91ede97
BLAKE2b-256 7cfc6460cbd0070674512defa7d1d2ddab2c43b466d43c395f70323fa65ea7db

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