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
# Initialize a new FastAPI project
fastapi-registry init
# 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.pyto 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 userPOST /api/v1/auth/login- Login userPOST /api/v1/auth/refresh- Refresh access tokenPOST /api/v1/auth/forgot-password- Request password resetPOST /api/v1/auth/reset-password- Reset password with tokenPOST /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 validationrouter.py- FastAPI route definitionsservice.py- Business logic layerdependencies.py- FastAPI dependency injectionexceptions.py- Module-specific exceptions__init__.py- Module initialization
๐ป Example Usage
Starting from Scratch
1. Initialize a new project
# Create project directory
mkdir my-fastapi-app
cd my-fastapi-app
# Initialize project structure
fastapi-registry init --name "My FastAPI App"
2. Set up virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
3. Install dependencies
pip install -r requirements.txt
4. Add modules
# Add authentication module
fastapi-registry add auth
5. Configure and run
# Edit .env with your settings
# Then start the server
uvicorn main:app --reload
Adding to Existing Project
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 init
Initialize a new FastAPI project with proper structure:
- Creates
main.pywith FastAPI app setup - Sets up
app/directory structure - Creates
app/core/with config and database utilities - Creates
app/modules/for your modules - Generates
requirements.txtwith essential dependencies - Creates
.envwith default configuration - Adds
.gitignore,README.md, and development config files - Includes code quality tools config (
.flake8,.pylintrc,pyproject.toml)
Options:
--project-path, -p- Path to create project (default: current directory)--name, -n- Project name (default: directory name)--description, -d- Project description--force, -f- Initialize even if directory is not empty
Example:
# Initialize in current directory
fastapi-registry init
# Create a new project directory
mkdir my-api && cd my-api
fastapi-registry init --name "My API" --description "My awesome API"
# Initialize in specific path
fastapi-registry init --project-path /path/to/project
fastapi-registry list
Display all available modules from the registry
Options:
--search, -s- Search modules by name or description
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.pywith router registration - Adds dependencies to
requirements.txt - Adds environment variables to
.env
Options:
--project-path, -p- Path to FastAPI project (default: current directory)--yes, -y- Skip confirmation prompts
fastapi-registry remove <module>
Remove a module from your project (manual cleanup required for dependencies)
Options:
--project-path, -p- Path to FastAPI project (default: current directory)--yes, -y- Skip confirmation prompts
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
- Project initialization command
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_blocks_registry-0.1.1.tar.gz.
File metadata
- Download URL: fastapi_blocks_registry-0.1.1.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b4e439506601283bdf3a69997ad770dfb7786f20de59ec706cc12dbaa1b2aa8
|
|
| MD5 |
4f5ca5d5666b74927829275c299706be
|
|
| BLAKE2b-256 |
0734900cbcd2d4bb2e548ef71e77b1d1bf74da82cc296e0d63f70dc91df773a9
|
File details
Details for the file fastapi_blocks_registry-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_blocks_registry-0.1.1-py3-none-any.whl
- Upload date:
- Size: 48.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11da758d91734c1830ccec73c5d99d7227df47867b1406ba1a6bcd1b7a39dc8a
|
|
| MD5 |
1f4e79580f1e7daebbbdd31b18bd2c11
|
|
| BLAKE2b-256 |
e4054387375fadded8a07519ca6c1623a43244b77a727bc1f19e0449dc356660
|