Backend-only FastAPI service that queues math operations to a Celery worker via RabbitMQ and stores results in PostgreSQL.
- Python 3.11
- FastAPI async API
- Celery worker (separate process/container)
- PostgreSQL persistence
- Alembic migrations
- Docker-ready
- Minikube-compliant
app/
api/ # HTTP routes
core/ # config + exception handlers
db/ # session + base
models/ # SQLAlchemy models
schemas/ # Pydantic schemas
services/ # business logic
tasks/ # Celery app + tasks
- Create a local
.envfile:
cp .env.example .env- Start the stack:
docker compose up --build- Run migrations (external tool, not runtime-managed):
docker compose exec api alembic upgrade head- Open the API docs:
http://localhost:8000/docs
Adminer is available at http://localhost:8080 for safe DB access (no direct DB port exposure).
You need RabbitMQ and PostgreSQL running locally. Then:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
alembic upgrade head
python -m app.serverIn another terminal:
celery -A app.tasks.celery_app:celery_app worker --loglevel=infoDocs: http://localhost:8000/docs.
Prerequisites:
- Docker, Minikube, Kubectl installed
Run:
runDeploy.batThe script will build the image, apply Kubernetes resources, run migrations, and open /docs.
Prerequisites:
- Docker, Minikube, Kubectl installed
Run:
./UbuntuDeploy.shThe script will build the image, apply Kubernetes resources, run migrations, and open /docs.
math-deployment.yamlincludes the API, worker, RabbitMQ, and PostgreSQL deployments.- Configuration is driven via
math-config.yaml(ConfigMap). - The API service is exposed via NodePort; open
/docsfor the Swagger UI. - Migrations are run via the
math-migrate-job.yamlJob.
minikube start
docker build -t mathcontainer:latest .
minikube image load mathcontainer:latest
kubectl apply -f math-config.yaml -f math-deployment.yaml
kubectl rollout status deployment/math-api --timeout=120s
kubectl delete job math-migrate --ignore-not-found
kubectl apply -f math-migrate-job.yaml
kubectl wait --for=condition=complete job/math-migrate --timeout=120s
minikube service math-calculator-service --urlPOST /calculate-> returns a job ID (string)GET /result/{job_id}-> returns{ status, result }
Use DBeaver or Adminer. Adminer via container is safer; exposing the DB port directly is not recommended.