How kevinorjg/optarys-invex works
Project Type and Purpose
• This is a “monolithic” back-end service built on the NestJS framework (TypeScript/Node.js).
• It exposes HTTP endpoints for account management, authentication (sign-in/sign-up), RBAC (roles & permissions), health checks, and metrics.
• It follows a layered, Domain-Driven structure (Presentation → Application → Domain → Infrastructure).
High-Level Layers & Top-Level Directories
• src/main.ts & nest-cli.json – Nest entry point & CLI config
• src/presentation – HTTP controllers (REST endpoints)
• src/application – Business use-cases, handlers, DTOs, guards, mediator & logging services
• src/domain – Core entities & contracts interfaces
• src/infrastructure – Database context (TypeORM models) & tenant configuration
• src/app.module.ts & dependencyInjection.ts – Module wiring & DI container setup
Reading the README
• Confirms a standard NestJS starter with build/start scripts, tests, and deployment guidance.
• No external front-end; it’s purely a back-end API.
Main Components
A. Client(s) (e.g., web/mobile)
B. API Gateway / NestJS Application
· Presentation Layer (Controllers: Auth, Account, Access, Health, Metrics)
· Application Layer
– Use-Case Handlers (CreateAccountHandler, SignInWithCredentialsHandler)
– Mediator Service for command dispatch
– Logger Service
– Guards (AuthGuard)
· Domain Layer (Entities: User, Account, Role, Permission; Contracts)
· Infrastructure Layer
– TypeORM Context (Entities mapped to DB tables)
– Tenant Context (multi-tenant config)
C. Database (e.g., PostgreSQL)
D. External Monitoring/Metrics
· Node Exporter (install_node_exporter.sh)
· Prometheus/Grafana pulling from /metrics endpoint
Relationships & Data Flow
1. HTTP Client → (1) Presentation Controller
2. Controller → (2) Application Handler via DI
3. Handler → (3) Domain Entities / Business Logic
4. Domain → (4) Infrastructure (TypeORM Repository → SQL DB)
5. Handlers/Services log events → (5) Logger Service
6. Metrics Endpoint scraped by Node Exporter/Prometheus
Architectural Patterns & Principles
• Layered Architecture (Separation of Concerns)
• Dependency Injection (Nest modules & custom dependencyInjection.ts)
• Mediator Pattern for decoupled command handling
• Guard pattern for authorization
• Domain-Driven Design (Entities & Contracts)
• Multi-tenant support via tenantContext