Skip to main content

Production-ready CLI to scaffold FastAPI and Flask projects with security, reliability, and 10+ boilerplate templates.

Project description

๐Ÿš€ BoilerPy

Lightning-fast FastAPI & Flask project scaffolding CLI

PyPI version Python Version License: MIT Downloads Code style: black

Installation โ€ข Quick Start โ€ข Templates โ€ข Documentation


๐ŸŽฏ Why BoilerPy?

Stop wasting time setting up the same project structure over and over. BoilerPy generates production-ready FastAPI and Flask projects in seconds with:

  • โœ… 10 Professional Templates - 5 FastAPI + 5 Flask templates
  • ๐Ÿ”’ Security First - JWT auth, password hashing, CORS, input validation
  • โšก Lightning Fast - Generate projects in < 5 seconds
  • ๐ŸŽจ Clean Architecture - Industry best practices built-in
  • ๐Ÿ›ก๏ธ Production Ready - Error handling, logging, rollback on failure
  • ๐Ÿ”ง Zero Configuration - Works out of the box
  • ๐Ÿ Python 3.9+ - Modern Python support
  • ๐Ÿณ Docker Ready - Docker Compose for databases

๐Ÿ“ฆ Installation

Using pipx (Recommended)

pipx install boilerpy

Using pip

pip install boilerpy

From source

git clone https://github.com/Faizgeeky/boilerpy.git
cd boilerpy
pip install -e .

๐Ÿš€ Quick Start

1. List available templates

bpy list

2. Create a new project

bpy init fastapi

3. Follow the interactive prompts

  • Select your template (1-5)
  • Enter project name
  • Done! Your project is ready ๐ŸŽ‰

Example

$ bpy init fastapi

============================================================
  Available FASTAPI Templates
============================================================

1. API Only
   Basic FastAPI project with routers and clean architecture

2. Authentication
   FastAPI with JWT authentication, user management

3. SQL (SQLAlchemy + PostgreSQL)
   FastAPI with SQLAlchemy, PostgreSQL, and Alembic migrations

Select template (1-5): 2
Enter project name: my-awesome-api

๐Ÿš€ Creating Authentication project: my-awesome-api
โœ… Project created successfully!

๐Ÿ“š Next steps:
  cd my-awesome-api
  python -m venv venv
  source venv/bin/activate
  pip install -r requirements.txt
  uvicorn app.main:app --reload

๐Ÿ“– API Docs: http://localhost:8000/docs

๐Ÿ“š Templates

๐Ÿ”ท FastAPI Templates

1. API Only - Clean REST API

Perfect for microservices and REST APIs

app/
โ”œโ”€โ”€ main.py              # FastAPI application
โ”œโ”€โ”€ api/v1/
โ”‚   โ”œโ”€โ”€ router.py        # API router
โ”‚   โ””โ”€โ”€ endpoints/       # API endpoints
โ”œโ”€โ”€ core/
โ”‚   โ””โ”€โ”€ config.py        # Configuration
โ””โ”€โ”€ schemas/             # Pydantic models

2. Authentication - JWT Auth System

Production-ready authentication with JWT tokens

app/
โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ api/v1/endpoints/
โ”‚   โ”œโ”€โ”€ auth.py          # Login, register
โ”‚   โ””โ”€โ”€ users.py         # User management
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ security.py      # JWT utilities
โ”‚   โ””โ”€โ”€ dependencies.py  # Auth dependencies
โ””โ”€โ”€ schemas/
    โ”œโ”€โ”€ user.py
    โ””โ”€โ”€ token.py

3. SQL - SQLAlchemy + PostgreSQL

Full database setup with migrations

app/
โ”œโ”€โ”€ models/              # SQLAlchemy models
โ”œโ”€โ”€ crud/                # CRUD operations
โ”œโ”€โ”€ core/
โ”‚   โ””โ”€โ”€ database.py      # Database config
โ”œโ”€โ”€ alembic/             # Migrations
โ””โ”€โ”€ docker-compose.yml   # PostgreSQL setup

4. MongoDB - Motor Async Driver

MongoDB integration with async support

app/
โ”œโ”€โ”€ core/
โ”‚   โ””โ”€โ”€ database.py      # MongoDB connection
โ”œโ”€โ”€ models/              # MongoDB models
โ””โ”€โ”€ crud/                # Database operations

5. CRM - Complete Application

Full CRM with users, customers, products, orders

app/
โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ user.py
โ”‚   โ”œโ”€โ”€ customer.py
โ”‚   โ”œโ”€โ”€ product.py
โ”‚   โ””โ”€โ”€ order.py
โ”œโ”€โ”€ api/v1/endpoints/
โ”‚   โ”œโ”€โ”€ auth.py
โ”‚   โ”œโ”€โ”€ customers.py
โ”‚   โ””โ”€โ”€ orders.py
โ””โ”€โ”€ core/
    โ”œโ”€โ”€ database.py
    โ””โ”€โ”€ security.py

