Skip to content

dhavalsavalia/fastapi-tdd-docker

Repository files navigation

FastAPI TDD with Docker, Postgres, and Pytest

Description

This is a simple project to demonstrate how to build a FastAPI application using Test Driven Development (TDD) as a development process. The project uses Docker and docker compose to containerize the application and Postgres database. Pytest is used as the testing framework.

Project Structure

.
├── app
│   ├── __init__.py
│   ├── main.py
│   ├── config.py
│   ├── db.py
│   ├── models
│   │   ├── __init__.py
│   │   └── tortoise.py
├── db
│   ├── Dockerfile
│   └── create.sql
├── migrations
│   ├── models
├── .dockerignore
├── .gitignore
├── docker-compose.yml
├── Dockerfile
├── entrypoint.sh
├── Pipfile
├── Pipfile.lock
├── README.md
└── pyproject.toml

Tech Stack

  • FastAPI
  • Docker
  • Postgres
  • Pytest
  • Tortoise ORM
  • Aerich

Running the Project

  1. Clone the repository
git clone https://github.com/dhavalsavalia/fastapi-tdd-docker.git
  1. Change directory to the project directory
cd fastapi-tdd-docker
  1. Build the Docker images
docker compose build --no-cache
  1. Run the Docker containers
docker compose up -d --build

Running Tests

To run the tests, execute the following command:

docker-compose exec web python -m pytest

Running Migrations

To run migrations, execute the following command:

docker-compose exec web aerich upgrade

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published