A clean, minimal FastAPI starter template with async PostgreSQL, type checking, and Docker support.
- FastAPI - async web framework
- PostgreSQL - main database
- SQLModel - ORM with Pydantic-style models
- Alembic - database migrations
- Pydantic - data validation
- UV - dependency management
- Mypy, Ruff - static analysis & linting
- Docker Compose - local PostgreSQL deployment
Instead of cloning directly, click the “Use this template” button on the GitHub page of this project, then select “Create a new repository”. This gives you your own copy, independent of the original.
After creating your repo, clone it:
git clone https://github.com/<your-username>/<your-repo-name>.git
cd <your-repo-name>Make sure you have uv installed. Then install project dependencies:
uv syncCreate .env files based on .env.example files located in the root and in local/postgres_db/.
cp .env.example .env
cp local/postgres_db/.env.example local/postgres_db/.envMake sure you have Docker and Docker Compose installed.
docker compose -f local/postgres_db/docker-compose.yml up -dThis starts a local PostgreSQL database.
After creating or modifying models, generate and apply migrations:
alembic revision --autogenerate -m "describe changes"
alembic upgrade headruff check --fix
mypy appapp/
├── __init__.py
├── main.py
├── settings.py
├── database/
│ ├── __init__.py
│ ├── engine.py
│ └── seesion.py
├── users/ # example module
│ ├── __init__.py
│ ├── model.py
│ ├── repository.py
│ ├── service.py
│ └── router.py
alembic/
local/
└── postgres_db/
├── .env
└── docker-compose.yml
| Task | Command |
|---|---|
| Run app locally | uvicorn app.main:app --reload |
| Start PostgreSQL | docker compose up -d |
| Run migrations | alembic upgrade head |
| Lint & type check | ruff check --fix && mypy app |
- Keep your
.envfiles out of version control. - Use async SQLModel operations for best performance.
- Always run linters and type checkers before committing.