Skip to content

v0.4.1: Architectural Hardening & Type Safety Sweep

Pre-release
Pre-release

Choose a tag to compare

@raouf-b-dev raouf-b-dev released this 17 May 16:51
147231b

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, and Products , eliminating dependency leaks between the application core and infrastructure adapters.
  • Input Standardization: Replaced primary-adapter DTO dependencies in use cases with domain-defined Command and Query interfaces across all modules, ensuring the application layer has zero knowledge of the HTTP layer.
  • Domain Purity Fix: Removed OrderFactory from 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 JwtSignerPort and JwtSignerService, 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 CachePort interface and refactored all module dependency injection to inject the abstraction rather than the concrete CacheService, enforcing strict Dependency Inversion across all cached repositories.

🛡️ Type Safety Sweep

  • Systematic elimination of as unknown and as any type 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 the GlobalExceptionFilter, JWT payload handling, and repository return types.

🧬 Domain Model Refinements

  • Inventory: Introduced StockAdjustmentType value object and CheckStockResult interface, strengthening the domain vocabulary.
  • Repository Ports: Enriched repository port interfaces across Inventory, Orders, Products, and Carts with 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.ts for standardized test module bootstrapping.
  • 8 New Shared Mocks: BullMQ Job, CachePort, CorrelationService, EnvConfigService, WinstonLogger, OrderScheduler, RedisPipeline, and Reflector , eliminating duplicated mock definitions scattered across modules.
  • Factory Alignment: Renamed test factories to follow the Command naming convention (e.g., create-product-dto.factorycreate-product-input.factory), and introduced new factories like schedule-checkout-props.factory and order.factory in the Orders module.

📖 Documentation

  • Roadmap Refined: Updated ROADMAP.md with 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