Template for FastAPI projects with database.
- Create and activate python virtual environment
- Install dependencies:
python -m pip install -U pip pip install -r requirements.txt
- Create .env file to configurate application (see Configuration section)
- Apply database migrations:
python migrate.py
- Run application:
python run.py
API documentation awailable at http://localhost:8000/docs
Available environment variables:
DB_URL # PostgresDsn, required. URL to PostgreSQL database
DB_SCHEMA # string, default is 'public'. PostgreSQL schema
name
DEBUG # boolean, default is false. If true, enable
server reloading
ROOT_PATH # string, default is empty string. Path setting
for proxy.
docker compose up --build -d