An open API service indexing awesome lists of open source software.

https://github.com/shaliamekh/clean-architecture-fastapi

Medium article "Clean Architecture with Python"
https://github.com/shaliamekh/clean-architecture-fastapi

clean-architecture fastapi mongodb python tdd

Last synced: about 2 months ago
JSON representation

Medium article "Clean Architecture with Python"

Awesome Lists containing this project

README

        

# Clean Architecture on Python with FastAPI


CI

This repository serves as an illustrative example of implementing Clean Architecture
principles in a Python application using FastAPI. It accompanies the Medium article
[“Clean Architecture with Python”](https://medium.com/@shaliamekh/clean-architecture-with-python-d62712fd8d4f).

## Local setup

Create a virtual environment and install dependencies

```shell
python3 -m venv venv && venv/bin/pip install -r src/requirements.txt
```
Launch a mongodb instance using Docker
```shell
docker run --rm -d -p 27017:27017 --name=mongo-auctions mongo:8.0.4
```

Run tests
```shell
venv/bin/pytest src/tests
```

Start FastAPI application

```shell
venv/bin/fastapi dev src/drivers/rest/main.py
```

## Clean up

Remove the mongodb container
```shell
docker rm -f mongo-auctions
```