Skip to content

Dynamic loading in Microservices Architecture refers to the ability to load, initialize, and integrate services or components at runtime rather than at compile-time or startup.

License

Notifications You must be signed in to change notification settings

vijayagopalsb/spring-dynamic-microservices

Repository files navigation

Quality Gate Status Maintainability Reliability Security Coverage Badge

Spring Dynamic Microservices

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.

Architecture Overview

  • 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.

Project Structure

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

Architecture Diagram

Modules

  • 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.

DevOps, CI/CD & Quality Tools

| Tool          | Purpose                        |
|---------------|--------------------------------|
| GitHub Actions| CI/CD pipeline                 |
| Docker        | Containerization               |
| Docker Compose| Multi-container orchestration  |
| JaCoCo        | Test coverage reports          |
| SonarCloud    | Code quality, static analysis  |

Testing

  • 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

Run Locally with Docker Compose

Tech Stack
  • Java 17
  • Spring Boot 3.2.5
  • Spring Cloud Gateway
  • Eureka Server (Netflix OSS)
  • RESTful APIs
  • Maven
  • Docker & Docker Compose
Running with Docker Compose
git clone https://github.com/vijayagopalsb/spring-dynamic-microservices.git
cd spring-dynamic-microservices
mvn clean package -DskipTests
docker-compose up --build

Service Access URLs

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 Workflow

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

SonarCloud Dashboard

View real-time static analysis and code coverage:

Author

Vijayagopal S
GitHub
LinkedIn

License

This project is licensed under the MIT License.

Releases

No releases published

Packages

No packages published