This is a comprehensive Java-based microservices system built with Spring Boot 3.x and Spring Cloud. It demonstrates dynamic service registration, routing, and payment processing using a modular architecture. The project includes CI integration with GitHub Actions and code quality checks with SonarCloud and JaCoCo.
- eureka-server: Acts as the service registry for all microservices.
- gateway-service: A Spring Cloud Gateway-based API Gateway that routes requests dynamically to microservices.
- payment-service-paypal: A microservice simulating PayPal payment logic, registered with Eureka.
- payment-service-stripe: A microservice simulating Stripe payment logic, registered with Eureka.
- docker-compose.yml: Boots up all services with required ports and network for full-stack integration.
All services are auto-discovered via Eureka and routed through Spring Cloud Gateway without hardcoded endpoints.
spring-dynamic-microservices/
│
├── common-api/ # Common library for shared DTOs and configs
├── eureka-server/ # Service registry
├── gateway-service/ # API Gateway
├── payment-service-paypal/ # Paypal payment microservice
├── payment-service-stripe/ # Stripe payment microservice
├── docker-compose.yml # Multi-container setup
└── README.md
common-api
– Shared domain objects, constants, and utilities.eureka-server
– Service discovery server powered by Netflix Eureka.gateway-service
– Spring Cloud Gateway for dynamic routing and API exposure.payment-service-paypal
– PayPal-specific payment microservice.payment-service-stripe
– Stripe-specific payment microservice.
| Tool | Purpose |
|---------------|--------------------------------|
| GitHub Actions| CI/CD pipeline |
| Docker | Containerization |
| Docker Compose| Multi-container orchestration |
| JaCoCo | Test coverage reports |
| SonarCloud | Code quality, static analysis |
- Unit testing with JUnit 5
- Controller testing using Spring’s
MockMvc
- Code coverage with JaCoCo (
target/site/jacoco/index.html
) - Test reports pushed to SonarCloud
- Java 17
- Spring Boot 3.2.5
- Spring Cloud Gateway
- Eureka Server (Netflix OSS)
- RESTful APIs
- Maven
- Docker & Docker Compose
git clone https://github.com/vijayagopalsb/spring-dynamic-microservices.git
cd spring-dynamic-microservices
mvn clean package -DskipTests
docker-compose up --build
Here are the main endpoints for accessing services in this dynamic microservices project:
| Purpose | URL |
|----------------------------------|------------------------------------------------------------------|
| Eureka Dashboard | [http://localhost:8761](http://localhost:8761) |
| PayPal Service (Direct Access) | [http://localhost:8082/hello](http://localhost:8082/hello) |
| PayPal via Gateway | [http://localhost:8090/payment-service-paypal/hello] |
| | (http://localhost:8090/payment-service-paypal/hello) |
| Stripe Service (Direct Access) | [http://localhost:8083/hello](http://localhost:8083/hello) |
| Stripe via Gateway | [http://localhost:8090/payment-service-stripe/hello] |
| | (http://localhost:8090/payment-service-stripe/hello) |
| Gateway Test Route | [http://localhost:8090/test/get](http://localhost:8090/test/get) |
CI is triggered on push to main
:
- Builds all modules
- Runs tests
- Sends coverage to SonarCloud
- Builds Docker images
- Pushes to DockerHub (if configured)
CI file: .github/workflows/ci-all.yml
View real-time static analysis and code coverage:
This project is licensed under the MIT License.