This project is a basic implementation of a job portal using a microservices architecture. The system consists of several microservices, each handling different aspects of the job portal, including job postings, companies, and company reviews. This README provides an overview of the entire system and links to the individual microservices repositories for more detailed information.
The job portal is composed of the following microservices and repositories:
Service | Description | Repository URL |
---|---|---|
Jobs Service | Manages job postings, including creating, updating, deleting, and retrieving job listings. | Jobs Service Repo |
Companies Service | Manages company information, including creating, updating, deleting, and retrieving company data. | Companies Service Repo |
Reviews Service | Manages reviews for companies, including creating, updating, deleting, and retrieving reviews. | Reviews Service Repo |
Service Registry | Implements service discovery using Spring Cloud Eureka for dynamic service registration. | Service Registry Repo |
API Gateway | Uses Spring Cloud Gateway to route requests to the appropriate microservice. | API Gateway Repo |
Config Server | Centralized configuration management for all microservices using Spring Cloud Config. | Config Server Repo |
Application Configuration Repo | Stores configuration properties for different environments. | Configuration Repo |
The system follows a microservices architecture, where each microservice is responsible for a specific domain of the job portal. Here is a brief description of each service:
The Jobs Service handles all operations related to job postings. It provides RESTful APIs to create, update, delete, and retrieve job listings.
The Companies Service manages company-related information. It provides APIs to manage company profiles and details.
The Reviews Service is responsible for managing company reviews. It includes functionalities to add, update, delete, and fetch reviews for companies.
The Service Registry uses Spring Cloud Eureka for service discovery. It allows microservices to register themselves at runtime and to discover other registered services.
The API Gateway uses Spring Cloud Gateway to route requests to the appropriate microservice. It acts as a single entry point for all client requests.
The Config Server provides centralized configuration management for all microservices. It retrieves configuration properties from the Configuration Repository.
This repository contains the configuration properties for different environments. The Config Server fetches these properties to configure the microservices accordingly.
This project utilizes several tools and technologies to enhance the functionality and reliability of the system:
- PostgreSQL: Used as the database for all microservices.
- Docker: Used to run PostgreSQL, pgAdmin, and Zipkin in containers.
- Distributed Tracing: Using Zipkin and Micrometer for tracing and monitoring requests across microservices.
- OpenFeign: For declarative REST client to simplify HTTP communication between microservices.
- Fault Tolerance and Circuit Breaker: Implemented using Resilience4j to handle failures gracefully and ensure system resilience.
- Kubernetes: Used for container orchestration and deployment.
There are three ways to run the Job Portal application:
For development purposes, you can start the PostgreSQL, RabbitMQ, and Zipkin server on Docker containers, and run other microservices from IntelliJ:
To get the codebase:
- Download all the microservices using the
download.sh
file. - Open each project in IntelliJ as a Maven project.
- Ensure Docker is installed and running on your machine.
- Navigate to the directory containing the
docker-compose.yaml
file. - Bring up the Docker instances for PostgreSQL, pgAdmin, and Zipkin.
docker compose up -d postgres rabbitmq zipkin
The following Docker containers are used in this project:
Service | Container Name | Image | Host Port | Container Port |
---|---|---|---|---|
Postgres | postgres | postgres | 5000 | 5432 |
pgAdmin | pgadmin | dpage/pgadmin4 | 5050 | 80 |
Zipkin | zipkin | openzipkin/zipkin | 9411 | 9411 |
Run the applications in the following order in IntelliJ:
Order | Service Name | Port | Gateway URL |
---|---|---|---|
1. | Service Registry | 8761 | http://localhost:8085/eureka/main |
2. | Config Server | 8080 | N/A |
3. | API Gateway | 8085 | N/A |
4. | Job Microservice | 8082 | http://localhost:8085/jobs |
5. | Company Microservice | 8083 | http://localhost:8085/companies |
6. | Review Microservice | 8084 | http://localhost:8085/reviews |
- Service Registry: Accessible on localhost:8761 or via the API Gateway.
- Config Server: Accessible on localhost:8080.
- API Gateway: Accessible on localhost:8085.
- Job Microservice: Accessible on localhost:8082 or via the API Gateway at /jobs.
- Company Microservice: Accessible on localhost:8083 or via the API Gateway at /companies.
- Review Microservice: Accessible on localhost:8084 or via the API Gateway at /reviews.
You can run all the services using Docker. This involves using Spring Boot's automatic Docker image creation and pushing the images to your server.
-
Ensure Docker is installed and running on your machine.
-
Create Docker image for each microservice
./mvnw spring-boot:build-image "-Dspring-boot.build-image.imageName=<username>/<service-name>"
- Push the image to docker hub
docker push <username>/<service-name>
Run the above command for all the services. Please use below service names or if you are using different names please update it in docker-compose.yaml
file.
- servicereg
- config-server-ms
- gateway-ms
- jobms
- companyms
- reviewms
- Navigate to the directory containing the docker-compose.yaml file.
- Start all the services:
docker compose up -d
You can also deploy the application using Kubernetes. For this, you need to install Minikube and use the Kubernetes configuration files to start all services.
- Install minikube from here
- Start Minikube
minikube start --driver=docker
- Open minikube dashboard to see the details
minikube dashboard
- Apply the kubernetes configuration files to start each services.
kubectl apply -f service/postgres
kubectl apply -f service/rabbitmq
kubectl apply -f service/zipkin
kubectl apply -f bootstrap/job
kubectl apply -f bootstrap/company
kubectl apply -f bootstrap/review
- Run the command to get url for each service to start using
minikube service <service-name> --url
For example
minikube service job --url