This repository hosts an asynchronous REST API built using FastAPI. The API implements CRUD (Create, Read, Update, Delete) operations on entities in an efficient and non-blocking manner.
To install and run the app follow these steps:
- Clone the repo:
git clone https://github.com/alexfurmenkov/fast-api-async-entities-manager.git - Create Python virtual environment:
python3 -m venv venv - Activate Python virtual environment:
source venv/bin/activate - Install the required dependencies:
pip install -r requirements.txt - Start a PostgreSQL DB locally and export its URL:
export DATABASE_URL=... - Run DB migrations with Alembic:
alembic upgrade head - Export a JWT secret:
export JWT_SECRET_KEY=mysecret - Run the app:
uvicorn app:app --reload. It will start the app on port 8000.
After the app is launched, navigate to /docs URI to explore the interactive Swagger documentation:

The project contains K8S manifest files making it deployable to a K8S cluster. Follow these steps to spin up a Minikube cluster locally and deploy this app into this cluster.
- Install and start the Minikube cluster - https://minikube.sigs.k8s.io/docs/start/
- Create secrets:
kubectl apply -f k8s/secrets - Deploy Postgres:
kubectl apply -f k8s/postgres-deployment.yml && kubectl apply -f k8s/postgres-service.yml - Deploy the app itself:
kubectl apply -f k8s/app-deployment.yml && kubectl apply -f k8s/app-service.yml - Enable ingress addons in minikube:
minikube addons enable ingress && minikube addons enable ingress-dns - Deploy the Nginx ingress controller:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.0/deploy/static/provider/cloud/deploy.yaml - Deploy the ingress:
kubectl apply -f k8s/ingress.yml - (for Mac users) The ingress file makes the app available at
myapp.example.comhost. You need to edit/etc/hostsfile and map127.0.0.1tomyapp.example.com. Just add a new row like127.0.0.1 myapp.example.com. - (for Mac users) Run
minikube tunneland openmyapp.example.comin the browser. You should see the app homepage.