A distributed system for processing image files using microservices and message queues.
- Python 3.9
- Flask: Web framework for upload service
- Pillow (PIL): Image processing library
- RabbitMQ 3: Message broker for service communication
- Pika: Python RabbitMQ client
- Docker: Container platform
- Docker Compose: Multi-container orchestration
- Image resizing (max 800x800)
- Format support: PNG, JPG, JPEG, GIF
- Aspect ratio preservation
- REST API (Upload Service)
- Asynchronous messaging (Inter-service)
- Dead Letter Queue for error handling
Service-specific dependencies are listed in their respective requirements.txt files:
Key configuration parameters (in shared/config.py):
- Max file size: 10MB
- Supported formats: PNG, JPG, JPEG, GIF
- Image max dimensions: 800x800 pixels
- RabbitMQ connection details
- Queue names and configurations
The system consists of four microservices:
- Upload Service: Receives files via HTTP and initiates processing
- Validation Service: Validates file format, size, and type
- Processing Service: Processes images (resizing)
- Notification Service: Handles completion notifications
- Docker and Docker Compose
- cURL (for testing)
- At least 4GB RAM
- 10GB free disk space
- Clone the repository:
git clone <repository-url>
cd simple-file-processing-pipeline
- Create necessary directories:
mkdir -p uploads
- Build and start services:
docker-compose build
docker-compose up -d
- Verify services are running:
docker-compose ps
- Test Upload Service:
# Upload an image
curl -X POST -F "file=@/path/to/your/image.jpg" http://localhost:5001/upload
# Expected response:
# {"message": "File uploaded successfully", "filepath": "/app/uploads/your-image.jpg"}
- Check Processing Results:
# List files in uploads directory
ls -l uploads/
# You should see:
# - Original file: image.jpg
# - Processed file: image_processed.jpg
- Check Service Logs:
# Upload Service logs
docker-compose logs upload_service
# Validation Service logs
docker-compose logs validation_service
# Processing Service logs
docker-compose logs processing_service
# Notification Service logs
docker-compose logs notification_service
-
Upload
- Client uploads file via HTTP POST
- File is saved to shared volume
- Message sent to validation queue
-
Validation
- Checks file existence
- Validates file size (max 10MB)
- Validates file extension (png, jpg, jpeg, gif)
- Forwards valid files to processing queue
-
Processing
- Resizes image to max 800x800px
- Maintains aspect ratio
- Saves processed file with "_processed" suffix
- Forwards to notification queue
-
Notification
- Receives processing completion message
- Logs completion status
- Failed validations go to dead letter queue
- Processing errors go to dead letter queue
- Services implement retry logic for RabbitMQ connections
- Upload Service: 5001
- RabbitMQ Management: 15672
- RabbitMQ: 5672
Access RabbitMQ management interface:
URL: http://localhost:15672
Username: guest
Password: guest
- Services not starting:
# Check service logs
docker-compose logs
# Restart services
docker-compose restart
- Upload fails:
# Check upload service logs
docker-compose logs upload_service
# Verify upload directory permissions
ls -l uploads/
- Processing fails:
# Check processing service logs
docker-compose logs processing_service
# Check available disk space
df -h
Stop and remove containers:
docker-compose down
# Remove all processed files
rm -rf uploads/*
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request