System Architecture
Core Features
Data Management
Frontend Components
Extensibility
The following files were used as context for generating this wiki page:
This document provides an overview of the module structure within the apps/api directory, focusing on how different feature modules are organized and integrated into the main application. It details the AppModule as the root, along with specific examples like HealthModule, IntegrationPlatformModule, and QuestionnaireModule, illustrating their responsibilities and dependencies.
The architecture leverages NestJS modules to encapsulate related functionalities, promoting modularity and maintainability. Each module typically groups controllers, services, and repositories relevant to a specific domain, which are then imported into the AppModule to form the complete API application.
AppModule)The AppModule serves as the root module for the NestJS API application. It aggregates all other feature modules, global configurations, and core services required for the application to function. This module is responsible for setting up global configurations like rate limiting and loading environment-specific settings.
The AppModule initializes several global configurations and guards:
ConfigModule: Configures the application to load environment variables and specific configuration objects (awsConfig, betterAuthConfig). It is set as global, making configuration available throughout the application.ThrottlerModule: Implements rate limiting to protect the API from abuse. It is configured to allow 100 requests per minute (ttl: 60000, limit: 100) per IP address.APP_GUARD: The ThrottlerGuard is provided globally using APP_GUARD, ensuring that rate limiting is applied to all routes by default.Sources: apps/api/src/app.module.ts:1-60
The AppModule imports a wide array of feature modules, each responsible for a specific domain or functionality within the API. This modular approach helps in organizing the codebase and managing dependencies.
The AppModule imports 29 distinct feature modules, demonstrating a comprehensive microservices-like architecture within a single NestJS application.
The following diagram illustrates the primary modules imported by the AppModule:
Sources: apps/api/src/app.module.ts:31-57
HealthModule)The HealthModule is a simple module dedicated to providing health check endpoints for the API. It contains only a controller, HealthController, which would typically expose endpoints to verify the application's operational status.
Sources: apps/api/src/health/health.module.ts:1-6
IntegrationPlatformModule)The IntegrationPlatformModule is a comprehensive module responsible for managing various aspects of third-party integrations. It encompasses controllers for handling OAuth flows, managing connections, administrative tasks, and webhook processing. It also provides services for credential management, connection handling, and automated checks, supported by dedicated repositories for data persistence.
This module is structured with a clear separation of concerns, including:
The module also exports several services, making them available for use by other modules that import IntegrationPlatformModule.
Exporting services like CredentialVaultService and ConnectionService allows other modules to securely interact with integration functionalities without needing to know the internal implementation details of the IntegrationPlatformModule.
The following diagram illustrates the internal components of the IntegrationPlatformModule:
Sources: apps/api/src/integration-platform/integration-platform.module.ts:1-62
QuestionnaireModule)The QuestionnaireModule handles functionalities related to questionnaires. It includes a controller for API endpoints and a service for business logic. Notably, it imports the TrustPortalModule, indicating a dependency on trust portal functionalities, possibly for questionnaire publishing or data integration.
Sources: apps/api/src/questionnaire/questionnaire.module.ts:1-11