A scalable microservice for compressing and managing images using AWS S3, Redis Streams, and Celery using Python.
- Image upload and compression
- Asynchronous processing with Celery
- Event streaming with Redis
- Cloud storage with AWS S3
- RESTful API with FastAPI
Technology | Purpose |
---|---|
Main programming language | |
API framework | |
Event streaming | |
Task queue | |
Cloud storage | |
Containerization |
- Python 3.8+
- Docker and Docker Compose
- AWS Account with S3 access
- Redis Server
- Clone the repository:
git clone https://github.com/yourusername/ImageCompressor.git
cd ImageCompressor
- Create and configure .env file:
AWS_REGION=your-region
AWS_BUCKET_NAME=your-bucket
AWS_ACCESS_KEY_ID=your-key
AWS_SECRET_ACCESS_KEY=your-secret
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_DB=0
- Build and run with Docker Compose:
docker-compose up --build
Method | Endpoint | Description |
---|---|---|
POST | `/image_upload` | Upload new image |
GET | `/image/{image_id}` | Get compressed image |
GET | `/images/list_indexs` | List all images |
- Client uploads image via API
- Image is stored in S3
- Compression task is queued in Celery
- Redis streams track processing status
- Compressed image is stored back in S3
- Client can download compressed image
api
: FastAPI applicationworker
: Celery workerredis
: Redis server