A scalable, event-driven microservices architecture for an e-commerce platform built with Spring Boot and Spring Cloud.
- Product Service: Product catalog management with MongoDB
- Inventory Service: Real-time inventory tracking with MySQL
- Order Service: Order processing with event-driven architecture
- Notification Service: Email notifications for order updates
- API Gateway: Single entry point with request routing and load balancing
- Event-Driven Architecture: Apache Kafka for asynchronous communication
- Containerized: Docker and Docker Compose for easy deployment
- API Documentation: Integrated Swagger UI for all services
- Java 21
- Spring Boot 3.3.12
- Spring Cloud 2023.0.5
- Spring Data MongoDB & JPA
- Spring Kafka
- Docker & Docker Compose
- MySQL 8.3.0
- MongoDB 7.0.5
- Apache Kafka 7.5.0
- OpenAPI 3.0
- Java 21 or later
- Docker Desktop (with Docker Compose)
- Maven 3.9.x or later
- Git
-
Clone the repository
git clone <repository-url> cd spring-boot-microservices
-
Build the project
mvn clean install
-
Start the services
docker-compose up -d
This will start all services and required infrastructure (Kafka, MySQL, MongoDB, etc.)
-
Verify services are running
docker-compose ps
Service | URL | Port |
---|---|---|
API Gateway | http://localhost:8080 | 8080 |
Product Service | http://localhost:8081 | 8081 |
Order Service | http://localhost:8083 | 8083 |
Inventory Service | http://localhost:8082 | 8082 |
Notification Service | http://localhost:8084 | 8084 |
Kafka UI | http://localhost:8086 | 8086 |
Access Swagger UI for API documentation:
- API Gateway (All Services): http://localhost:8080/swagger-ui.html
- Product Service: http://localhost:8081/swagger-ui.html
- Order Service: http://localhost:8083/swagger-ui.html
- Inventory Service: http://localhost:8082/swagger-ui.html
To run tests for all services:
mvn test
For individual service tests, navigate to the service directory and run:
cd <service-directory>
mvn test
.
├── api-gateway/ # API Gateway service
├── product-service/ # Product management service
├── order-service/ # Order processing service
├── inventory-service/ # Inventory management service
├── notification-service/ # Notification service
├── docker-compose.yml # Docker Compose configuration
└── README.md # This file
- Synchronous: REST APIs (HTTP/HTTPS)
- Asynchronous: Apache Kafka for event-driven communication
Each service has its own configuration in application.yml
. For local development, you can override settings using environment variables in docker-compose.yml
.
To debug a specific service:
-
Stop the service in Docker:
docker-compose stop <service-name>
-
Run the service locally with debug mode:
cd <service-directory> mvn spring-boot:run -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
-
Attach your IDE's debugger to port 5005
To stop and remove all containers, networks, and volumes:
docker-compose down -v
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with ❤️ using Spring Boot and Spring Cloud
- Thanks to all open-source projects used in this project