This is a boilerplate project for fastapi. It is based on the fastapi official tutorial. It aims to be a simple MVC project with a database connection. The example is a simple todo list.
It uses Jinja2 as a template engine and Prisma as an ORM.
For the frontend, it uses Bootstrap and HTMX.
- Docker and docker-compose v2 for running the project
- Python 3.10+ and Poetry for development
cp docker-compose.override.yml.dist docker-compose.override.yml
docker compose up
# Install dependencies
poetry install
# Run the project
poetry run uvicorn app.main:app --reload
# Run tests
poetry run pytest
# Run linters
poetry run ruff . --fix
poetry run black .
To declare a new route, you need to create a new file in the app/routes
directory. The file must contain a router
variable that is an instance of fastapi.APIRouter
. It will be automaticaly binded to the fastapi application.
# app/routes/my_route.py
from fastapi import APIRouter
router = APIRouter(prefix="/my_route")
@router.get("/helloworld")
async def my_route():
return {"message": "Hello World"}