Skip to content

[Refactor] Implement Chassis Pattern by Separating Infrastructure from Domain Primitives#35

Merged
foxminchan merged 1 commit into
mainfrom
refactor/chassis
May 4, 2025
Merged

[Refactor] Implement Chassis Pattern by Separating Infrastructure from Domain Primitives#35
foxminchan merged 1 commit into
mainfrom
refactor/chassis

Conversation

@foxminchan

Copy link
Copy Markdown
Owner

Pull Request Description

This pull request implements the Chassis Pattern by creating a new BookWorm.Chassis project to house all infrastructure and cross-cutting concerns, while keeping only essential domain primitives in the BookWorm.SharedKernel. This architectural refactoring aligns with Domain-Driven Design principles by clearly separating technical infrastructure from domain concepts.

Changes

  • Created new BookWorm.Chassis project to contain infrastructure and cross-cutting concerns
  • Moved the following components from SharedKernel to Chassis:
    • Infrastructure: ActivityScope, EventBus, OpenTelemetry, Logging, Mediator
    • Cross-cutting concerns: Command, Query, Pipelines, Exceptions, Guards, Versioning
    • Data access: EF, Repository, Specification
    • Utilities: Converters, Endpoints, Mapper
  • Kept only domain primitives in SharedKernel:
    • Domain building blocks: Entity, ValueObject, IAggregateRoot, AuditableEntity, ISoftDelete, PagedResult
    • Domain events

Motivation

Chassis Pattern

The Chassis Pattern provides a foundation for applications by centralizing technical infrastructure, cross-cutting concerns, and common utilities. This pattern:

  • Creates a consistent technical foundation across services
  • Reduces duplication of infrastructure code
  • Enforces standardized approaches to common concerns (logging, telemetry, etc.)
  • Simplifies onboarding by providing a well-defined technical framework

Why Move to Chassis

This refactoring moves infrastructure concerns to BookWorm.Chassis because:

  1. SharedKernel Should Focus on Domain - In DDD, the SharedKernel should contain only the essential domain primitives shared across bounded contexts, not technical implementation details
  2. Separation of Concerns - Domain model should be isolated from infrastructure to maintain clean architecture
  3. Reduced Coupling - Domain logic can evolve independently from infrastructure concerns
  4. Improved Testability - Domain models can be tested without infrastructure dependencies
  5. Better Maintainability - Clear boundaries between domain and infrastructure make the codebase easier to understand and maintain

Checklist

  • My code follows the DDD principles
  • I've used the latest C# features and idioms
  • I've added/updated unit tests for business logic
  • Service boundaries are maintained (no cross-service direct dependencies)
  • Repository pattern is used for data access
  • Domain Events are used for cross-service communication
  • I've registered new services in AppHost project (if applicable)
  • I've updated both entities and DTOs (if applicable)

… domain primitives

- Create BookWorm.Chassis project to house infrastructure and cross-cutting concerns
- Move technical components from SharedKernel to Chassis (EventBus, OpenTelemetry, etc.)
- Keep only domain primitives in SharedKernel following DDD principles
- Improve architecture by clearly separating domain model from technical implementation
@foxminchan foxminchan added the enhancement New feature or request label May 4, 2025
@foxminchan foxminchan self-assigned this May 4, 2025
@netlify

netlify Bot commented May 4, 2025

Copy link
Copy Markdown

Deploy Preview for bookwormdev canceled.

Name Link
🔨 Latest commit 66679ce
🔍 Latest deploy log https://app.netlify.com/sites/bookwormdev/deploys/68178672fde1860008920b0f

@foxminchan foxminchan changed the title refactor: implement chassis pattern by separating infrastructure from… [Refactor] Implement Chassis Pattern by Separating Infrastructure from Domain Primitives May 4, 2025
@sonarqubecloud

sonarqubecloud Bot commented May 4, 2025

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 4, 2025

Copy link
Copy Markdown

Test Results

588 tests  ±0   588 ✅ ±0   2m 19s ⏱️ +32s
  6 suites ±0     0 💤 ±0 
  6 files   ±0     0 ❌ ±0 

Results for commit 66679ce. ± Comparison against base commit d17e68a.

@foxminchan
foxminchan merged commit 193048d into main May 4, 2025
@foxminchan
foxminchan deleted the refactor/chassis branch May 4, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant