A Baker template for generating modern FastAPI projects with optional database support and best practices.
- 🚀 FastAPI - Modern web framework with automatic API docs
- 📦 UV - Fast Python package manager (replaces pip/requirements.txt)
- 🗄️ Optional Database - SQLModel + Alembic with SQLite or PostgreSQL
- 🧹 Ruff - Lightning-fast linting and formatting
- ✨ Typos - Spell checking for code and documentation
- 🧪 Pytest - Testing framework with async support
- 🤖 GitHub Copilot - Pre-configured instructions for better AI assistance
- 🔧 VS Code - Optimized workspace settings and extensions
- ⚙️ Smart Setup - Conditional features based on your choices
# Install Baker (project generator, see https://github.com/aliev/baker on how to install)
# Install UV (Python package manager)
curl -LsSf https://astral.sh/uv/install.sh | sh
baker fastapi-baker-template my-awesome-api
You'll be prompted to choose:
- ✅ Database support (SQLModel + Alembic)
- ✅ Database type (SQLite or PostgreSQL)
- ✅ Example CRUD endpoints (User/Post models)
- ✅ Logfire integration (Enhanced logging)
- Template Generation - Files created based on your choices
- Git Repository - Initialized with proper .gitignore
- Virtual Environment - UV creates and configures venv
- Dependencies - All packages installed automatically
- Database Setup - Migration structure ready (if selected)
- Code Quality - Pre-configured linting and formatting
cd my-awesome-api
# If you chose database support:
uv run alembic revision --autogenerate -m "Initial migration"
uv run alembic upgrade head
# Start development server
uv run fastapi dev backend/main.py
Visit http://localhost:8000/docs for interactive API documentation.
my-awesome-api/
├── backend/
│ ├── main.py # FastAPI application entry point
│ ├── deps.py # Dependency injection (DB sessions, etc.)
│ ├── db/ # Database layer (if selected)
│ │ ├── schema.py # SQLModel database models
│ │ └── migrations/ # Alembic migration files
│ ├── routes/ # API route definitions
│ │ └── api.py # Main API endpoints
│ ├── services/ # Business logic layer
│ │ └── example.py # Example service patterns
│ └── tests/ # Test files with pytest
├── pyproject.toml # UV dependencies and tool config
├── alembic.ini # Database migration configuration (if DB selected)
├── .env.example # Environment variable template
├── .vscode/ # VS Code workspace settings
├── .github/ # Copilot instructions and workflows
├── .gitignore # Git ignore patterns
└── README.md # Project-specific documentation
- SQLModel - Type-safe ORM with Pydantic integration
- Alembic - Professional database migration management
- Multi-DB - SQLite (development) or PostgreSQL (production) [PostgreSQL has not been tested yet]
- CRUD Examples - Optional User/Post relationship models
- UV Package Manager - 10-100x faster than pip
- Ruff - All-in-one linting, formatting, and import sorting
- Typos - Catches spelling mistakes in code and docs
- Pytest - Async-ready testing with coverage support
- FastAPI - Automatic OpenAPI docs and type validation
- GitHub Copilot - Context-aware AI assistance configuration
- VS Code - Optimized settings and recommended extensions
- Hot Reload - Instant server restarts during development
# Start development server
uv run fastapi dev backend/main.py
# Run tests
uv run pytest
# Database migrations (if DB enabled)
uv run alembic revision --autogenerate -m "description"
uv run alembic upgrade head
# Code quality
uv run ruff format # Format code
uv run ruff check --fix # Fix linting issues
uv run typos # Check spelling
To modify this template:
- Edit the
.baker.j2
template files - Update
baker.yaml
for new configuration options - Test generation:
baker . test-project
- Submit PR with your improvements
Some of the code in this template was generated with the help of large language models (LLMs) and have not been fully tested and reviewed. Please review and test thoroughly before using in production.