๐Ÿ”ถ Flask Templates

1. API Only - Clean REST API

Blueprint-based Flask API with CORS and clean architecture

app/
โ”œโ”€โ”€ api/v1/
โ”‚   โ”œโ”€โ”€ endpoints/       # API endpoints
โ”‚   โ”‚   โ””โ”€โ”€ items.py     # CRUD operations
โ”‚   โ””โ”€โ”€ __init__.py      # Blueprint registration
โ”œโ”€โ”€ core/
โ”‚   โ””โ”€โ”€ config.py        # Configuration
โ””โ”€โ”€ schemas/             # Data validation

2. Authentication - JWT Auth System

Flask with JWT authentication and user management

app/
โ”œโ”€โ”€ api/v1/endpoints/
โ”‚   โ”œโ”€โ”€ auth.py          # Register, login
โ”‚   โ””โ”€โ”€ users.py         # User management
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ security.py      # JWT + password hashing
โ”‚   โ””โ”€โ”€ config.py        # JWT settings
โ””โ”€โ”€ models/              # User models

3. SQL - SQLAlchemy + PostgreSQL

Flask with SQLAlchemy 2.0 and PostgreSQL

app/
โ”œโ”€โ”€ models/              # SQLAlchemy models
โ”œโ”€โ”€ crud/                # CRUD operations
โ”œโ”€โ”€ schemas/             # Validation schemas
โ”œโ”€โ”€ core/
โ”‚   โ””โ”€โ”€ database.py      # SQLAlchemy setup
โ””โ”€โ”€ docker-compose.yml   # PostgreSQL

4. MongoDB - PyMongo Integration

Flask with PyMongo and advanced querying

app/
โ”œโ”€โ”€ core/
โ”‚   โ””โ”€โ”€ database.py      # MongoDB connection
โ”œโ”€โ”€ models/              # MongoDB models
โ”œโ”€โ”€ api/v1/endpoints/
โ”‚   โ””โ”€โ”€ items.py         # CRUD with filtering
โ””โ”€โ”€ docker-compose.yml   # MongoDB

5. Full-Stack - Complete Web App

Flask with Jinja2 templates and authentication

app/
โ”œโ”€โ”€ routes/
โ”‚   โ”œโ”€โ”€ main.py          # Main routes
โ”‚   โ””โ”€โ”€ auth.py          # Auth routes
โ”œโ”€โ”€ templates/           # Jinja2 templates
โ”‚   โ”œโ”€โ”€ base.html
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ””โ”€โ”€ auth/            # Login, register
โ”œโ”€โ”€ static/
โ”‚   โ”œโ”€โ”€ css/style.css    # Modern responsive CSS
โ”‚   โ””โ”€โ”€ js/main.js       # Form validation
โ”œโ”€โ”€ models/              # User models
โ””โ”€โ”€ forms/               # WTForms

## ๐ŸŽจ Features

### Core Features
- ๐Ÿ—๏ธ **Production-Ready** - All templates follow industry best practices
- ๐Ÿ“ **Clean Structure** - Organized, scalable architecture
- โšก **Async Support** - FastAPI with async/await, Motor for MongoDB
- ๐Ÿณ **Docker Included** - docker-compose.yml for databases
- ๐Ÿ“ **Type Hints** - Full typing support with Pydantic
- ๐Ÿงช **Testing Ready** - Structured for easy testing
- ๐Ÿ“– **Documentation** - Comprehensive README in each project

### Security Features
- ๐Ÿ” **JWT Authentication** - Access & refresh tokens
- ๐Ÿ”’ **Password Hashing** - PBKDF2-SHA256 with Werkzeug/Passlib
- ๐Ÿ›ก๏ธ **Input Validation** - Server-side validation with detailed errors
- ๐ŸŒ **CORS Configuration** - Configurable allowed origins
- ๐Ÿ”‘ **CSRF Protection** - Built into fullstack templates
- ๐Ÿšซ **SQL Injection Prevention** - Parameterized queries/ORM
- ๐Ÿ“‹ **Security Headers** - X-Frame-Options, X-Content-Type-Options

### Reliability Features
- ๐Ÿ“Š **Comprehensive Logging** - Structured logging throughout
- ๐Ÿ”„ **Rollback on Failure** - Automatic cleanup if generation fails
- โœ… **Input Validation** - Project name validation, path security
- ๐Ÿ›ก๏ธ **Directory Traversal Protection** - Secure file operations
- โš ๏ธ **Error Handling** - Comprehensive error messages
- ๐Ÿ” **Verbose Mode** - `--verbose` flag for debugging

### Database Support
- ๐Ÿ—„๏ธ **PostgreSQL** - SQLAlchemy with Alembic migrations
- ๐Ÿƒ **MongoDB** - Motor (async) & PyMongo support
- ๐Ÿ”„ **Database Migrations** - Alembic configured
- ๐Ÿณ **Docker Compose** - One-command database setup
- ๐Ÿ“Š **Connection Pooling** - Optimized database connections

## ๐Ÿ“– Documentation

### After Creating a Project

```bash
cd my-awesome-api

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run the application
uvicorn app.main:app --reload

FastAPI Projects:

uvicorn app.main:app --reload

Visit http://localhost:8000/docs for interactive API documentation.

Flask Projects:

flask run

Visit http://localhost:5000 for your application.

Project Structure

Every generated project includes:

  • โœ… requirements.txt - All dependencies
  • โœ… .env.example - Environment variables template
  • โœ… .gitignore - Comprehensive Python gitignore (auto-generated)
  • โœ… README.md - Complete setup guide with examples
  • โœ… docker-compose.yml - Database setup (SQL/MongoDB templates)
  • โœ… Secure file permissions - Proper file modes set automatically

CLI Options

# Basic usage
bpy init fastapi              # Interactive template selection
bpy init flask my-project     # Specify project name upfront
bpy list                      # List all available templates

# With verbose logging
bpy --verbose init fastapi    # See detailed generation logs

# Get help
bpy --help                    # Show all commands
bpy init --help               # Show init command help

๐Ÿšฆ Version History

v1.0.1 (Latest)

  • โœ… Added 5 Flask templates (API, Auth, SQL, MongoDB, Full-Stack)
  • โœ… Enhanced security: input validation, directory traversal protection
  • โœ… Added logging and error handling with rollback
  • โœ… Auto-generated .gitignore files
  • โœ… Improved CLI with verbose mode
  • โœ… Added MongoDB and CRM templates for FastAPI
  • โœ… Enhanced documentation

v0.1.0

  • Initial release with 3 FastAPI templates

๐Ÿ” Security Best Practices

All templates include security features out of the box:

Authentication Templates

  • Password hashing with PBKDF2-SHA256
  • JWT tokens with configurable expiration
  • Secure secret key management via environment variables
  • Protected routes with authentication middleware

API Security

  • CORS configuration with allowed origins
  • Input validation with Pydantic (FastAPI) or WTForms (Flask)
  • SQL injection prevention via ORM
  • Security headers (X-Frame-Options, X-Content-Type-Options)

File Security

  • Directory traversal attack prevention
  • Secure file permissions (644 for files, 755 for directories)
  • Validation of project names and paths
  • Safe template variable replacement

Production Checklist

Before deploying to production:

  1. โœ… Change SECRET_KEY in .env (min 32 characters)
  2. โœ… Set DEBUG=False
  3. โœ… Configure production database URLs
  4. โœ… Set up HTTPS/SSL certificates
  5. โœ… Configure allowed CORS origins
  6. โœ… Set up monitoring and logging
  7. โœ… Use environment-specific configs

๐Ÿ› ๏ธ Development

Requirements

  • Python 3.9+
  • pip or pipx

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

Building from Source

git clone https://github.com/Faizgeeky/boilerpy.git
cd boilerpy
python -m build

๐Ÿ“ License

MIT License - see LICENSE for details.

๐Ÿค Support

๐Ÿ™ Acknowledgments

Built with โค๏ธ by Faiz

Inspired by:

  • create-react-app
  • vue-cli
  • cookiecutter

โฌ† back to top

Made with โค๏ธ for the Python 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

boilerpy-1.0.1.tar.gz (85.7 kB view details)

Uploaded Source

Built Distribution

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

boilerpy-1.0.1-py3-none-any.whl (144.8 kB view details)

Uploaded Python 3

File details

Details for the file boilerpy-1.0.1.tar.gz.

File metadata

  • Download URL: boilerpy-1.0.1.tar.gz
  • Upload date:
  • Size: 85.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for boilerpy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 9f6785a33aeb4fb81e2e275fff106059ab02888e79dddd2a9bd5f281b2474889
MD5 9c23ea1788acd3745f36c1c16d7e7c31
BLAKE2b-256 3088b88b5202c3183bcb19645e6b287c2d54312e53265fcee5e99960e1309822

See more details on using hashes here.

Provenance

The following attestation bundles were made for boilerpy-1.0.1.tar.gz:

Publisher: publish.yml on Faizgeeky/boilerpy

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

File details

Details for the file boilerpy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: boilerpy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 144.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for boilerpy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b7512bf2c7d1e35c968067669f34c32f58d9dd46e000985cfadeae3535cc56ec
MD5 93b9e2eec16446788bd507ac74c1aed6
BLAKE2b-256 a111498c1807f6f4756ef184e9b09db357e403b99ee015864ba08ed0c51d8449

See more details on using hashes here.

Provenance

The following attestation bundles were made for boilerpy-1.0.1-py3-none-any.whl:

Publisher: publish.yml on Faizgeeky/boilerpy

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