How sumanentc/fastapi-celery-rabbitmq-application works
Project type and purpose
• This is a backend API application demonstrating an asynchronous architecture using FastAPI for HTTP request handling and Celery (with RabbitMQ as broker/backend) for background task processing. There is no separate “frontend” beyond the automatically generated Swagger UI.
File structure
• Top-level scripts and configs:
• main.py – Entry point that creates the FastAPI app and wires up Celery
• Pipfile / requirements.txt – Dependency / environment management
• Directories:
• api/ – Core business-logic functions (e.g., universities.py)
• routers/ – FastAPI route definitions pointing to api functions
• schemas/ – Pydantic models for request/response validation
• celery_tasks/ – Celery task definitions calling api functions asynchronously
• config/ – Celery configuration and helper utilities
• No database folder—so persistence is external or out of scope; RabbitMQ doubles as broker and result backend.
Insights from the README
• Components: FastAPI app, Celery workers, RabbitMQ broker/backend, optional Flower UI for monitoring
Relationships and data flow
• Client → HTTP POST/GET → FastAPI endpoint
• FastAPI enqueues Celery task via Celery client (configured to use RabbitMQ)
• Task message → RabbitMQ queue
• Celery worker consumes from queue → executes task (calls into api/)
• On completion, Celery stores result back in RabbitMQ backend
• FastAPI can poll or retrieve the result by task ID
• Flower subscribes to RabbitMQ to display task status
Architectural patterns and principles
• Asynchronous, decoupled processing using message queue (push-based)
• Single responsibility: routers handle HTTP, api modules handle logic, celery_tasks handle async wrappers, config modules handle settings
• Pydantic models for schema validation (type-safe contracts)
• Clear separation between sync (FastAPI) and async (Celery) components
Technologies & libraries
• FastAPI (uvicorn)
• Celery (task queue)
• RabbitMQ (broker & backend)
• Flower (monitoring)
• Pydantic (schemas)
• Pipenv (environment)