Buy-01 is a microservices-based e-commerce platform built with Spring Boot, providing product management, user authentication, and media handling capabilities.
- Architecture – System architecture and design
- API Endpoints – Complete API documentation
- Security – Security implementation details
- Kafka – Event-driven communication
- API Gateway Documentaion
- User Service Documentaion
- Product Service Documentaion
- Media Service Documentaion
- Discovery Server Documentaion
| Service | Port | Description |
|---|---|---|
| API Gateway | 8080 | Entry point for all client requests |
| Discovery Server | 8761 | Service registry (Eureka) |
| User Service | 8081 | Authentication & user management |
| Product Service | 8082 | Product catalog management |
| Media Service | 8083 | Media file storage |
| Service | Port | Database |
|---|---|---|
| MongoDB (Users) | 27017 | users |
| MongoDB (Products) | 27018 | products |
| MongoDB (Media) | 27019 | media |
| Service | Port | Purpose |
|---|---|---|
| Apache Kafka | 9092 | Event streaming |
- Pattern: Microservices Architecture
- Service Architecture: Hexagonal Architecture (Ports & Adapters)
- Communication: REST APIs + Event-Driven (Kafka)
- Service Discovery: Netflix Eureka
- API Gateway: Spring Cloud Gateway
backend/
├── api-gateway/ # Spring Cloud Gateway
├── discovery-server/ # Eureka Service Registry
├── user-service/ # User authentication & management
├── product-service/ # Product catalog (Reactive)
└── media-service/ # Media file management (Reactive)
- Framework: Spring Boot 3.x
- Language: Java 21
- Databases: MongoDB
- Message Broker: Apache Kafka
- Service Registry: Netflix Eureka
- API Gateway: Spring Cloud Gateway
- Authentication: JWT (JSON Web Tokens)
┌─────────────────────────────────────────────────────────────────┐
│ Clients │
│ (Web, Mobile, External APIs) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ API Gateway (8080) │
│ • JWT Validation │
│ • Rate Limiting │
│ • Request Logging │
│ • CORS │
│ • Route Management │
└─────────────────────────────────────────────────────────────────┘
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌─────────────────────┐ ┌──────────────┐ ┌─────────────────────┐
│ User Service │ │ Product │ │ Media Service │
│ (8081) │ │ Service │ │ (8083) │
│ │ │ (8082) │ │ │
│ • Authentication │ │ │ │ • File Upload │
│ • User Management │ │ • Products │ │ • File Storage │
│ • Registration │ │ • Inventory │ │ • Image Retrieval │
│ • Login/JWT │ │ │ │ │
└─────────────────────┘ └──────────────┘ └─────────────────────┘
│ │ │
└───────────────┼───────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Discovery Server (8761) │
│ Netflix Eureka Server │
│ Service Registration & Discovery │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Apache Kafka (9092) │
│ Event-Driven Communication │
└─────────────────────────────────────────────────────────────────┘
│
┌───────────────┴───────────────┐
▼ ▼
┌──────────────────────────────┐ ┌─────────────────────────────┐
│ MongoDB Instances │ │ Additional Services │
├─────────────┬────────────────┤ │ │
│ Users (27017)│Products(27018)│ │ • Logging │
│ Media (27019)│ │ │ • Monitoring │
└─────────────┴────────────────┘ └─────────────────────────────┘
- Port: 8080
- Technology: Spring Cloud Gateway
- Responsibilities:
- Centralized entry point for all requests
- JWT token validation
- Rate limiting (Bucket4j)
- Request and response logging
- CORS management
- Dynamic route configuration
- Port: 8761
- Technology: Netflix Eureka
- Responsibilities:
- Service registration and discovery
- Load balancing support
- Health monitoring
- Port: 8081
- Technology: Spring Boot (Servlet)
- Database: MongoDB (27017)
- Responsibilities:
- User registration and authentication
- JWT token generation
- User profile and role management
- Port: 8082
- Technology: Spring Boot WebFlux (Reactive)
- Database: MongoDB (27018)
- Responsibilities:
- Product CRUD operations
- Inventory management
- Kafka event publishing
- Image association
- Port: 8083
- Technology: Spring Boot WebFlux (Reactive)
- Database: MongoDB (27019)
- Responsibilities:
- Media upload and storage (GridFS)
- Media retrieval
- Kafka event consumption
- Orphaned media cleanup
-
Hexagonal Architecture (Ports & Adapters)
- Domain Layer: Core business logic
- Ports: Interfaces for inbound (use cases) and outbound (repositories)
- Adapters: Implementations for inbound (controllers) and outbound (MongoDB)
-
Event-Driven Architecture
- Kafka for asynchronous communication between services
- Decouples Product and Media services
-
API Gateway Pattern
- Centralized entry point
- Handles cross-cutting concerns (authentication, logging, rate limiting)
-
Service Discovery
- Dynamic service registration
- Eliminates hard-coded service URLs
git clone https://github.com/hmaach/buy-01.git
cd buy-01Requirements:
- Git
- Docker & Docker Compose
- Java 21+
- Maven (optional,
mvnwincluded)
make envThis starts all containers defined in docker-compose.yml in detached mode.
make docker-upTo stop and remove all running containers:
make docker-down| Service | Endpoint |
|---|---|
| API Gateway | http://localhost:8080/actuator/health |
| User Service | http://localhost:8081/actuator/health |
| Product Service | http://localhost:8082/actuator/health |
| Media Service | http://localhost:8083/actuator/health |
Use Cases:
- Service monitoring
- Readiness & liveness checks
- Integration with service discovery
- Observability (e.g., Prometheus)
- Load balancer health checks