How khaikenly/domain-driven-hexagon-research works
Main Components
• Application Interface / User-Facing Layer – includes HTTP controllers, CLI controllers, GraphQL resolvers (see files like create-user.http.controller.ts, create-user.cli.controller.ts, and create-user.graphql-resolver.ts).
• Application/Core Layer – encompasses the use case implementations (commands/queries and their corresponding services), application-specific logic (transactional orchestration, command and query buses) and the “ports” (interfaces for repositories, loggers, etc.).
• Domain Layer – contains entities and aggregates (e.g., user.entity.ts and wallet.entity.ts), value objects (like address.value-object.ts), domain events (user-created.domain-event.ts, wallet-created.domain-event.ts), and domain error classes.
• Infrastructure Layer – includes actual implementations of external resources such as database access (the sql-repository.base.ts, user.repository.ts, wallet.repository.ts), configuration files, Docker integration, and deployment files.
• Shared / Utility Components – provided by libraries such as helper functions, custom decorators (like final.decorator.ts, frozen.decorator.ts), guard utilities, and exception handling.
Relationships and Interactions
• Data flows from the outermost adapter layer into the core application via controllers (or resolvers) which accept a DTO, then map the data into a Command/Query.
• The Command/Query is processed by application services. These interact with the domain layer (entities, aggregates, value objects) to perform business logic.
• All external interactions (such as database operations or logging) are done through dedicated “ports” — abstract interfaces defined in the core and implemented in the infrastructure.
• Domain events may be dispatched from services or entities and then handled by appropriate event handlers (for example, to create a wallet when a user is created).
• Finally, after processing, data is converted into Response DTOs which are sent back to the clients.
Architectural Patterns
• Domain-Driven Design (DDD): Emphasize entities, aggregates, value objects, domain events, and domain invariants.
• Separation of Concerns via Vertical Slicing of Modules: Note how each business domain (User, Wallet) is managed within its module. Inside modules, separate folders for commands (state-changing use cases) and queries (read models) keep related classes together.
• Clean/Onion Architecture: Show the inner core (domain) that remains independent of external concerns and ensure that dependencies point inward.
Technologies and Frameworks
• NodeJS and TypeScript as the chosen language/platform.
• NestJS as the web framework providing the controllers, dependency injection, and possibly the CQRS module.
• Slonik for type-safe SQL database interactions.
• Test frameworks related to Jest (see jest-e2e.json and tests directory) and possibly a tool like Dependency Cruiser (with the .dependency-cruiser.js file) to enforce architectural boundaries.