How tekdi/all-saas-user-microservice works
Project Type & Purpose
• The project is a backend API server built with the NestJS framework using TypeScript. It is structured as a modular, feature-based application supporting multiple domains (for example: attendance, auth, cohort, courses, RBAC, etc.) along with various adapters for external integrations (like Hasura, Postgres, and Diksha).
• The README “NestJS starter repository” shows that the project follows Nest’s best practices and is intended to be scalable and maintainable. It’s designed to handle a variety of business functionalities including authentication, role-based access control, user and cohort management, and interfacing with external services.
Analyzing the File Structure
• Top-Level Structure: Notice directories like “src” for application code, “adapters” which provide integration layers, “common” for shared utilities, decorators, and guards, as well as configurations and scaffolding files (Dockerfile, Jenkinsfile, docker-compose.yml, etc.) for deployment and CI/CD.
• Modular Domains: Within “src” you have separated modules such as “attendance”, “auth”, “cohort”, “course”, “fields”, “rbac”, “user”, “userTenantMapping”, etc. This modular breakdown is reflective of the typical NestJS approach where each module encapsulates controllers, services, DTOs, and entities related to specific functionality.
• Adapters: The “adapters” directory contains subdirectories for different external service integrations. For example, there are adapters for Hasura (e.g. for RBAC, attendance, cohort members) and Postgres. This separation indicates that external services are abstracted so that the business logic in your modules can remain independent of the underlying data sources or APIs.
• Configurations & CI/CD: Files and directories like “.github/workflows”, “Jenkinsfile”, “Dockerfile”, and “docker-compose.yml” suggest that the project is set up for containerized deployment and automated testing/deployment pipelines.
Main Components
a. API Gateway / Entry Point:
• NestJS application’s main entry (main.ts) which initializes the entire server.
b. Domain Modules / Functional Components:
• Each module should ideally encapsulate its controllers (handling HTTP requests), services (business logic), DTOs (data transfer objects), and Entities (database schema representations).
c. Adapters / Integration Layers:
• Hasura Adapter for GraphQL interactions, RBAC, and related services.
• Postgres Adapter managing data persistence.
• Diksha Adapter (and possibly others) for interfacing with external course or content services.
d. Common Shared Components:
• Elements like Common Utilities, Guards, Filters, Decorators, and a Database Module that are used across various modules.
e. Infrastructure & CI/CD:
Relationships & Interactions
• How modules interact with the adapters (for example, the Attendance module calling a specific Hasura or Postgres adapter) via service locators.
• Data flow between the modules and the database/integrations.
• Optionally, show how CI/CD components (from GitHub workflows, Docker, Kubernetes manifests) relate to the overall system deployment and ongoing operations.
Architectural Patterns & Design Principles
• Modular architecture pattern inherent to NestJS which provides separation of concerns: controllers, services, and adapters are decoupled.
• Use of adapter or façade patterns where external systems (database, third-party APIs) are abstracted behind local interfaces.
• That dependency inversion is used in orchestrating business logic through service locators.