A simple backend template with a user system, jwt token management and email sending.
- FastAPI
- SQLModel
- Pydantic
- PostreSQL
- Docker & Docker Compose
- Secure password hashing & JWT authentication
- Password recovery with email
- Tests
- Docker
- Make
- uv
-
Create
.env
by copying.env.template
cp .env.template .env
-
Run the project
make dev
The app will be launched on port 8000
and it's possible to view the API docs on http://localhost:8000/docs
There's a makefile that has multiple useful commands defined within it
make dev
- runs the backend containermake build
- builds the backend containermake prod
- runs a prod version of the container that's smallermake shell
- runs and attached to the backend containermake check
- formats and checks the codemake test
- runs tests and shows the total code coveragemake test-email
- sends a test email to an email designated in .envmake migrations title="migration title"
- generates a new migration
Command to connect to any running container:
docker exec -it <container_id> bash
Command to connect to a postgresql container:
docker exec -it <container_id> psql -U postgres
Pre-commit hooks are set up to check the code on commits - configuration file. To install pre-commit hooks run pre-commit install
. More info here.
To run the checks before committing, run:
pre-commit run
Migrations are managed and generated automatically using Alembic. To automatically create a migration run:
make migrations title="migration title"
after adding a dependency with uv it's necessary to rebuild the backend docker container to update the containers dependencies
make build
To build a small docker image for prod run:
make prod