How vishnuvinay89/all-saas-user-microservice works
Project Type and Purpose
• This is a backend monolith built with NestJS (a TypeScript Node.js framework) providing a collection of REST/GraphQL‐style APIs.
• It orchestrates multiple domain modules (attendance, cohort, user, RBAC/privileges, course, fields, etc.), each with its own controllers, services, DTOs, and entity definitions.
• It uses adapter/service‐locator patterns to switch between different data sources (Hasura GraphQL, PostgreSQL, external Diksha API) and integrates Keycloak for authentication/authorization.
File Structure
• Top‐level project: Dockerfile, docker-compose.yml, CI/CD (Jenkinsfile, GitHub workflows), manifests for Kubernetes.
• src/ contains:
• app.controller.ts/app.module.ts: Entry point and root DI container
• Domain folders (attendance/, cohort/, user/, rbac/, etc.) each with controller, service, DTOs, entities
• src/adapters/: Adapter abstractions & concrete implementations under hasura/, postgres/, diksha/
• src/common/: Global modules, guards, filters, decorators (Keycloak integration, RBAC guards)
• src/configs, src/courseTracking, src/fields: Additional domain modules
• src/auth & src/authRbac: Authentication and authorization services
• CI/CD configs and Kubernetes manifests reside at root and .github/workflows/.
README Insights
• No explicit architecture section, so we infer patterns & external integrations from code.
Main Components & Relationships
a. API Layer (Controllers)
• Exposed REST endpoints by controllers in each module (e.g., /attendance, /cohort, /user, /rbac/assign-role, etc.)
b. Service Layer
• Business logic in module services (e.g., AttendanceService, CohortService).
c. Adapter Layer (Ports & Adapters)
• Generic service locators (e.g., AttendanceServiceLocator) inject concrete adapters.
• Adapters talk to:
• Hasura GraphQL API
• PostgreSQL DB
• External Diksha API
d. Data Sources & External Services
• Hasura GraphQL endpoint
• PostgreSQL instance
• Diksha REST API
• Keycloak Identity Provider
e. Infrastructure & CI/CD
• Docker build image
• docker-compose for local dev
• Kubernetes manifests (EKS, GitHub Actions, Jenkins pipelines)
Architectural Patterns & Design Principles
• Modular (NestJS modules per domain)
• Dependency Injection & Inversion of Control for testability & adapter substitution
• Ports & Adapters (Hexagonal architecture) separating domain logic from data sources
• Layered architecture: Controller → Service → Adapter → Data Source
• Centralized authentication/authorization via Keycloak guards and strategies
Essential Elements to Capture
• Every domain module (attendance, cohort, user, rbac, etc.) as a logical block
• The adapter layer’s ability to route calls to different backends (Hasura vs. Postgres vs. external API)
• Keycloak’s integration point for authentication and RBAC enforcement
• The CI/CD flow: GitHub Actions/Jenkins → Docker image → EKS (manifest/backend.yaml)
• Configuration (environment variables, NestJS ConfigModule) as a shared concern