How devmentors/group-flights-ddd works
Project type and purpose
• This is a .NET-based modular monolith implementing a group flight booking system (“GroupFlights”) using Domain-Driven Design.
• It consists of multiple bounded contexts (Inquiries, Sales, Backoffice, Finance, Postsale, TimeManagement, WorkloadManagement, Communication) plus a central API gateway and shared libraries.
• Purpose: handle the end-to-end process of group flight inquiries, offer creation, reservation, contract generation, payment, post-sale changes and associated deadlines/workload management.
File structure
• src/Api/GroupFlights.Api: the HTTP gateway, routes requests to modules.
• src/[Module]/ (e.g. Inquiries, Sales, Finance, etc.): each contains
• Api project: exposes REST endpoints
• Core project: domain model, services, repositories, DTOs
• Shared project: integration contracts (ModuleApi, Shared DTOs, IntegrationEvents)
• Infrastructure (for some): EF Core configurations, DB contexts, migrations
• src/Shared/GroupFlights.Shared.Plumbing: in-memory command/event/query dispatcher, user-context.
• src/Shared/GroupFlights.Shared.ModuleDefinition: endpoint registration, shared contracts.
• src/_ExternalSystems: FakePaymentGateway emulating an external payment service.
• docker-compose.yml and SQL scripts configure a Postgres database with separate schemas per module.
• No external message broker: modules integrate via in-memory event dispatcher.
Key architectural insights from README
• Modular monolith with separate schemas for each module in a single Postgres instance.
• Integration patterns: synchronous REST (shared contracts) and asynchronous in-memory events with deliberate delivery delays.
• Each module may implement one of three persistence styles: JSON-serialized aggregates, CRUD, or rich domain model with EF.
• Commands/Queries separation, Clean Architecture in non-trivial modules.
Main components
A. API Gateway (GroupFlights.Api)
B. Bounded Context Modules (each deployed within the same process):
1. Inquiries
2. Sales
3. Backoffice
4. Finance
5. Postsale
6. TimeManagement
7. WorkloadManagement
8. Communication
C. Shared Libraries (Plumbing, ModuleDefinition, Types)
D. Database (Postgres with multiple schemas)
E. External Payment Gateway (FakePaymentGateway)
F. Clients: Web/Console users issuing HTTP calls (via .http scenario files)
Relationships and interactions
• Clients → API Gateway: HTTP/JSON requests with header-based naive auth (X-UserId, X-CashierId).
• Gateway → Module APIs: routes to the correct module based on URL path.
• Module APIs → Core: each module’s API calls its Core services/repositories.
• Core → Database: using EF Core (per-module DbContext) or JSON storage.
• Core → Shared Plumbing: dispatch commands/queries/events in-memory.
• Event Flow: e.g., Sales emits ContractGenerationRequested → Backoffice handles it → Backoffice emits ContractSignedIntegrationEvent → Sales/Postsale react → TimeManagement schedules deadlines → modules react to DeadlineOverdueIntegrationEvent, etc.
• External Calls: Finance calls FakePaymentGateway REST; FakePaymentGateway pushes back a payment-completed webhook.
• WorkloadManagement: tracks and validates cashier workload assignments.
• Communication: publishes messages (console email simulation).
Architectural patterns and principles
• Modular Monolith: modules are independent at the code and DB schema level but run in one process.
• Bounded Contexts with Clear APIs and Integration Events.
• Clean Architecture in complex modules: separation between Api, Application (commands/queries), Domain (entities, value objects), Infrastructure.
• CQRS-style separation between command handlers and query handlers.
• In-Memory Event Bus: for eventual consistency and async flows without external broker.
• Schema-per-Module: isolation of data stores.