How omarelbeggar/microservices-project works
Project Type and Purpose
• This is a microservices-based system.
• The project includes four key microservices: Client-SERVICE, Commande-SERVICE, Discovery-SERVICE, and Gateway-SERVICE.
• The README tells you that the services communicate via RESTTEMPLATE (HTTP REST calls) and that there are two databases (Postgres) used by two of the services. In the client database (clientdb), there is a “client” table, and in the commande database (commandedb), there is a “commande” table.
• Each microservice is structured as a Maven project with its own configuration, controllers, service layers, and repositories, indicating a typical layered architecture.
Analyzing the File Structure for Architectural Patterns
• Each service (e.g., client-service, commande-service) has a similar Maven-based file structure indicating separation of concerns:
• /src/main/java contains controllers, business objects (bo), configurations, DTOs, services, mappers, repositories, and sometimes exception handlers.
• /src/main/resources holds configuration files (notably, application.properties with DB connections).
• The project also includes test directories, build files, and helper scripts (mvnw, mvnw.cmd) that ensure consistency in builds.
• There is also an external directory in both microservices that might indicate outbound REST calls (e.g., to exchange data with other services).
• Main Components – include:
• Client-SERVICE: Manages clients, containing its own MVC-like structure (Controller, BO, DTO, Service, Repository, and external communication objects).
• Commande-SERVICE: Manages orders (commande), similarly structured to deal with business operations.
• Discovery-SERVICE: Likely acts as a service registry (e.g., Eureka, if assumed by naming) to enable service discovery within the microservices ecosystem.
• Gateway-SERVICE: Acts as the API gateway that routes requests to appropriate services and handles cross-cutting concerns (like authentication, load balancing, etc.).
• Databases: Representing two distinct Postgres DB instances, one for clientdb (with a “client” table) and one for commandedb (with a “commande” table).
• Relationships and Interactions:
• The Gateway-SERVICE forwards incoming requests from clients to the respective microservice.
• The microservices (Client-SERVICE and Commande-SERVICE) communicate among each other using RESTTEMPLATE calls.
• Discovery-SERVICE enables the microservices to register themselves as available and to discover other services to call.
• Each microservice connects to its designated database using configurations from application.properties.
• Important Architectural Highlights:
• Microservices architecture with service discovery and an API gateway.
• A layered structure in each service (Controller, Service, Repository, etc.).
• Communication using synchronous HTTP REST calls (via RESTTEMPLATE).
• Database separation between services ensuring data encapsulation.
• Use of Maven for builds and standard Java project structure.