# Sairyss/domain-driven-hexagon

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/sairyss-domain-driven-hexagon).**

14,395 stars · 1,480 forks · TypeScript · mit

## Links

- GitHub: https://github.com/Sairyss/domain-driven-hexagon
- awesome-repositories: https://awesome-repositories.com/repository/sairyss-domain-driven-hexagon.md

## Topics

`architectural-patterns` `architecture` `backend` `best-practices` `clean-architecture` `clean-code` `ddd` `design-patterns` `development` `domain-driven-design` `hexagonal-architecture` `javascript` `nestjs` `nodejs` `onion-architecture` `secure-by-design` `solid-principles` `system-design` `typeorm` `typescript`

## Description

This project is a TypeScript-based architectural framework designed to implement domain-driven design and hexagonal architecture in enterprise applications. It provides a structured boilerplate that isolates core business logic from infrastructure concerns, ensuring that domain entities, use cases, and external technology adapters remain decoupled and maintainable.

The framework distinguishes itself by enforcing strict architectural boundaries and dependency inversion, preventing unauthorized access to core logic from external layers. It utilizes a command-query responsibility segregation pattern to separate state-changing operations from data-retrieval queries, simplifying complex business logic and enabling independent scaling of models. By leveraging aggregate-based state management and event-driven communication, the system maintains data consistency across modules without creating direct dependencies.

The platform includes a comprehensive suite of tools for managing the full application lifecycle, including repository-based persistence, atomic transaction management, and automated project scaffolding. It supports robust development practices through integrated testing suites, including support for human-readable feature files, and enforces strict type safety and modular code organization to ensure consistency across large-scale codebases.

The repository provides a standardized foundation for building enterprise-grade systems, complete with built-in utilities for request validation, error handling, and infrastructure abstraction.

## Tags

### Data & Databases

