Skip to main content

A modular scaffolding system for FastAPI backends

Project description

๐Ÿงฉ FastAPI Blocks Registry

A modular scaffolding system for FastAPI backends, inspired by shadcn-vue. Add production-ready modules (like auth, users, billing) to your FastAPI project with a single CLI command.

๐ŸŽฏ Project Goal

FastAPI Blocks Registry allows you to quickly add complete, production-ready modules to your FastAPI projects. Each module includes models, schemas, routers, services, and all necessary configurations - just copy and customize.

Unlike traditional packages, modules are copied directly into your project, giving you full control to modify and adapt them to your needs.

โœจ Features

  • ๐Ÿ“ฆ Copy, not install - Modules are copied into your project for full customization
  • ๐Ÿ”ง Auto-configuration - Automatically updates main.py, requirements.txt, and .env
  • ๐ŸŽจ Production-ready - Each module follows best practices and includes proper error handling
  • ๐Ÿ”’ Type-safe - Full type hints and Pydantic validation
  • ๐Ÿ“š Well-documented - Clear code structure with docstrings
  • ๐Ÿš€ Quick start - Get authentication, user management, and more in seconds

๐Ÿš€ Quick Start

Installation

# Install from source (for development)
pip install -e .

# Or install from PyPI (when published)
pip install fastapi-blocks-registry

Usage

# List available modules
fastapi-registry list

# Show module details
fastapi-registry info auth

# Add a module to your project
fastapi-registry add auth

# Remove a module
fastapi-registry remove auth

What Gets Installed

When you add a module, the CLI automatically:

  • โœ… Copies module files to app/modules/<module>/
  • โœ… Updates main.py to register the router
  • โœ… Adds dependencies to requirements.txt
  • โœ… Adds environment variables to .env

๐Ÿ“ฆ Available Modules

Auth Module

Complete JWT-based authentication system with:

  • User registration with password strength validation
  • Login with JWT access and refresh tokens
  • Password reset flow
  • Password change for authenticated users
  • Token blacklisting support

Endpoints:

  • POST /api/v1/auth/register - Register new user
  • POST /api/v1/auth/login - Login user
  • POST /api/v1/auth/refresh - Refresh access token
  • POST /api/v1/auth/forgot-password - Request password reset
  • POST /api/v1/auth/reset-password - Reset password with token
  • POST /api/v1/auth/change-password - Change password (authenticated)
  • GET /api/v1/auth/me - Get current user info

Technologies:

  • PyJWT for token management
  • Passlib + bcrypt for password hashing
  • Pydantic for validation
  • In-memory user store (easily replaceable with database)

๐Ÿ—๏ธ Project Structure

fastapi-blocks-registry/
โ”œโ”€โ”€ fastapi_registry/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ cli.py                  # CLI implementation
โ”‚   โ”œโ”€โ”€ registry.json           # Module registry
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ file_utils.py       # File operations
โ”‚   โ”‚   โ”œโ”€โ”€ installer.py        # Module installer
โ”‚   โ”‚   โ””โ”€โ”€ registry_manager.py # Registry management
โ”‚   โ””โ”€โ”€ modules/
โ”‚       โ””โ”€โ”€ auth/               # Auth module
โ”‚           โ”œโ”€โ”€ __init__.py
โ”‚           โ”œโ”€โ”€ models.py       # User model & store
โ”‚           โ”œโ”€โ”€ schemas.py      # Pydantic schemas
โ”‚           โ”œโ”€โ”€ router.py       # FastAPI routes
โ”‚           โ”œโ”€โ”€ service.py      # Business logic
โ”‚           โ”œโ”€โ”€ dependencies.py # FastAPI dependencies
โ”‚           โ”œโ”€โ”€ auth_utils.py   # JWT & password utils
โ”‚           โ””โ”€โ”€ exceptions.py   # Custom exceptions
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ docs/
โ”œโ”€โ”€ CLAUDE.md                   # Development guidelines
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ pyproject.toml

๐Ÿง  Module Structure

Each module follows a consistent structure:

  • models.py - Data models (Pydantic or SQLAlchemy)
  • schemas.py - Request/response schemas with validation
  • router.py - FastAPI route definitions
  • service.py - Business logic layer
  • dependencies.py - FastAPI dependency injection
  • exceptions.py - Module-specific exceptions
  • __init__.py - Module initialization

๐Ÿ’ป Example Usage

1. Add the auth module to your project

cd your-fastapi-project
fastapi-registry add auth

2. Install dependencies

pip install -r requirements.txt

3. Configure environment variables

Edit your .env file:

SECRET_KEY=your-secret-key-min-32-characters
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRES_MINUTES=30
REFRESH_TOKEN_EXPIRES_DAYS=7

4. Start your server

uvicorn main:app --reload

5. Test the endpoints

# Register a new user
curl -X POST "http://localhost:8000/api/v1/auth/register" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "Test123!@#",
    "name": "Test User"
  }'

# Login
curl -X POST "http://localhost:8000/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "Test123!@#"
  }'

๐Ÿ”ง CLI Commands

fastapi-registry list

Display all available modules from the registry

fastapi-registry info <module>

Show detailed information about a specific module

fastapi-registry add <module>

Add a module to your project:

  • Copies module files to app/modules/<module>/
  • Updates main.py with router registration
  • Adds dependencies to requirements.txt
  • Adds environment variables to .env

fastapi-registry remove <module>

Remove a module from your project (manual cleanup required for dependencies)

fastapi-registry version

Show version information

๐Ÿ› ๏ธ Development

Setup

# Clone the repository
git clone https://github.com/yourusername/fastapi-blocks-registry
cd fastapi-blocks-registry

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

# Install in editable mode
pip install -e .

Running Tests

pytest

Code Quality

# Format code
black .

# Lint code
ruff check .

# Type checking
mypy fastapi_registry

๐Ÿ”ฎ Roadmap

  • CLI implementation with Typer
  • Auth module with JWT
  • Auto-configuration system
  • Users module with RBAC
  • Database integration (SQLAlchemy)
  • Alembic migrations support
  • Email module
  • Billing/subscription module
  • Projects/workspaces module
  • Remote registry support (GitHub)
  • PyPI publication
  • Module templates generator
  • Test generation for modules

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

MIT

๐Ÿ™ Inspiration

This project is inspired by:

  • shadcn-vue - Copy, don't install philosophy
  • FastAPI - Modern Python web framework
  • Typer - CLI framework by the creator of FastAPI

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

fastapi_blocks_registry-0.1.0.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

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

fastapi_blocks_registry-0.1.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fastapi_blocks_registry-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4292328a8aaffcb847eeb9465e4ede96fc968ae80e2e0c4c8a6cc35066e2ebc9
MD5 1fc1b1e04f933002b48fc2e8fd81b7d2
BLAKE2b-256 235df0741e52b6dcbb5a60795891c04eb85bc19a5734cc6f483fd518b70dfc7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_blocks_registry-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48e87d92d84a6479691b79ae01c62b2f7faf6ef77ff48f8acd9cb083827815e8
MD5 0cddfcad33ef1a745dc40fc792f1eb83
BLAKE2b-256 80e72b32c660267beca3d5b5cd3bbe8e7ac2467e76bc5cdf22d08a62b259bf3b

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