A scalable image processing service built with Go using microservices architecture. Allows uploading images, processing them asynchronously (e.g., resizing, applying filters), and retrieving processed results via REST API.
This project is a scalable image processing service built in Go. It consists of two main components:
- API Server (app): Handles HTTP requests for uploading, retrieving, and deleting images.
- Worker: Asynchronously processes images using Kafka message queues.
The service uses PostgreSQL for storing image metadata, MinIO for file storage, and Kafka for processing coordination.
- ✅ Upload images via REST API
- ✅ Asynchronous image processing (resizing, filters, etc.)
- ✅ Retrieve processed images
- ✅ Delete images
- ✅ Scalable architecture using message queues
- ✅ Object storage (S3-compatible)
- ✅ Docker containerization for local development
- ✅ Database migrations
- ✅ Logging and monitoring
The project follows Clean Architecture principles and is divided into layers:
cmd/
├── app/ # API server entry point
└── worker/ # Worker entry point
internal/
├── api/ # HTTP handlers and server
├── infra/ # Infrastructure components (Kafka, MinIO, Worker)
├── models/ # Data structures
├── repository/ # Database repository layer
├── service/ # Business logic layer
└── middlewares/ # HTTP middleware
config/ # Configuration files
migrations/ # Database migrations
- User uploads image via API
- Image is stored in MinIO, metadata in PostgreSQL
- Message is sent to Kafka
- Worker receives message, processes image
- Processed image is stored back in MinIO
- Status is updated in database
- Docker and Docker Compose
- Go 1.25.3+ (for local development)
- Make (optional, for convenience)
-
Clone the repository:
git clone https://github.com/your-username/image-processor.git cd image-processor -
Create
.envfile based on example:cp .env.example .env
Fill in environment variables (see Configuration section).
-
Start services:
make up # or docker compose up -
Service will be available at: http://localhost:8080
-
Install dependencies:
go mod download
-
Start infrastructure services (DB, Kafka, MinIO):
docker compose up db kafka minio migrator kafka-init
-
Start API server:
go run cmd/app/main.go
-
In another terminal, start worker:
go run cmd/worker/main.go
# Database
DB_HOST=
DB_PORT=
DB_USER=
DB_PASSWORD=
DB_NAME=
DB_SSL_MODE=
# Kafka
KAFKA_BROKERS=
KAFKA_TOPIC=
KAFKA_GROUP_ID=
# MinIO (S3)
MINIO_HOST=
MINIO_PORT=
MINIO_ROOT_USER=
MINIO_ROOT_PASSWORD=
MINIO_SSL=
S3_BUCKET_NAME=
S3_LOCATION=
# Server
SERVER_PORT=
GIN_MODE=Main settings in YAML format. Supports overriding via environment variables.
POST /api/v1/images
Content-Type: multipart/form-data
Form data:
- image: image file
- processing: processing type (e.g., "resize:100x100")Response:
{
"id": 1,
"status": "uploaded"
}GET /api/v1/images/{id}Response: Binary image data
DELETE /api/v1/images/{id}Response:
{
"message": "Image deleted successfully"
}GET /api/v1/images/{id}/statusResponse:
{
"id": 1,
"status": "processed"
}cmd/: Application entry pointsinternal/api/: HTTP handlers and routinginternal/infra/: External service integrationsinternal/models/: Data modelsinternal/repository/: Database operationsinternal/service/: Business logicmigrations/: Database migrationsconfig/: Configuration
- Implement processing function in
internal/infra/handlers/images/process_image.go - Update
ImageKafkamodel if needed - Test the changes
make lint
# or
go vet ./...
golangci-lint run ./...go test ./...# Start infrastructure
docker compose up -d db kafka minio
# Run tests
go test -tags=integration ./...