Installation Guide¶
This guide covers different ways to install and set up the FastAPI Boilerplate depending on your needs and environment.
System Requirements¶
Before you begin, ensure your system meets these requirements:
- Python: 3.11 or higher
- Operating System: Linux, macOS, or Windows (with WSL2 recommended)
- Memory: Minimum 4GB RAM (8GB recommended)
- Disk Space: At least 2GB free space
Method 1: Docker Compose (Recommended)¶
Docker Compose is the easiest way to get started. It handles all dependencies and services automatically.
Prerequisites¶
Install these tools on your system:
- Docker (version 20.10+)
- Docker Compose (version 1.29+)
Installation Steps¶
-
Get the template:
-
Set up environment:
-
Start services:
-
Verify installation:
What Gets Installed¶
Docker Compose sets up these services:
- Web server (FastAPI + Uvicorn) on port 8000
- PostgreSQL database on port 5432 (internal)
- Redis server on port 6379 (internal)
- ARQ Worker for background tasks
- NGINX (optional, for production)
Method 2: Manual Installation¶
For more control or development purposes, you can install everything manually.
Prerequisites¶
-
Install Python 3.11+:
-
Install uv (Python package manager):
-
Install PostgreSQL:
-
Install Redis:
Installation Steps¶
-
Clone the repository:
-
Install Python dependencies:
-
Set up environment variables:
-
Set up PostgreSQL:
-
Run database migrations:
-
Create admin user:
-
Start the application:
-
Start the worker (in another terminal):
Method 3: Development Setup¶
For contributors and advanced users who want to modify the boilerplate.
Additional Prerequisites¶
- Git for version control
- Pre-commit for code quality
Installation Steps¶
-
Fork and clone:
-
Install development dependencies:
-
Set up pre-commit hooks:
-
Set up development environment:
-
Run tests to verify setup:
Docker Services Breakdown¶
Understanding what each Docker service does:
Web Service¶
- Runs the FastAPI application - Handles HTTP requests - Auto-reloads on code changes (development)Database Service¶
db:
image: postgres:13
environment:
POSTGRES_DB: myapp
POSTGRES_USER: postgres
POSTGRES_PASSWORD: changethis
Redis Service¶
- In-memory data store - Used for caching and job queues - Persistent storage with AOFWorker Service¶
- Background task processor - Handles async jobs - Scales independentlyConfiguration¶
Environment Variables¶
The application uses environment variables for configuration. Key variables:
# Database
POSTGRES_USER=postgres
POSTGRES_PASSWORD=changethis
POSTGRES_SERVER=localhost # or "db" for Docker
POSTGRES_PORT=5432
POSTGRES_DB=myapp
# Redis
REDIS_CACHE_HOST=localhost # or "redis" for Docker
REDIS_CACHE_PORT=6379
# Security
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
Database Connection¶
For manual installation, update your database settings:
# Local PostgreSQL
POSTGRES_SERVER=localhost
POSTGRES_PORT=5432
# Docker PostgreSQL
POSTGRES_SERVER=db
POSTGRES_PORT=5432
Verification¶
After installation, verify everything works:
- API Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/api/v1/health
- Database Connection: Check logs for successful connection
- Redis Connection: Test caching functionality
- Background Tasks: Submit a test job
Troubleshooting¶
Common Issues¶
Port Already in Use:
Database Connection Error:
# Check PostgreSQL status
sudo systemctl status postgresql
# Restart PostgreSQL
sudo systemctl restart postgresql
Redis Connection Error:
Permission Errors:
Docker Issues¶
Clean Reset:
# Stop all containers
docker compose down
# Remove volumes (⚠️ deletes data)
docker compose down -v
# Rebuild images
docker compose build --no-cache
# Start fresh
docker compose up
Next Steps¶
After successful installation:
- Configuration Guide - Set up your environment
- First Run - Test your installation
- Project Structure - Understand the codebase
Need Help?¶
If you encounter issues:
- Check the GitHub Issues for common problems
- Search existing issues
- Create a new issue with details