A hands-on example demonstrating how to build a modern, containerized Python microservice with:
- FastAPI for high-performance HTTP & WebSocket endpoints
- Celery for background task processing (Redis broker & result backend)
- PostgreSQL via SQLAlchemy & Alembic migrations
- Jinja2 templates & Bootstrap for a simple form UI
- Broadcaster + WebSockets for live task updates
- Docker Compose for a fully isolated local development stack
- Optional Datadog Agent integration for metrics & centralized logs
- Built-in security scans (Bandit, Semgrep, pip-audit, Trivy) via GitHub Actions
- Show how to cleanly separate web (FastAPI) and worker (Celery) concerns
- Provide synchronous REST + real-time WebSocket hooks for task status
- Illustrate container-based development with automatic reloads
- Enforce code quality & security best practices in CI/CD
- Offer a ready-to-fork template for future microservice projects
- Python 3.11
- FastAPI, Uvicorn
- Celery 5.x, Redis
- SQLAlchemy 2.x, Alembic
- Jinja2 + Bootstrap 5
- broadcaster (WebSocket pub/sub)
- Docker, Docker Compose
- Datadog Agent (optional)
- Bandit, Semgrep, safety, pip-audit, Trivy (security)
Docker & Docker Compose
git clone https://github.com/your-org/fastapi-celery-project.git
cd fastapi-celery-projectdocker-compose up --build- Web UI: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Celery Flower: http://localhost:5555
- PostgreSQL: http://localhost:5432 (user:
postgres, password:postgres) - Redis: http://localhost:6379
This work is mainly based on the FastAPI + Celery Microservice Example.