Release v0.4.0: Observability, RBAC, and Architecture Hardening
Pre-release
Pre-release
🚀 Release v0.4.0: Observability, RBAC, and Architecture Hardening
This release represents a massive leap in production readiness. Over the past month (~180 commits), the architecture has been hardened with a full observability stack, a granular Role-Based Access Control (RBAC) system, enhanced security features, and strict API rate limiting.
✨ Key Features
🔍 Full Observability Stack (Logs, Metrics, Traces)
- Structured Logging: Replaced standard console logging with Winston. Logs are formatted as structured JSON and shipped to Loki via Promtail.
- Distributed Tracing: Integrated OpenTelemetry SDK with auto-instrumentation for HTTP, PostgreSQL, Redis, and BullMQ, exporting to Tempo via OTLP gRPC.
- Metrics: Integrated
prom-clientto expose a protected/metricsendpoint for Prometheus scraping. Captures both infrastructure metrics (latency, HTTP codes) and business domain events. - Grafana Dashboards: Included a pre-provisioned Grafana setup via Docker Compose with 4 ready-to-use dashboards: API Overview, Business Metrics, Checkout SAGA, and Infrastructure.
- Async Correlation: Implemented a robust
AsyncLocalStoragecorrelation service.X-Request-Idand trace contexts now propagate seamlessly across the HTTP boundary and into all 18 BullMQ background job workers.
🔐 RBAC & Security Hardening
- Normalized RBAC: Completely refactored the Auth module. Replaced static enums with a full database-backed
RoleandPermissionentity model. - Guards & Decorators: Introduced
PermissionsGuardand@RequirePermissionsdecorators for granular endpoint protection without compromising cross-module boundaries. - Auth Hardening: Extracted password hashing into a dedicated
PasswordHasherport. Implemented user activation/deactivation flows andmustChangePasswordsecurity flags. - API Rate Limiting: Added global Redis-backed rate limiting using
@nestjs/throttlerto protect against brute-force and DDoS attacks.
🏗️ Architecture & Infrastructure
- API Versioning: Enabled URI versioning (e.g.,
/v1/orders). - Health Checks: Implemented
@nestjs/terminusfor robust/healthendpoints covering PostgreSQL, Redis, and WebSocket readiness. - Docker Production Ready: Overhauled the
Dockerfileinto a 4-stage optimized build. Updateddocker-compose.prod.ymlwith health checks, dynamic image versioning, and proper network isolation. - AI Agentic Ecosystem: Formalized AI assistant boundaries with
.agents/configuration, standardizing how AI tools interact with the repository's DDD rules.
🧹 Refactoring & Quality
- Stripped redundant generic wrappers and implemented thin-controller patterns across Notifications and Payments modules.
- Added 116 spec files spanning unit, repository, and controller levels.
- Resolved race conditions in WebSocket graceful shutdowns.
📦 Quick Start with the new stack
To spin up the entire API alongside the new Grafana/Prometheus/OTel observability stack:
# Start the full production stack including monitoring
npm run d:up:full:prod