|
| 1 | +# FastAPI RabbitMQ Celery Flower Application |
1 | 2 |
|
2 | | -## Docker commands |
| 3 | +A distributed application for sending SMS and emails using FastAPI, RabbitMQ, Celery, Flower and PostgreSQL. |
3 | 4 |
|
4 | | -**start all containers** |
5 | | -``` |
| 5 | +### Features |
| 6 | +- **Distributed Messaging System**: Implemented a robust architecture for message processing using FastAPI, RabbitMQ, Celery, and PostgreSQL |
| 7 | +- **SMS Notifications**: Integration with Twilio API for sending SMS messages |
| 8 | +- **Email Notifications**: Integration with Brevo (formerly Sendinblue) for sending transactional emails |
| 9 | +- **Message Queuing**: Separate queues for SMS and email tasks to optimize message processing |
| 10 | +- **Database Persistence**: PostgreSQL integration for storing and tracking message status |
| 11 | +- **Containerization**: Full Docker support with docker-compose for easy deployment |
| 12 | +- **Real-time Monitoring**: Flower dashboard for monitoring Celery workers and task execution |
| 13 | +- **API Documentation**: Swagger UI for easy API testing and documentation |
| 14 | + |
| 15 | +### Technical Highlights |
| 16 | +- **FastAPI Web Server**: RESTful API endpoints for triggering notifications |
| 17 | +- **Celery Workers**: Background task processing for non-blocking operations |
| 18 | +- **RabbitMQ Message Broker**: Reliable message queuing with management interface |
| 19 | +- **Health Checks**: Service health monitoring for all components |
| 20 | +- **Environment Configuration**: Separate environment configurations for web and worker components |
| 21 | +- **Dependency Management**: Poetry for Python dependency management |
| 22 | + |
| 23 | +### Infrastructure |
| 24 | +- **Database**: PostgreSQL 14 |
| 25 | +- **Message Broker**: RabbitMQ 3 with Management Plugin |
| 26 | +- **Monitoring**: Celery Flower dashboard with authentication |
| 27 | +- **Service Orchestration**: Docker Compose with health checks and dependency management |
| 28 | + |
| 29 | +## Setup and Run |
| 30 | + |
| 31 | +1. Clone the repository: |
| 32 | + ```bash |
| 33 | + git clone https://github.com/ysskrishna/fastapi-rabbitmq-celery-flower |
| 34 | + cd fastapi-rabbitmq-celery-flower |
| 35 | + ``` |
| 36 | + |
| 37 | +2. Update environment variables: |
| 38 | + |
| 39 | + **For webserver/.env:** |
| 40 | + ``` |
| 41 | + TWILIO_FROM_PHONE="your-twilio-phone-number" |
| 42 | + BREVO_FROM_EMAIL="your-brevo-from-email" |
| 43 | + ``` |
| 44 | + |
| 45 | + **For worker/.env:** |
| 46 | + ``` |
| 47 | + TWILIO_ACCOUNT_SID="your-twilio-account-sid" |
| 48 | + TWILIO_AUTH_TOKEN="your-twilio-auth-token" |
| 49 | + BREVO_API_KEY="your-brevo-api-key" |
| 50 | + ``` |
| 51 | + |
| 52 | +3. Run the application using Docker Compose: |
| 53 | + ```bash |
| 54 | + docker-compose up -d |
| 55 | + ``` |
| 56 | + |
| 57 | +4. Access the application: |
| 58 | + - Swagger API documentation: `http://localhost:8000/docs` |
| 59 | + - RabbitMQ Management UI: `http://localhost:15672/` (Username: admin_user, Password: admin_pass) |
| 60 | + - Flower dashboard: `http://localhost:5555/` (Username: admin, Password: supersecret) |
| 61 | + |
| 62 | +## Development |
| 63 | + |
| 64 | +To modify the application: |
| 65 | + |
| 66 | +1. Update code in the `webserver` or `worker` directories |
| 67 | +2. Restart the containers: |
| 68 | + ```bash |
| 69 | + docker-compose down |
| 70 | + docker-compose up -d |
| 71 | + ``` |
| 72 | + |
| 73 | +## Docker Commands |
| 74 | + |
| 75 | +```bash |
| 76 | +# Start all containers |
6 | 77 | docker compose up --build |
7 | | -``` |
8 | 78 |
|
9 | | -**stop all containers** |
10 | | -``` |
| 79 | +# Stop all containers |
11 | 80 | docker compose down |
12 | | -``` |
13 | 81 |
|
14 | | -**stop and delete volumes** |
15 | | -``` |
| 82 | +# Stop and delete volumes |
16 | 83 | docker compose down -v |
17 | | -``` |
18 | | - |
19 | | -**Fastapi swagger documentation** |
20 | | -``` |
21 | | -http://localhost:8000/docs |
22 | | -``` |
23 | | - |
24 | | -**Rabbitmq Dashboard** |
25 | | -``` |
26 | | -http://localhost:15672/ |
27 | | -``` |
28 | | - |
29 | | -**Flower dashboard** |
30 | | -``` |
31 | | -http://localhost:5555/ |
32 | | -``` |
33 | | - |
34 | | -**update webserver/.env variables** |
35 | | -``` |
36 | | -TWILIO_FROM_PHONE="your-twilio-phone-number" |
37 | | -BREVO_FROM_EMAIL="your-brevo-from-email" |
38 | 84 | ``` |
0 commit comments