A modern, production-ready FastAPI template with built-in features for rapid development and deployment.
- FastAPI - Modern, fast web framework for building APIs with automatic OpenAPI documentation
- FastAPI Pundra - Productivity companion for FastAPI development
- Auto Route Discovery - Automatic route discovery and binding from API modules
- SQLAlchemy - Powerful SQL toolkit and Object-Relational Mapping (ORM)
- Alembic - Database migration management and version control
- Pydantic - Built-in DTO (Data Transfer Object) with automatic data validation
- Schema Layer - Organized schemas for request/response validation
- Custom Serializers - Flexible data transformation and formatting
- TaskIQ - Distributed task queue for background job processing
- Task Scheduling - Built-in support for scheduled and recurring tasks
- JWT Authentication - Secure token-based user authentication
- Authorization Middleware - Role-based access control
- UV - Ultra-fast Python package manager and dependency resolver
- Pytest - Comprehensive testing framework with fixtures and factories
- Ruff - Lightning-fast Python linter and formatter
- Docker - Full containerization support with production-ready configurations
- Email Templates - Built-in email templating system with HTML/CSS support
- SQL File Management - Organized raw SQL queries for complex operations
- Structured Logging - Built-in logging utilities for debugging and monitoring
- Python 3.12 or higher
- UV package manager (recommended)
Clone the repository and install dependencies:
# Install dependencies
uv sync
# Install with development dependencies (recommended for development)
uv sync --extra devNote: The
--extra devflag installs additional development tools like testing frameworks, linters, and formatters.
Create your environment configuration:
# Copy the example environment file
cp .env.example .env
# Edit the .env file with your specific configuration
# Configure database URL, secret keys, email settings, etc.This project uses Alembic for database schema management and migrations.
Initialize and upgrade your database:
# Run database migrations
uv run db-upgrade
# create a new database revision
uv run db-revision "Initial database setup"Start the development server:
# Start the FastAPI development server with auto reload
uv run start-server-dev
# Start the FastAPI server
uv run start-serverThe API will be available at:
- API: http://localhost:8000
- Interactive Docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
├── _docs/* # Documentation files
├── alembic/* # Database migration management
├── app/ # Main application directory
│ ├── api/ # API routes
│ │ ├── v1/
│ │ │ ├── task_schedule_sample.py
│ │ │ └── user.py
│ │ ├── health.py
│ │ ├── root_index.py
│ │ └── router.py
│ ├── config/ # Application configuration
│ │ ├── authorization.py
│ │ └── cors.py
│ ├── lib/ # Library modules
│ │ ├── database.py
│ │ └── tskq/* # TaskIQ utilities
│ ├── middleware/ # Custom middleware
│ │ └── authorization_middleware.py
│ ├── models/ # Database models
│ │ └── users.py
│ ├── schemas/ # Pydantic schemas
│ │ └── user_schema.py
│ ├── serializers/ # Data serializers
│ │ └── user_serializer.py
│ ├── services/ # Business logic services
│ │ ├── scheduler_service.py
│ │ └── user_service.py
│ ├── sql_files/ # SQL query files
│ │ └── users/
│ │ ├── fetch-all-users.sql
│ │ └── fetch-single-user.sql
│ ├── tasks/
│ │ ├── my_schedule_task.py
│ │ └── my_task.py
│ ├── templates/ # HTML templates
│ │ ├── mails/
│ │ │ ├── css/
│ │ │ │ └── mail.css
│ │ │ └── welcome_email.html
│ │ └── user.html
│ ├── tests/* # Test files
│ ├── utils/ # Utility functions
│ │ ├── base.py
│ │ └── logger.py
│ ├── cli.py # CLI commands
│ ├── main.py # Application entry point
│ └── taskiq.py # TaskIQ configuration
├── docker/* # Docker configuration
├── scripts/* # Utility scripts
├── alembic.ini # Alembic configuration
├── pyproject.toml # Project dependencies and metadata
├── README.md # This file
├── ruff.toml # Ruff linter configuration
└── uv.lock # UV lock fileNote
This project needs python 3.12 or higher