A CLI to generate a FastAPI + Alembic + SQLAlchemy boilerplate
Project description
The high-performance, drift-ready boilerplate for FastAPI.
Hatchback is a powerful CLI tool designed to bootstrap and manage production-ready FastAPI applications. It comes pre-loaded with best practices, security hardening, and a modular architecture that scales.
โจ Features
- ๐ Production Ready: SQLAlchemy 2.0, Pydantic v2, and Alembic pre-configured.
- ๐ก๏ธ Secure by Default: Rate limiting (SlowAPI), hardened Auth (JWT), secure secret generation, and non-root Docker containers.
- โก Blazing Fast: Optional
uvsupport for lightning-fast dependency management. - ๐๏ธ Clean Architecture: Service-Repository pattern for maintainable code.
- โ
Testing Ready: Integrated
pytestsetup withhatchback test. - ๐ณ Dockerized: Ready-to-deploy
docker-composesetup with healthchecks. - ๐๏ธ Drift Mode: A CLI that drives as good as it looks.
๐ฆ Installation
pip install hatchback
๐ Quick Start
1. Initialize a new project
hatchback init my_project_name
You will be prompted for:
- Database Name
- Docker inclusion
uvusage (if installed, for faster setup)
Options:
--use-uv: Force usage ofuvfor virtualenv creation.--no-docker: Skip Docker file generation.
2. Start the Engine
Before hitting the gas, ensure your database is running and the schema is initialized.
1. Start Database:
cd my_project_name
docker-compose up -d db
(Or configure a local Postgres instance in .env)
2. Initialize Database: Create and apply the first migration for the built-in models (User, Tenant).
hatchback migrate create -m "initial_setup"
hatchback migrate apply
3. Run Server: Start the development server with hot-reloading.
hatchback run
๐ Success! Your API is now live.
- API Docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
3. Scaffold Resources
Don't write boilerplate. Generate Models, Schemas, Repositories, Services, and Routes in one go. Hatchback automatically registers your new routes and services, so they are ready to use immediately.
hatchback make Product
4. Manage Migrations
Wrapper around Alembic to keep your database in sync.
# Create a migration
hatchback migrate create -m "add products table"
# Apply migrations
hatchback migrate apply
5. Seed Data
Populate your database with initial data (default tenant and admin user).
hatchback seed
๐๏ธ Architecture Explained
Hatchback follows a Service-Repository pattern to keep your code modular and testable.
- Routes (
app/routes/): Handle HTTP requests/responses and dependency injection. They delegate business logic to Services. - Services (
app/services/): Contain the business logic. They orchestrate data operations using Repositories. - Repositories (
app/repositories/): Handle direct database interactions (CRUD). They abstract the SQL/ORM details from the rest of the app. - Models (
app/models/): SQLAlchemy database definitions. hatchback test
Run with coverage (pass arguments to pytest)
hatchback test --
Hatchback projects come with pytest configured.
# Run all tests
pytest
# Run with coverage
pytest --cov=app
๐ Project Structure
my_project/
โโโ app/
โ โโโ config/ # Database, Security, Limiter config
โ โโโ models/ # SQLAlchemy Database Models
โ โโโ schemas/ # Pydantic Data Schemas
โ โโโ repositories/ # Data Access Layer (CRUD)
โ โโโ services/ # Business Logic
โ โโโ routes/ # API Endpoints
โ โโโ dependencies.py
โ โโโ main.py
โโโ alembic/ # Database Migrations
โโโ tests/ # Pytest Suite
โโโ docker-compose.yml
โโโ requirements.txt
๐ก๏ธ Security Features
- Rate Limiting: Built-in protection against brute-force attacks.
- Secure Headers: Trusted host middleware configuration.
- Password Hashing: Argon2/Bcrypt support via Passlib.
- Docker Security: Runs as a non-root user to prevent container breakout.
Built with ๐ and ๐๏ธ by Ignacio Bares(nachovoss) and the Hatchback Team.
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
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 hatchback-0.1.6.tar.gz.
File metadata
- Download URL: hatchback-0.1.6.tar.gz
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
739e82d699781b3c219e63d77a3a005aeb58788e8e6bde21b97d3bb8681cdd4e
|
|
| MD5 |
1200c536c2a57af23dbc19fe24cec390
|
|
| BLAKE2b-256 |
83fc8144b612e20cff7db8e203f85e0a4215bf044a2d8d841f8ba3218ef5a8f8
|
Provenance
The following attestation bundles were made for hatchback-0.1.6.tar.gz:
Publisher:
publish.yml on nachovoss/hatchback
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hatchback-0.1.6.tar.gz -
Subject digest:
739e82d699781b3c219e63d77a3a005aeb58788e8e6bde21b97d3bb8681cdd4e - Sigstore transparency entry: 788036145
- Sigstore integration time:
-
Permalink:
nachovoss/hatchback@07e3d605c5d689572a946535e2eb654f7218dc1a -
Branch / Tag:
refs/tags/0.1.6 - Owner: https://github.com/nachovoss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@07e3d605c5d689572a946535e2eb654f7218dc1a -
Trigger Event:
release
-
Statement type:
File details
Details for the file hatchback-0.1.6-py3-none-any.whl.
File metadata
- Download URL: hatchback-0.1.6-py3-none-any.whl
- Upload date:
- Size: 49.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0a49b02fbe8463515ac7a3695369e8a963899959e6048480627e1df0b0f855e
|
|
| MD5 |
480ef6db28a0777de4abb7d2cbbdbd80
|
|
| BLAKE2b-256 |
d654e1d69b38509fc9adaf21e33e7f22ee9b1ac42d6d13557c1fdf7a1420a795
|
Provenance
The following attestation bundles were made for hatchback-0.1.6-py3-none-any.whl:
Publisher:
publish.yml on nachovoss/hatchback
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hatchback-0.1.6-py3-none-any.whl -
Subject digest:
d0a49b02fbe8463515ac7a3695369e8a963899959e6048480627e1df0b0f855e - Sigstore transparency entry: 788036147
- Sigstore integration time:
-
Permalink:
nachovoss/hatchback@07e3d605c5d689572a946535e2eb654f7218dc1a -
Branch / Tag:
refs/tags/0.1.6 - Owner: https://github.com/nachovoss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@07e3d605c5d689572a946535e2eb654f7218dc1a -
Trigger Event:
release
-
Statement type: