How haunguyendev/microservices works
Main Components
• API Gateway: Represented by the “OcelotApiGw” service inside the src/ApiGateways directory. This component acts as the front door routing client requests to the appropriate microservice.
• Microservices: Each service is defined under the src/Service directory and includes:
– Basket API
– Customer API
– Hangfire API
– Inventory API
– Ordering API
– Product API
• Web Applications: Specifically, the WebHealthStatus project in src/WebApps which likely provides health/status monitoring or a simple UI.
• Building Blocks/Shared Libraries: These are in the src/BuildingBlocks section and provide cross-cutting concerns such as logging (Common.Logging), contracts (interfaces, domains, DTOs), infrastructure (repository and unit-of-work implementations), and shared functionalities.
• External Dependencies & Infrastructure: The project makes use of several Dockerized external services (e.g., RabbitMQ, Kibana, Portainer and possibly SQL Server/MySQL as databases) as described in the README.
Relationships and Interactions
• Clients initiate requests that first hit the API Gateway.
• The API Gateway routes calls to the corresponding microservices (e.g., requests for product data go to Product API, customer data to Customer API, etc.).
• Each microservice is responsible for its domain logic and interacts with the shared building blocks for cross-cutting concerns such as logging, data access (repository pattern), and messaging (event bus messages).
• There is likely an event-driven communication aspect (see “EventBus.Messages”) that enables asynchronous interactions between services.
• The WebHealthStatus application serves as a monitoring or status dashboard, possibly interacting with the other services to display system health.
• Docker Compose is used to manage the runtime environment, with containers for microservices and external applications.
Architectural Patterns and Design Principles
• Microservices Architecture: The system is split into discrete, independently deployable services.
• API Gateway Pattern: Ocelot serves this role by abstracting the complexity of the underlying microservices.
• Repository and Unit-of-Work Patterns: As seen in the building blocks (IRepositoryBaseAsync, UnitOfWork) and infrastructure directories, ensuring proper data handling.
• Shared Libraries: Common contracts and DTOs ensure consistency and reduce duplicated code.
• Containerization: Docker Compose is used for orchestration, suggesting container-based deployment.
• Asynchronous Messaging/Event Bus: Include messaging components that facilitate inter-service communication.
Relevant Technologies
• ASP.NET Core (.NET 6 from global.json)
• Docker (with docker-compose)
• Ocelot (API Gateway)
• Hangfire (for background tasks)
• Possibly Entity Framework Core for data access (evidenced by the existence of migrations and repository patterns)
• Logging via Serilog (developers can note the Serilogger in BuildingBlocks/Common.Logging)
• External tools: RabbitMQ, Kibana, and Portainer