https://github.com/1hashcode/employee-management-microservices
An Employee Management System with 5 microservice, build using Java, Spring boot and Docker. Implemented technologies like Grpc, Kafka, Docker, Jwt, Cloud Gateway.
https://github.com/1hashcode/employee-management-microservices
docker grpc java jwt-authentication kafka microservices-architecture postgresql repository-service spring-boot
Last synced: 2 months ago
JSON representation
An Employee Management System with 5 microservice, build using Java, Spring boot and Docker. Implemented technologies like Grpc, Kafka, Docker, Jwt, Cloud Gateway.
- Host: GitHub
- URL: https://github.com/1hashcode/employee-management-microservices
- Owner: 1HashCode
- License: mit
- Created: 2025-04-07T20:23:35.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2025-04-08T19:46:25.000Z (2 months ago)
- Last Synced: 2025-04-08T20:25:51.529Z (2 months ago)
- Topics: docker, grpc, java, jwt-authentication, kafka, microservices-architecture, postgresql, repository-service, spring-boot
- Language: Java
- Homepage:
- Size: 516 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: security-service/.gitattributes
Awesome Lists containing this project
README
# π¬ Employee Management System Microservices
---#### ποΈ A scalable and modular Employee Management System built using microservices architecture.
The system consists of 5 independently deployable services, documented with `OpenAPI`,
using `gRPC` for synchronous and `Kafka` for asynchronous messaging and containerized using `Docker` for easy orchestration and deployment.---
## β¨Key Highlights
- π Built secure and efficient `REST APIs` using Spring Boot with `JWT-based authentication`
- β‘ Employed `gRPC` for fast inter-service communication and π© `Apache Kafka` for asynchronous messaging
- π‘οΈ Created a centralized `API Gateway` to handle routing, security, and request forwarding across services
- π³ Used `Docker` to containerize each service and `Docker Compose` to orchestrate all services
- π’οΈ Leveraged `PostgreSQL` as the primary database, integrated via Docker containers
- π Documented each service using `OpenAPI (Swagger)` for easy collaboration and maintenance
- π§± Designed the system for scalability, security, and independent service deployment
---
## π§© Microservices Overview
The system follows a microservices architecture with independently deployable services, each having a specific responsibility:### π‘οΈ API Gateway
Click to Know More
- Acts as the entry point for all client requests.
- Uses a custom `GatewayFilter` to validate JWT tokens and forward requests securely to appropriate microservices.
- Ensures centralized security and request routing.### π Security Service
Click to Know More
- Handles authentication and authorization using JWT (JSON Web Tokens).
- Provides endpoints for token generation and validation.
- Persists authentication-related data in a PostgreSQL database (`security-service-DB`).### π¨βπΌ Employee Service
Click to Know More
- Responsible for CRUD operations on employee data.
- On creation of an employee:
- Sends a gRPC request to `performance-service` to create a performance record.
- Publishes an event on the Kafka `employee topic` for asynchronous processing.
- Uses PostgreSQL (`employee-service-DB`) for data persistence.
- On deletion of an employee:
- deletes the employee record from `employee-service-DB`
- Sends a gRPC request to `performance-service` to delete a performance record.### π Performance Service
Click to Know More
- Manages performance reviews of employees.
- Supports updating, retrieving performance data.
- Accepts gRPC calls from the `employee-service` for creation and deletion of performance record.
- Data is stored in PostgreSQL (`performance-service-DB`).### π HR Analytics Service (Demo Service)
Click to Know More
- Demonstrates event-driven microservice communication.
- Consumes create employee events from the Kafka `employee-topic`.
- Showcases real-time data syncing using Kafka-based message consumption.### ποΈ Databases & Message Brokers
This system uses Dockerized databases and Kafka for seamless integration and scaling.
Click to Know More
- #### ποΈ PostgreSQL Containers
Each core service has its own dedicated PostgreSQL database container:
- `security-service-DB` β Stores valid authenticated users from SQL script.
- `employee-service-DB` β Stores employee information and records.
- `performance-service-DB` β Stores performance-related data for employees.#### π Kafka Infrastructure
- Kafka Broker runs inside a container to handle real-time messaging.
- Maintains a topic named `employee-topic` which:
- Receives events from `employee-service` on employee creation.
- Is consumed by services like `hr-analytics-service` for analytics and further processing.---
## π§© Project Dependencies
This project uses a robust set of tools and libraries that enable secure, scalable, and maintainable development using the microservices architecture.
**Here's a breakdown of the core dependencies:**Click to Know More
- π₯οΈ Backend Frameworks & Libraries
- `Spring Boot` β Simplifies the bootstrapping and development of Spring-based applications with minimal configuration.
- `Spring DevTools` β Enables hot reloading and automatic restarts for a faster development experience.
- `Spring Security` β Provides comprehensive security features, including authentication, authorization, and protection against common vulnerabilities.
- `Spring Data JPA` β Simplifies database operations using Java Persistence API with minimal boilerplate code.
- `Spring Cloud Gateway` β A lightweight API Gateway built on Spring Boot for routing, filtering, and securing requests across services.
- `Spring Web` β Supports RESTful API development using Spring MVC.- π Security
- `Validation` β Ensures input data adheres to expected formats using annotations like @Valid and @NotNull.
- `JWT (JSON Web Token)` β Used for securely transmitting information between parties, especially for stateless authentication.
- β‘ Inter-Service Communication
- `Protobuf (Protocol Buffers)` β A language-neutral, platform-neutral extensible mechanism for serializing structured data (used in gRPC).
- `gRPC` β A high-performance, open-source universal RPC framework for inter-service communication.- π‘ Event Streaming
- `Kafka` β Used for distributed event streaming; enables asynchronous communication between microservices using topics.- π³ Containerization
- `Docker` β Containerizes each service for consistent environments across development and production.
- `Docker Compose` β Orchestrates multiple containers including microservices, databases, and Kafka broker using a single YAML file.- π οΈ Build & Dependency Management
- `Maven` β Handles project builds, dependencies, and plugin management using a centralized pom.xml.- π’οΈ Database & Drivers
- `PostgreSQL Driver` β JDBC driver for connecting to PostgreSQL databases used by microservices.- π API Documentation
- `OpenAPI / Swagger` β Automatically generates interactive API documentation for REST endpoints.---
## Architecture Diagram
---
## π¬ API Documentation Snapshot
This image showcases the OpenAPI (Swagger) documentation for the Employee Management System.
It provides a visual overview of the available REST endpoints, request/response structures, and service contracts for each microservice.
The documentation is generated automatically and helps developers and testers interact with the APIs efficiently during development and debugging.### Auth Requests
### Employee Requests
### Performance Requests
---
## π¬ API Request Collection with Postman
A complete and well-structured Postman collection (`Employee_Management_Service_API_Requests.postman_collection.json file`) is included in the project. It contains all the necessary API requests categorized by service, making it easy for developers or testers to interact with the system's endpoints quickly.
Simply import the collection into Postman and start testing the microservices seamlessly.---
## π³ Docker Compose Integration
`Docker Compose` is used to streamline the orchestration of all microservices, supporting containers, and environments required for this project. It allows us to define and manage multiple containers in a single `YAML` file, ensuring all services start in the correct order with appropriate configurations and ports.### β Services Managed via docker-compose.yml:
- API Gateway
- Security Service
- Employee Service
- Performance Service
- HR Analytics Service
- PostgreSQL Containers:
- security-service-DB
- employee-service-DB
- performance-service-DB
- Kafka Broker with employee-topicβΆοΈ Running the Entire Project:
To build and start all services, run:docker-compose up --build
This command:
- Builds all the images defined in the docker-compose.yml
- Creates the containers
- Runs them concurrently with appropriate networks, environment variables, and port mappingsTo stop all running containers:
docker-compose down---
## π οΈSteps to Run the Project From GitHub
1. Clone the Repository
git clone https://github.com/your-username/your-repo.git
cd your-repo2. Make Sure Docker and Docker Compose Are Installed
docker --version
docker-compose --version3. Turn on the docker engine
4. Run the Whole Project with Docker Compose
docker-compose up --build5. Import the project's Postman collection into Postman to access ready-made requests.
6. Stop the Project (when done)
docker-compose down---