How rebeldecuantico/online-store-ddd works
Main Components
• Catalog Service: This is the core business module where products and categories are managed. It includes:
• API layer (CategoryController.cs, ProductController.cs) that exposes endpoints.
• Application layer (commands, queries, DTOs, and event handlers) responsible for business use cases.
• Domain layer (entities such as Category, Product, available stock, Price, etc.) encapsulating business logic.
• Infrastructure layer (repositories, Entity Framework context, entity type configurations, diagnostics, and database migrations) that implements persistence and integration with PostgreSQL and Redis (as indicated in the Settings files).
• Workers (like CatalogWorker.cs) which may perform background tasks.
• Reverse Proxy Service: This acts as the API gateway for the Online Store.
• It contains routing extensions, security components for token handling, service discovery integrations, and a worker (ServiceDiscoveryWorker.cs) for dynamic configurations.
• Its configuration and settings (e.g., OpenIdConnectSettings) are critical for managing authentication, likely integrating with IDP/SSO components.
• Config Server:
• Located under src/configserver, this is a Java-based service (Maven project with pom.xml) that serves as a central configuration management system, delivering configuration settings to the other services.
• This is an example of externalized configuration in a microservices ecosystem.
• Common Library:
• Shared code, contracts, and abstractions that support DDD practices (e.g., Domain/ Entity, AggregateRoot, UnitOfWork) across the solution.
• Contains shared infrastructure pieces (Kafka producer/consumer, service bus implementations, logging facilities, service discovery integration via Consul, etc.).
• Docker and DevOps Components:
• Docker-compose and configuration files in the docker folder indicate that the project is containerized.
• Configuration files such as fluent-bit.conf, grafana-datasources.yaml, loki-config.yaml, otel-collector-config.yaml, parsers.conf, and prometheus.yml suggest integrated logging, monitoring (Prometheus, Grafana), and observability (OpenTelemetry) features.
Relationships and Interactions
• Frontend requests (not explicitly shown, but assumed to come via the Reverse Proxy) are accepted by the Reverse Proxy service which handles routing and security verification.
• Reverse Proxy routes incoming API calls to the appropriate backend service – mainly the Catalog service for product and category-related operations.
• The Catalog service’s API layer then orchestrates application logic by invoking the Application layer, which executes commands/queries.
• Domain events (e.g., CategoryAdded, PriceChanged, etc.) trigger side effects and are managed internally to ensure business rules adhere to the DDD model.
• Persistence is handled by the Infrastructure layer via a database context with migrations—for example, PostgreSQL for data storage and Redis for caching.
• The Common library facilitates reusable abstractions (like service discovery, messaging through Kafka, and unit-of-work patterns) that underpin service-to-service communications and distributed system concerns.
• The Config server supplies centralized configurations to the various services, enabling consistent and dynamic configuration management.
• Docker and associated configuration files serve as the bridge for container orchestration, ensuring that logging, metrics, and monitoring are available for operational insights.
Architectural Patterns and Design Principles
• Domain-Driven Design is the most obvious guiding principle with clearly separated layers – Domain, Application, and Infrastructure.
• Microservices (or at least service separation): Catalog, Reverse Proxy, and Config Server appear as autonomous components.
• API Gateway pattern is implemented by the Reverse Proxy for centralized request routing.
• Infrastructure concerns (logging, caching, message queuing, service discovery) are abstracted into shared components in the Common library.
• Containerization with Docker ensures that each service can be developed, deployed, and scaled independently with the help of external configuration management, observability, and monitoring tools.
Final Recommendations for the Principal Software Engineer
• Client → Reverse Proxy → Catalog API
• Domain events internally in the Catalog service.
• Persistence flows between the Catalog service and PostgreSQL/Redis.
• Configuration flows from Config Server to all services.
This approach will help capture the full stack architecture of the online store project and provide detailed insight into how the system is organized with a focus on DDD principles and modern distributed system design.