Table of Contents
-
- Optimize parking space management using IoT and AI.
- Reduce search time, minimize traffic congestion, and decrease environmental impact.
-
- Overview of the system's key components.
-
- Config Server: Manages centralized configuration for all microservices.
- Eureka Server: Service discovery and registration.
- API Gateway: Routes client requests to microservices.
- Microservices: Handles parking management, user management, reservation management, and membership management.
-
- Visual representation of the system architecture.
-
- Configuration retrieval, service registration, and request routing.
-
- List of technologies: Spring Boot, Spring Cloud, Docker, PostgreSQL, Feign Client.
-
- API Gateway: Entry point for all requests.
- Config Server: Centralized configuration management.
- Eureka Server: Service registry and discovery.
- Communication Between Microservices: Use of Feign Client.
-
- Steps to set up and run the project.
-
- Instructions to start all microservices.
The Intelligent Parking Management System aims to optimize parking space management in urban areas using IoT technologies and AI algorithms. The project reduces the time spent searching for parking spots, minimizes traffic congestion, and decreases environmental impact through the use of sensors and voice recognition.
- Config Server: Manages centralized configuration for all microservices.
- Eureka Server: Discovery service that allows microservices to register and discover each other.
- API Gateway: Handles all client requests and routes them to the appropriate microservices.
- Microservices:
- Parking Management: Manages information about parking lots and available spots.
- User Management: Handles user information and roles.
- Reservation Management: Manages parking space reservations by users.
- Membership Management: Administers memberships and additional features offered to users.
- Config Server: All microservices retrieve their configuration from the Config Server at startup.
- Eureka Server: All microservices register with the Eureka Server for discovery.
- API Gateway: Receives client requests and routes them to the appropriate microservices based on the path.
- Microservices:
- User Management can communicate with Membership Management using Feign Client to fetch memberships for a specific user.
- Spring Boot: Main framework for developing microservices.
- Spring Cloud: Includes Config Server, Eureka Server, and API Gateway.
- Docker: Containerization of applications and databases.
- PostgreSQL: Database management system used for each microservice.
- Feign Client: Inter-microservice communication.
The API Gateway serves as the entry point for all client requests. It routes these requests to the appropriate microservices and handles authentication, authorization, and other cross-cutting concerns such as rate limiting and logging.
The Config Server centralizes the configuration of all microservices. This allows for easier management and updating of configurations without the need to redeploy the services. Configurations are stored in a central repository and fetched by the microservices at runtime.
The Eureka Server acts as a service registry and discovery server. It keeps track of all available microservices and their instances, enabling load balancing and failover mechanisms. Microservices register themselves with the Eureka Server at startup and periodically send heartbeats to indicate their availability.
Microservices communicate with each other using RESTful APIs. The API Gateway routes incoming requests to the appropriate microservice. Internal communication between microservices is facilitated using Feign clients, which provide a declarative way of defining REST clients in Spring Boot.
- Docker and Docker Compose installed.
- JDK 17 installed.
spring-microservices/
├── config-server/
├── eureka-server/
├── api-gateway/
├── microservice-parking-management/
├── microservice-users/
├── microservice-reservations/
├── microservice-memberships/
├── docker-compose.yml
└── README.md
Each database has an initialization .sql
file located in the ./init
directory. These files are copied to the /docker-entrypoint-initdb.d/
directory in the PostgreSQL containers to create the necessary tables.
- GET
/api/parkings
: Retrieve all parking lots. - POST
/api/parkings
: Create a new parking lot.
- GET
/api/users
: Retrieve all users. - POST
/api/users
: Create a new user. - GET
/api/users/{id}/memberships
: Retrieve memberships for a user.
- GET
/api/reservations
: Retrieve all reservations. - POST
/api/reservations
: Create a new reservation.
- GET
/api/memberships
: Retrieve all memberships. - POST
/api/memberships
: Create a new membership.
The root pom.xml
file includes the configuration for all microservices as modules and manages common dependencies.
The root pom.xml
file lists all microservices as modules and includes common dependencies such as Spring Boot and Lombok.
Each microservice has its own pom.xml
file, inheriting from the root pom.xml
and specifying dependencies unique to that microservice.
-
Clone the repository:
git clone https://github.com/CarlosFULLHD/spring-microservices.git cd spring-microservices
-
Navigate to the docker-compose directory:
cd spring-microservices/docker-compose
-
Build and start the containers:
docker-compose up -d
-
Verify the containers are running:
docker-compose ps
Once you have started the Docker containers for the databases, you can proceed to run the microservices. Follow these steps:
-
Navigate to the root directory of the project:
cd spring-microservices
-
Build and package all the microservices:
mvn clean package
-
Start the Config Server:
cd config-server mvn spring-boot:run
-
Start the Eureka Server:
Open a new terminal window and navigate to the Eureka Server directory:
cd eureka-server mvn spring-boot:run
-
Start the API Gateway:
Open another new terminal window and navigate to the API Gateway directory:
cd api-gateway mvn spring-boot:run
-
Start the Microservices:
For each microservice (Parking Management, User Management, Reservation Management, Membership Management), open a new terminal window and navigate to the respective directory, then run the service:
# Parking Management Service cd microservice-parking-management mvn spring-boot:run # User Management Service cd microservice-users mvn spring-boot:run # Reservation Management Service cd microservice-reservations mvn spring-boot:run # Membership Management Service cd microservice-memberships mvn spring-boot:run