Skip to content

A high-performance microservice for efficient image compression. Using FastAPI, Celery, Redis Streams, and AWS S3, it automatically processes uploaded images, reduces their size while maintaining quality, and delivers them via a REST API.

Notifications You must be signed in to change notification settings

PedroH183/vigilant-happiness

Repository files navigation

Image Compressor Service

A scalable microservice for compressing and managing images using AWS S3, Redis Streams, and Celery using Python.

🚀 Features

  • Image upload and compression
  • Asynchronous processing with Celery
  • Event streaming with Redis
  • Cloud storage with AWS S3
  • RESTful API with FastAPI

🛠️ Technologies Used

Technology Purpose
Python Main programming language
FastAPI API framework
Redis Event streaming
Celery Task queue
AWS S3 Cloud storage
Docker Containerization

📋 Requirements

  • Python 3.8+
  • Docker and Docker Compose
  • AWS Account with S3 access
  • Redis Server

🔧 Installation

  1. Clone the repository:
git clone https://github.com/yourusername/ImageCompressor.git
cd ImageCompressor
  1. 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
  1. Build and run with Docker Compose:
docker-compose up --build

📡 API Endpoints

Method Endpoint Description
POST `/image_upload` Upload new image
GET `/image/{image_id}` Get compressed image
GET `/images/list_indexs` List all images

🔄 Process Flow

  1. Client uploads image via API
  2. Image is stored in S3
  3. Compression task is queued in Celery
  4. Redis streams track processing status
  5. Compressed image is stored back in S3
  6. Client can download compressed image

🐳 Docker Services

  • api: FastAPI application
  • worker: Celery worker
  • redis: Redis server

About

A high-performance microservice for efficient image compression. Using FastAPI, Celery, Redis Streams, and AWS S3, it automatically processes uploaded images, reduces their size while maintaining quality, and delivers them via a REST API.

Topics

Resources

Stars

Watchers

Forks