🚀 v0.2.0: Architecture Polish & DDD Hardening #86
raouf-b-dev
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
🚀 v0.2.0: Architecture Polish & DDD Hardening
This release focuses on refining the architecture, enforcing strict Domain-Driven Design boundaries, cleaning up redundant boilerplate, and optimizing data access. Every change ensures system boundary definitions and error handling are as clear and efficient as possible.
🛠 What's New & Improved
🏗️ ACL Gateway & SAGA Cleanup
PaymentMethod+PaymentMethodTypetoshared-kernelto resolve downstream dependency violations.CheckoutCustomerInfo,CheckoutCartInfo) instead of leaking upstream types (ICustomer,ICart).OrderEntity↔ProductEntityforeign key in the ORM layer (@ManyToOneremoved).Job → UseCase → Gatewayflow.ReserveStockForCheckoutUseCase,ReleaseCheckoutStockUseCase,ConfirmCheckoutReservationUseCase,CreateCheckoutPaymentUseCase,RefundCheckoutPaymentUseCase,ClearCheckoutCartUseCase.🐛 Repository Cleanup & Bug Fix
ProductEntityandInventoryEntityqueries frompostgres.order-repository.ts— it now strictly managesordersandorder_itemstables only.cancelOrder()previously released stock atomically and triggered a SAGA compensation job, causing double-release. Now the repository only persists state; stock release is handled exclusively by the SAGA orchestrator.🧹 Try/Catch Boilerplate Cleanup (61 Use Cases & Services)
Result<T, E>types internally. Outer use-cases previously wrapped this with redundanttry/catchblocks.isFailure(result)checks.🗄️ Database Index Optimization (Orders)
orderstable indexes from 12 down to the 4 essential patterns based on actual query behaviors (customer_id,status,payment_id, andcustomer_status).♻️ Caching Decorator Naming Fix (21 files)
Redis*RepositorytoCached*Repository— explicitly separating the intent (caching) from the infrastructure (Redis), respecting Dependency Inversion.🧪 Testing Infrastructure
createMockRepository<T>()generic factory totypeorm.mocks.tsfor strictly-typed ORM mocks — no moreas anycasting.postgres.order-repository.spec.tsto match the simplified repository behavior (no cross-context tests).🔌 Gateway Ports → Abstract Classes
CustomerGateway,CartGateway,InventoryReservationGateway,PaymentGateway) from TypeScriptinterfacetoabstract class.@Inject(TOKEN)decorators from 8 Use Cases and Listeners — NestJS now resolves dependencies natively via class type.useExistingaliases inorders.module.tsso both the string token and the abstract class resolve to the same adapter.🧱 DDD Layer Fix: ShippingAddressResolver
ShippingAddressResolverfromcore/domain/services/→core/application/services/.ShippingAddressDto(primary adapter) andCheckoutCustomerInfo(application port) — two violations of the domain dependency rule.CheckoutCustomerInfoinstead ofICustomer.📝 Documentation Alignment
ARCHITECTURE.mdcontext map — ACL arrows now show Use Case injection (e.g.,FindCustomerUseCase) instead of the old*Repositoryreferences.README.mdv0.2.0 section with correct gateway count (7), new SAGA use cases, bug fix, and DDD relocation.PaymentMethodTypeimport paths in Payments test suites after shared-kernel migration.🗺️ New Production-Ready Roadmap
🤖 CI/CD Automation
.github/workflows/tag-on-merge.ymlfor automatic tagging upon version bumps.📊 By The Numbers
orders/core/(except shared-kernel)ShippingAddressResolver)This discussion was created from the release 🚀 v0.2.0: Architecture Polish & DDD Hardening.
All reactions