This project demonstrates the evolution of a monolithic application into a distributed system using a microservices architecture. It serves as a practical example for learning about service decomposition, service discovery, centralized security, and routing.
For a detailed explanation of the architecture and workflow, please see the USER_GUIDE.md.
This project is composed of four core modules. See the README in each module's directory for more specific details.
discovery-server: A Netflix Eureka server that acts as the service registry.gateway-service: The single entry point for all requests. It handles routing, security (JWT validation), and other cross-cutting concerns.employee-service: Manages core employee data and exposes the login endpoint.payroll-service: Manages detailed employee salary and payroll data.
- Java 21 & Spring Boot 3
- Spring Cloud Gateway for API Routing
- Spring Cloud (Netflix Eureka) for Service Discovery
- Spring Security (with JWT) for Authentication
- Spring Data MongoDB for Data Persistence
- Maven for Build Management
- Java Development Kit (JDK) 21
- Apache Maven
- MongoDB
Build all modules by running the following command from the project root directory:
mvn clean installYou must run the services in the correct order. Open four separate terminals.
Terminal 1: Start the Discovery Server
cd discovery-server
java -jar target/discovery-server-0.0.1-SNAPSHOT.jarWait for it to start (on port 8761).
Terminal 2: Start the Employee Service
cd employee-service
java -jar target/employee-service-0.0.1-SNAPSHOT.jarThis service will register with Eureka (on port 8082).
Terminal 3: Start the Payroll Service
cd payroll-service
java -jar target/payroll-service-0.0.1-SNAPSHOT.jarThis service will also register with Eureka (on port 8081).
Terminal 4: Start the API Gateway
cd gateway-service
java -jar target/gateway-service-0.0.1-SNAPSHOT.jarThis is the single entry point for the system (on port 8080).
Once all services are running, the system is fully operational. All API requests should be made to the gateway on port 8080.