Skip to content

Repository files navigation

FastAPI Template

Built-In Features:

Quick Start

  1. Install Docker on your machine.
  2. Start Docker.
  3. Add the environment variables in the .env file.
  4. Open the terminal in the root of the project.
  5. Build the image:
docker compose build
  1. Run the migrations:
docker compose run web alembic upgrade head
  1. Run the containers
docker compose up --watch
  1. When you want to stop the containers, press Ctrl+C or:
docker compose down

API Documentation

  1. Run the containers
docker compose up --watch
  1. Access:

Run Tests

docker compose run web pytest

Run Tests with Coverage

  1. Run tests with Pytest.
docker compose run web coverage run -m pytest
  1. To check the test coverage, it is possible to use Terminal Report or HTML.

Terminal Report

  1. Run:
docker compose run web coverage report

image

HTML

  1. Run:
docker compose run web coverage html
  1. Initialize the /htmlcov directory generated by the test coverage using the Live-Server extension in VSCode.
  2. Go to http://localhost:5500/htmlcov/
  3. Check the test coverage via HTML:

image

Delete Database

docker compose down -v

Create migration

docker compose run web alembic revision --autogenerate -m “first_commit”

Migrate

docker compose run web alembic upgrade head

Downgrade

docker compose run web alembic downgrade base

List Migrations History

docker compose run web alembic history

Run Commands in Container terminal

docker compose run web COMMAND

Seeds

docker compose run web python app/seeds.py

Deploy

  1. Create your account in AWS

  2. Install AWS CLI

  3. Login in AWS CLI

  4. Change variables in ./scripts/setup.sh:

REGION="us-east-1"
AWS_ACCOUNT_ID="111111111111"
PROJECT_NAME="fastapi-template"
  1. Run setup.sh script:
sh ./scripts/setup.sh
  1. Change AWS Lambda function URL permissions in AWS Console

About

FastAPI Template for fast project configuration with built-in UV, JWT Auth, Admin, ORM, Migrations, Tests, Coverage, camelCase API, Celery, Docker, PostgreSQL, Redis, CI/CD, AWS Lambda

Topics

Resources

Stars

9 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages