Skip to content

This is a simple boilerplate MVC like project to create quickly application with great components (Fastapi, Prisma, HTMX...)

Notifications You must be signed in to change notification settings

vvatelot/fastapi_boilerplate

Repository files navigation

Fastapi Boilerplate project

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.

Requirements

Quickstart

Running the project

cp docker-compose.override.yml.dist docker-compose.override.yml 
docker compose up

Development

# Install dependencies
poetry install

# Run the project
poetry run uvicorn app.main:app --reload

Project quality

# Run tests
poetry run pytest

# Run linters
poetry run ruff . --fix
poetry run black .

Application structure

Declare a new route

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"}

About

This is a simple boilerplate MVC like project to create quickly application with great components (Fastapi, Prisma, HTMX...)

Topics

Resources

Stars

Watchers

Forks