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.12+ and uv for development
cp docker-compose.override.yml.dist docker-compose.override.yml
docker compose up
# Service is running on http://localhost:8000
To improve development experience, a devcontainer configuration is available. To setup a development environment, you can simply use Vscode Devcontainer. Once the devcontainer is up, just run the command uv run fastapi dev ./app/main.py
to start the dev server that will be available on localhost:8000
Else, you can follow those steps to configure the development environment on your host:
# Install dependencies
uv sync --all-groups --frozen
# Install prisma client
uv run prisma migrate dev --schema database/schema.prisma
# Run the project
uv run fastapi dev ./app/main.py
# Run linters
uv run ruff check . --fix
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"}