v0.4.1: Architectural Hardening & Type Safety Sweep
Pre-release
Pre-release
Release v0.4.1 🚀
A comprehensive architectural hardening release that strengthens DDD and Hexagonal Architecture boundaries across the entire codebase. This patch touches 228 files (~2,600 insertions / ~2,350 deletions) and focuses on enforcing strict layer isolation, eliminating unsafe type assertions, and building a centralized testing infrastructure.
🌟 Highlights
🏗️ Architectural Hardening (DDD & Hexagonal)
- Full Boundary Audit: Hardened DDD boundaries and hexagonal isolation across all 7 domain modules,
Auth,Carts,Customers,Inventory,Orders,Payments, andProducts, eliminating dependency leaks between the application core and infrastructure adapters. - Input Standardization: Replaced primary-adapter DTO dependencies in use cases with domain-defined
CommandandQueryinterfaces across all modules, ensuring the application layer has zero knowledge of the HTTP layer. - Domain Purity Fix: Removed
OrderFactoryfrom the domain layer (it was a test concern living in the wrong architectural layer) and relocated it to the testing infrastructure where it belongs.
🔌 Ports & Adapters Refactoring
- JWT Abstraction: Introduced
JwtSignerPortandJwtSignerService, fully decoupling JWT token generation from concrete infrastructure. Restructured the broader JWT service ecosystem for cleaner separation of signing vs. verification concerns. - Cache Abstraction: Implemented the
CachePortinterface and refactored all module dependency injection to inject the abstraction rather than the concreteCacheService, enforcing strict Dependency Inversion across all cached repositories.
🛡️ Type Safety Sweep
- Systematic elimination of
as unknownandas anytype assertions across the codebase, replacing them with proper type guards, validated interfaces, and strict typing. This effort surfaced and fixed several silenced bugs that were hidden behind loose casts, including in theGlobalExceptionFilter, JWT payload handling, and repository return types.
🧬 Domain Model Refinements
- Inventory: Introduced
StockAdjustmentTypevalue object andCheckStockResultinterface, strengthening the domain vocabulary. - Repository Ports: Enriched repository port interfaces across
Inventory,Orders,Products, andCartswith stronger type contracts and explicit method signatures, removing reliance on loosely-typed parameters.
🧪 Shared Testing Infrastructure
- Centralized Test Layer: Built a new
src/testing/shared infrastructure with a barrel export (index.ts) for cross-module reuse. - NestJS Context Fixture: Added a reusable
nestjs-context.fixture.tsfor standardized test module bootstrapping. - 8 New Shared Mocks:
BullMQ Job,CachePort,CorrelationService,EnvConfigService,WinstonLogger,OrderScheduler,RedisPipeline, andReflector, eliminating duplicated mock definitions scattered across modules. - Factory Alignment: Renamed test factories to follow the
Commandnaming convention (e.g.,create-product-dto.factory→create-product-input.factory), and introduced new factories likeschedule-checkout-props.factoryandorder.factoryin the Orders module.
📖 Documentation
- Roadmap Refined: Updated
ROADMAP.mdwith revised phases and goals prioritizing pre-deployment readiness and live demo provisioning.
📊 Release Stats
| Metric | Value |
|---|---|
| Files Changed | 228 |
| Insertions | ~2,600 |
| Deletions | ~2,350 |
| Modules Touched | 7 / 8 (all except Notifications) |
| New Shared Mocks | 8 |
| New Domain Artifacts | 2 (value object + interface) |
📝 Commits
| Hash | Description |
|---|---|
bb0e295 |
refactor(arch): harden DDD boundaries and hexagonal isolation |
cc4914b |
refactor(auth, carts, customers): standardize input handling with Command interfaces |
1a96698 |
refactor(jwt): restructure JWT services and introduce ports for better abstraction |
c1b6154 |
implement CachePort interface and refactor CacheService for improved abstraction |
e609e69 |
introduce JwtSignerService and JwtSignerPort for JWT handling |
07cf01d |
refactor: update mock implementations and add new factories for testing |
715bc93 |
refactor: update JWT and Cache services to use ports for improved abstraction |
86296d2 |
refactor: enhance error handling and type safety in global exception filter |
78fea4a |
refactor: enhance test structure and mock implementations across various modules |
17b5a33 |
update ROADMAP.md: revise phases and goals for deployment readiness |
27a8dd1 |
chore(release): bump version to v0.4.1 |
Full Changelog: v0.4.0...v0.4.1