https://github.com/gifflet/spring-cloud-microservices
Spring Cloud powered microservices utilizing Eureka, Gateway LoadBalancer, Open Feign, RabbitMQ, KeyCloak and Docker
https://github.com/gifflet/spring-cloud-microservices
docker docker-compose eureka feign keycloak mapstruct microservices rabbitmq spring-boot spring-cloud
Last synced: 9 months ago
JSON representation
Spring Cloud powered microservices utilizing Eureka, Gateway LoadBalancer, Open Feign, RabbitMQ, KeyCloak and Docker
- Host: GitHub
- URL: https://github.com/gifflet/spring-cloud-microservices
- Owner: gifflet
- Created: 2024-01-10T03:27:00.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-08T20:01:49.000Z (about 1 year ago)
- Last Synced: 2025-01-31T11:49:40.677Z (11 months ago)
- Topics: docker, docker-compose, eureka, feign, keycloak, mapstruct, microservices, rabbitmq, spring-boot, spring-cloud
- Language: Java
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Cloud Microservices Project
## Overview
This project is a collection of microservices built using Spring Boot, designed to demonstrate the capabilities of microservices architecture. The system consists of several services, including a client management service, a card management service, a credit assessment service, and a cloud gateway for routing requests. Each service is registered with a Eureka server for service discovery.
## Architecture
The architecture of the project is based on the following components:
- **Eureka Server**: Acts as a service registry for all microservices.
- **Clients Service**: Manages client information.
- **Cards Service**: Handles card-related operations.
- **Credit Assessment Service**: Evaluates the creditworthiness of clients.
- **Cloud Gateway**: Routes requests to the appropriate microservice.
## Technologies Used
- Spring Boot
- Spring Cloud
- Spring Data JPA
- RabbitMQ
- H2 Database (for development)
- Lombok
- MapStruct
- Feign Client
## Getting Started
### Prerequisites
- Java 17
- Maven
- Docker (optional, for running services in containers)
### Running the Application
You can run the application using Docker Compose. Make sure you have Docker installed and running, then execute the following command in the root directory of the project:
```bash
docker-compose up --build
```
This command will build and start all the microservices along with the RabbitMQ and Keycloak services.
### Accessing the Services
Once the services are up and running, you can access them through the Cloud Gateway. The default port for the gateway is `8080`.
## How to Use
### Client Management
1. **Create a Client**
To create a new client, send a POST request to the `/clients` endpoint:
```bash
curl -X POST http://localhost:8080/clients \
-H "Content-Type: application/json" \
-d '{
"cpf": "12345678900",
"name": "John Doe",
"age": 30
}'
```
2. **Find a Client by CPF**
To retrieve a client by their CPF, send a GET request to the `/clients` endpoint:
```bash
curl -X GET "http://localhost:8080/clients?cpf=12345678900"
```
### Card Management
1. **Create a Card**
To create a new card, send a POST request to the `/cards` endpoint:
```bash
curl -X POST http://localhost:8080/cards \
-H "Content-Type: application/json" \
-d '{
"name": "Visa",
"brand": "Visa",
"income": 5000,
"creditLimit": 1000
}'
```
2. **Get Cards by CPF**
To retrieve cards associated with a specific CPF, send a GET request to the `/cards` endpoint:
```bash
curl -X GET "http://localhost:8080/cards?cpf=12345678900"
```
### Credit Assessment
1. **Assess Credit**
To assess a client's credit, send a POST request to the `/credit-assessments` endpoint:
```bash
curl -X POST http://localhost:8080/credit-assessments \
-H "Content-Type: application/json" \
-d '{
"cpf": "12345678900",
"income": 3000
}'
```
2. **Get Customer Cards**
To retrieve the cards associated with a customer after assessment, send a GET request to the `/credit-assessments/customer-cards` endpoint:
```bash
curl -X GET "http://localhost:8080/credit-assessments/customer-cards?cpf=12345678900"
```
## Conclusion
This project demonstrates the integration of multiple microservices using Spring Cloud. Each service can be independently developed, deployed, and scaled, providing flexibility and resilience. For further customization and enhancements, feel free to explore the codebase and contribute!