A scalable, cloud-native eCommerce backend built with Java and Spring Boot microservices. This project features modular services for products, orders, payments, customers, notifications, and more—leveraging service discovery, centralized configuration, and robust messaging for modern distributed architectures.
- Product Service: Manage product catalog with PostgreSQL and Flyway migrations.
- Order Service: Place and track orders, integrates with product, payment, and customer services.
- Payment Service: Handles payment processing and status updates.
- Customer Service: Manages customer data using MongoDB.
- Notification Service: Sends email notifications (MailDev for dev), listens to Kafka events.
- Service Discovery: Eureka server for dynamic service registration and lookup.
- API Gateway: Centralized routing and load balancing for all APIs.
- Centralized Config: Spring Cloud Config Server for unified configuration management.
- Event-Driven: Kafka for asynchronous communication between services.
- Database Admin UIs: pgAdmin and Mongo Express for DB management.
- Dockerized: All services and dependencies orchestrated via Docker Compose.
- Java 17
- Spring Boot 3.5+ (Web, Data JPA, Data MongoDB, Validation, Mail, Thymeleaf)
- Spring Cloud (Eureka, Config Server, OpenFeign, Gateway)
- PostgreSQL & MongoDB
- Kafka (Confluent Platform)
- Docker & Docker Compose
- JUnit 5 (Testing)
- Lombok (Boilerplate reduction)
- Flyway (DB migrations)
- pgAdmin, Mongo Express, MailDev
This project follows a microservices architecture:
- Service Discovery: All services register with Eureka for dynamic discovery.
- API Gateway: Routes external requests to internal services, supports load balancing and path-based routing.
- Config Server: Centralizes configuration for all services, loaded at startup.
- Inter-Service Communication: REST (via OpenFeign) and asynchronous messaging (Kafka).
- Persistence: PostgreSQL for transactional data (orders, products, payments), MongoDB for customer and notification data.
- Notifications: Kafka events trigger email notifications via the notification service.
Service Communication Diagram:
[Client] → [API Gateway] → [Product/Order/Payment/Customer Services]
↑ ↓
[Eureka Discovery]
↑ ↓
[Config Server] [Kafka]
↑ ↓
[PostgreSQL/MongoDB] [Notification Service]
springbootEcommerceapp/
│
├── docker-compose.yml
└── services/
├── config.server/ # Spring Cloud Config Server
├── customer/ # Customer microservice (MongoDB)
├── discovery/ # Eureka Service Discovery
├── gateway/ # API Gateway
├── notification/ # Notification microservice (Kafka, Mail)
├── order/ # Order microservice (PostgreSQL, Kafka)
├── payment/ # Payment microservice (PostgreSQL, Kafka)
└── product/ # Product microservice (PostgreSQL)
-
Clone the repository:
git clone https://github.com/yourusername/springbootEcommerceapp.git cd springbootEcommerceapp -
Configure Environment:
- All service configs are managed via
services/config.server/src/main/resources/configurations. - For local overrides, edit
services/config.server/src/main/resources/application.ymlin each service or use Docker Compose environment variables.
- All service configs are managed via
-
Start Infrastructure with Docker Compose:
docker-compose up -d
This will start:
- PostgreSQL, MongoDB, Kafka, Zookeeper
- pgAdmin, Mongo Express, MailDev
- (You can now run the Spring Boot services)
-
Build and Run Microservices:
In each service directory (e.g.,
services/product):./mvnw clean package java -jar target/*.jarOr use your IDE to run each service.
-
API Gateway:
Access all APIs via the gateway at http://localhost:8222.- Example:
GET /api/v1/products→ routed to Product Service
- Example:
-
Service Endpoints:
Service Base URL (via Gateway) Product /api/v1/productsOrder /api/v1/ordersPayment /api/v1/paymentsCustomer /api/v1/customersNotification Internal (Kafka, Email) -
Swagger UI:
Add Swagger/OpenAPI to each service for interactive API docs (recommended). -
Database Admin:
- pgAdmin: http://localhost:5050
- Mongo Express: http://localhost:8081
-
MailDev (Email Testing):
http://localhost:1080
-
Unit & Integration Tests:
Each service includes tests using JUnit 5 and Spring Boot Test. Run tests with:./mvnw test -
Test Coverage:
Add plugins like JaCoCo for coverage reports.
Example: Create Product (POST /api/v1/products)
{
"name": "Wireless Mouse",
"description": "Ergonomic wireless mouse",
"price": 29.99,
"quantity": 100
}Example: Order Response
{
"orderId": 123,
"customerId": 1,
"orderLines": [{ "productId": 10, "quantity": 2 }],
"status": "CONFIRMED"
}- Add JWT-based authentication and role-based authorization
- Implement distributed tracing (Zipkin, Sleuth)
- Add Swagger/OpenAPI documentation to all services
- CI/CD pipeline for automated builds and deployments
- Horizontal scaling with Kubernetes
- Advanced monitoring (Prometheus, Grafana)
- Payment gateway integration (Stripe, PayPal)
Contributions, bug reports, and feature requests are welcome!
Please open an issue or submit a pull request.
This project is licensed under the MIT License.