- [Database Adapters](https://awesome-repositories.com/f/data-databases/database-adapters.md) — Provides standardized interfaces for decoupling application logic from specific database engines and external services.
- [Aggregate State Management](https://awesome-repositories.com/f/data-databases/strong-consistency-guarantees/write-consistency-enforcement/state-consistency-patterns/aggregate-state-management.md) — Encapsulates business logic and state transitions within a central object to maintain consistency and enforce domain-specific rules. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/wallet/domain/wallet.entity.ts))
- [Atomic Transaction Execution](https://awesome-repositories.com/f/data-databases/data-integration-synchronization/data-integration/database-integrations/atomic-transaction-execution.md) — Groups multiple database operations into a single unit of work that succeeds or fails entirely to ensure data consistency. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/libs/ddd/repository.port.ts))
- [Business Invariant Enforcement](https://awesome-repositories.com/f/data-databases/data-validation/business-invariant-enforcement.md) — Validates entity state against defined rules before persistence to ensure that only valid data is saved to the database. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/domain/user.entity.ts))
- [Persistence Abstractions](https://awesome-repositories.com/f/data-databases/persistence-abstractions.md) — Decouples core business models from specific database technologies by using repository patterns and standardized interfaces.
- [Repository Patterns](https://awesome-repositories.com/f/data-databases/repository-patterns.md) — Centralizes data access logic and decouples the domain model from specific database implementations using repository patterns. ([source](https://github.com/Sairyss/domain-driven-hexagon#readme))
- [Transaction Managers](https://awesome-repositories.com/f/data-databases/transaction-managers.md) — Groups multiple database operations into atomic units to ensure data integrity and reliable persistence across complex business processes.
- [Data Persistence Layers](https://awesome-repositories.com/f/data-databases/data-persistence-layers.md) — Maps domain objects to database records and handles storage operations to ensure data consistency between the application and the persistence layer. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/libs/db/sql-repository.base.ts))
- [Data Access Contracts](https://awesome-repositories.com/f/data-databases/data-persistence/data-access-contracts.md) — Standardizes database operations by enforcing a consistent interface for entity persistence and retrieval across different modules. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/database/user.repository.port.ts))
- [Atomic Transactions](https://awesome-repositories.com/f/data-databases/database-management-systems/database-systems-management/connection-transaction-management/atomic-transactions.md) — Wraps database operations in atomic transactions to ensure that domain events and state changes are persisted reliably. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/commands/create-user/create-user.service.ts))
- [Request Validation](https://awesome-repositories.com/f/data-databases/data-governance-modeling/data-management-governance/data-integrity-validation/data-validation/request-validation.md) — The framework enforces structural and content constraints on incoming data to ensure integrity and correctness before information reaches the core application logic. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/commands/create-user/create-user.request.dto.ts))
- [Database Migration Management](https://awesome-repositories.com/f/data-databases/database-migration-management.md) — Executes schema changes and versioning scripts to keep database structures synchronized across development, testing, and production environments. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/package.json))
- [Entity Mappings](https://awesome-repositories.com/f/data-databases/type-mapping-frameworks/script-to-native-type-mappings/entity-mappings.md) — Fetches records from the database by identifier or as a collection and transforms them back into domain objects using mapping logic. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/database/user.repository.ts))
- [Data Validation](https://awesome-repositories.com/f/data-databases/data-governance-modeling/data-management-governance/data-integrity-validation/data-validation.md) — Checks if provided values are empty or fall within specified length ranges to ensure data meets business requirements before processing. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/libs/guard.ts))
- [Event Tracking](https://awesome-repositories.com/f/data-databases/event-tracking.md) — Records significant state changes within aggregates to facilitate decoupled communication and side effects across the system. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/libs/ddd/aggregate-root.base.ts))
- [Pagination](https://awesome-repositories.com/f/data-databases/query-result-fetching/pagination.md) — Retrieves filtered data sets from the database using pagination parameters to optimize performance and reduce memory usage. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/queries/find-users/find-users.query-handler.ts))

### Development Tools & Productivity

- [Project Boilerplates](https://awesome-repositories.com/f/development-tools-productivity/project-boilerplates.md) — Enforces clean separation between domain entities, application use cases, and external technology adapters through project templates.
- [Project Scaffolding](https://awesome-repositories.com/f/development-tools-productivity/project-scaffolding-config-code-generation/project-scaffolding-configuration/project-scaffolding.md) — Automates the creation of standardized application structures and boilerplate code to ensure consistent architecture across enterprise-grade projects. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/nest-cli.json))
- [Code Organization](https://awesome-repositories.com/f/development-tools-productivity/code-organization.md) — Groups related business logic into independent, encapsulated modules to minimize coupling and support vertical slicing of features. ([source](https://github.com/Sairyss/domain-driven-hexagon#readme))

### Software Engineering & Architecture

- [Command Query Responsibility Segregation Patterns](https://awesome-repositories.com/f/software-engineering-architecture/architectural-design-patterns/state-management/state-logic-and-utilities/command-query-responsibility-segregation-patterns.md) — The framework routes state-changing operations and data-retrieval requests through distinct handlers to simplify logic and enable independent scaling of read and write models. ([source](https://github.com/Sairyss/domain-driven-hexagon#readme))
- [Clean Architecture Frameworks](https://awesome-repositories.com/f/software-engineering-architecture/clean-architecture-frameworks.md) — Provides a strictly typed foundation for organizing complex business logic into decoupled modules with standardized command and query patterns.
- [Domain-Driven Designs](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/abstraction-domain-modeling/domain-driven-designs.md) — Implements clean, modular software by separating core business logic from infrastructure concerns using hexagonal architectural patterns.
- [Command Execution Engines](https://awesome-repositories.com/f/software-engineering-architecture/command-execution-engines.md) — The framework processes business logic by invoking handlers that apply state changes and ensure domain rules remain consistent across the application. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/commands/create-user/create-user.service.ts))
- [Design Pattern Implementations](https://awesome-repositories.com/f/software-engineering-architecture/design-pattern-implementations.md) — Separates state-changing commands from data-retrieval queries to simplify scaling and maintainability in complex systems.
- [Dependency Inversion Patterns](https://awesome-repositories.com/f/software-engineering-architecture/project-management-governance/dependency-boundary-enforcers/dependency-inversion-patterns.md) — Enforces strict boundaries by ensuring high-level business logic depends only on abstractions rather than concrete infrastructure implementations.
- [Command Query Separation](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/modular-decoupled-design/structural-design-paradigms/command-query-separation.md) — Separating state-changing operations from data-retrieval queries to simplify complex business logic and enable independent scaling of models.
- [Event-Driven Architectures](https://awesome-repositories.com/f/software-engineering-architecture/event-driven-architectures.md) — Triggers asynchronous side effects across system components to maintain data consistency without creating direct dependencies between different modules.
- [Dependency Boundary Enforcers](https://awesome-repositories.com/f/software-engineering-architecture/project-management-governance/dependency-boundary-enforcers.md) — The framework analyzes and enforces dependency rules between layers to prevent unauthorized access to core domain logic from external infrastructure or interface layers. ([source](https://github.com/Sairyss/domain-driven-hexagon#readme))
- [Request Dispatchers](https://awesome-repositories.com/f/software-engineering-architecture/request-dispatchers.md) — The framework dispatches incoming transport requests to specific domain commands through a centralized bus to decouple the communication layer from core business operations. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/commands/create-user/create-user.http.controller.ts))
- [Decoupled Logic Encapsulation](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/modular-decoupled-design/structural-design-paradigms/decoupled-logic-encapsulation.md) — Groups data and business rules within objects to ensure state remains consistent and protected from unauthorized external modifications. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/README.md))
- [Use Case Orchestrators](https://awesome-repositories.com/f/software-engineering-architecture/use-case-orchestrators.md) — The framework coordinates interactions between the outside world and domain entities using application services that do not contain core business logic. ([source](https://github.com/Sairyss/domain-driven-hexagon#readme))
- [Workflow Orchestrators](https://awesome-repositories.com/f/software-engineering-architecture/workflow-orchestrators.md) — The framework executes use cases by coordinating domain entities and external services through defined ports to keep business logic decoupled from infrastructure. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/README.md))
- [Command Objects](https://awesome-repositories.com/f/software-engineering-architecture/data-structures/domain-type-definitions/command-objects.md) — The framework packages business intent and required data into structured objects to trigger state changes within the core application logic. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/commands/create-user/create-user.command.ts))
- [Error Handling](https://awesome-repositories.com/f/software-engineering-architecture/error-handling.md) — The framework converts internal error types into appropriate status codes and messages to ensure consistent and predictable error reporting for all system users. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/commands/create-user/create-user.http.controller.ts))
- [Event-Driven Triggers](https://awesome-repositories.com/f/software-engineering-architecture/event-driven-triggers.md) — Decouples system components by using asynchronous domain events to trigger side effects and maintain data consistency.
- [Value Objects](https://awesome-repositories.com/f/software-engineering-architecture/object-schema-definitions/value-objects.md) — Encapsulates domain data with built-in validation logic to ensure that objects remain in a valid state throughout the application lifecycle. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/domain/value-objects/address.value-object.ts))
- [Error Handling Patterns](https://awesome-repositories.com/f/software-engineering-architecture/error-handling-patterns.md) — Returns explicit error types instead of throwing exceptions to make failure states visible and manageable within the application flow. ([source](https://github.com/Sairyss/domain-driven-hexagon#readme))
- [Query Objects](https://awesome-repositories.com/f/software-engineering-architecture/software-architecture/architectural-patterns/modular-decoupled-design/structural-design-paradigms/command-query-separation/ingestion-query-separation/query-objects.md) — Separates read operations from business logic by encapsulating data retrieval within dedicated query objects. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/queries))

### DevOps & Infrastructure

- [Infrastructure Abstraction Layers](https://awesome-repositories.com/f/devops-infrastructure/infrastructure/infrastructure-as-code/iac-providers-and-cloud/cloud-provider-integrations/infrastructure-abstraction-layers.md) — The framework provides technology-agnostic interfaces for external services, ensuring business logic remains independent of specific databases, third-party APIs, or infrastructure implementation details. ([source](https://github.com/Sairyss/domain-driven-hexagon#readme))

### User Interface & Experience

- [Domain Event Emission](https://awesome-repositories.com/f/user-interface-experience/component-utilities/ui-frameworks/component-apis/event-communication-systems/event-emission-declarations/custom-event-emission/domain-event-emission.md) — Triggers notifications when state changes occur within an entity so that other parts of the system can react to updates asynchronously. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/domain/user.entity.ts))
- [Domain Event Handlers](https://awesome-repositories.com/f/user-interface-experience/form-and-input-management/interaction-and-event-handling/event-handling-architectures/event-handling-systems/domain-event-handlers.md) — The framework executes automated side effects across system aggregates in response to specific events to maintain data consistency and decoupled business logic. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/wallet/application/event-handlers/create-wallet-when-user-is-created.domain-event-handler.ts))

### Programming Languages & Runtimes

- [Type Safety](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/type-system-tools/type-safety.md) — Applies rigorous type safety rules during compilation to catch potential runtime errors and ensure consistent data structures. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/tsconfig.json))

### Web Development

- [Mutation Mappers](https://awesome-repositories.com/f/web-development/graphql-extensions/mutation-mappers.md) — The framework maps incoming GraphQL mutation requests to internal command objects to trigger domain logic while returning standardized response types to the client. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/commands/create-user/graphql-example/create-user.graphql-resolver.ts))
- [Response Mappers](https://awesome-repositories.com/f/web-development/api-response-handlers/response-mappers.md) — The framework maps internal domain entities to documented and serializable formats to ensure consistent data structures for all client communication across the system. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/dtos/user.response.dto.ts))

### Networking & Communication

- [Message Brokers](https://awesome-repositories.com/f/networking-communication/message-brokers.md) — The framework listens for incoming messages from a message queue and dispatches them to the correct command handler to execute business logic asynchronously. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/modules/user/commands/create-user/create-user.message.controller.ts))

### System Administration & Monitoring

- [Logging Abstractions](https://awesome-repositories.com/f/system-administration-monitoring/system-logging-frameworks/logging-abstractions.md) — Standardizes how system events, errors, and warnings are recorded by defining a consistent interface for various logging implementations. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/src/libs/ports/logger.port.ts))

### Testing & Quality Assurance

- [End-to-End Testing](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/e2e-integration-testing/end-to-end-testing.md) — Runs automated suites that simulate complete user workflows across an entire application stack to verify system-wide functional correctness. ([source](https://github.com/Sairyss/domain-driven-hexagon/blob/master/package.json))
