A comprehensive e-commerce microservices architecture built with Spring Boot, Spring Cloud, and modern cloud-native technologies.
This project implements a microservices architecture for an e-commerce platform with the following components:
- Product Service - Manages product catalog and inventory
- Inventory Service - Handles stock management and availability
- Order Service - Processes customer orders and orchestrates transactions
- Notification Service - Sends email notifications for order confirmations
- Service Discovery - Eureka server for service registration and discovery
- API Gateway - Spring Cloud Gateway for routing and load balancing
- Config Server - Centralized configuration management
- Common Library - Shared DTOs, events, and utilities
- MongoDB - Document database for product catalog
- PostgreSQL - Relational database for orders and inventory
- Apache Kafka - Event streaming for asynchronous communication
- Prometheus - Metrics collection and monitoring
- Grafana - Visualization and alerting
- Java 21 - Programming language
- Spring Boot 3.4.4 - Application framework
- Spring Cloud 2024.0.0 - Microservices toolkit
- Spring Data JPA/MongoDB - Data access layer
- Spring Cloud Gateway - API gateway
- Netflix Eureka - Service discovery
- Apache Kafka - Event streaming
- Resilience4j - Circuit breaker and fault tolerance
- MapStruct - Object mapping
- Docker & Docker Compose - Containerization
- Prometheus & Grafana - Monitoring and observability
- Java 21 or higher
- Maven 3.8+
- Docker and Docker Compose
- Git
cd spring-shop-microservicesCreate a .env file in the root directory:
# Database Configuration
MONGO_USERNAME=mongodb
MONGO_PASSWORD=mongodb
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
# Email Configuration (for notifications)
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your_username
MAIL_PASSWORD=your_password
# Config Server (optional)
CONFIG_GIT_URI=https://github.com/yourusername/spring-shop-config.git
CONFIG_GIT_BRANCH=main
# Monitoring
GRAFANA_ADMIN_USER=admin
GRAFANA_ADMIN_PASSWORD=adminmvn clean package -DskipTestsdocker-compose up -dThis will start all services including:
- Infrastructure services (MongoDB, PostgreSQL, Kafka, Zookeeper)
- Application services (all microservices)
- Monitoring stack (Prometheus, Grafana)
Check that all services are running:
docker-compose psAccess the applications:
- API Gateway: http://localhost:8080
- Eureka Dashboard: http://localhost:8761
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/admin)
| Service | Port | Purpose |
|---|---|---|
| API Gateway | 8080 | Main entry point |
| Product Service | 8081 | Product management |
| Inventory Service | 8082 | Stock management |
| Order Service | 8083 | Order processing |
| Notification Service | 8084 | Email notifications |
| Service Discovery | 8761 | Eureka server |
| Config Server | 8888 | Configuration management |
| Prometheus | 9090 | Metrics collection |
| Grafana | 3000 | Monitoring dashboard |