# rtcface/backend-oic architecture

> Architecture diagram of the GitHub repository rtcface/backend-oic, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rtcface/backend-oic
- Repository: https://github.com/rtcface/backend-oic

## Overview

##### Main Components
- API Layer (GraphQL): At the heart of the application is the GraphQL schema (schema.gql) alongside a series of resolver files (e.g., auth.resolver.ts, code-ethics.resolver.ts, etc.) which handle incoming API requests.
- Modules: The project is broken into several business-specific modules, such as:
- Authentication (src/auth)
- Code Ethic management (src/code-ethics)
- Ente (src/ente)
- Ethics Committe (src/ethics-committe)
- Integrity Rules (src/integrity-rules)
- KPIs (src/kpis)
- Menu (src/menu)
- Plan Work (src/plan-work)
- Users (src/users)
- Supporting Infrastructure:
- Configuration (src/configuration)
- Main application entry (src/main.ts)
- Environment configuration (.env.example) and containerization files (Dockerfile, Tem-docker-compose.yml, Procfile) which suggest deployment via Docker and potentially integration with some PaaS.
- Testing: An end-to-end test folder (test/) which indicates that integration flows and data flows should also be considered.

##### Interactions and Relationships
- Authentication & Security: Since there is an auth module with guards and strategies, include an authentication component that ensures secure API access. This part will interact with other modules by protecting endpoints.
- Configuration & Dependency Injection: Denote configuration management as a standalone service/component that provides a central configuration to various modules.
- Deployment/Environment: Represent the containerization (Docker) aspect and environment variables, showing that the application is set up for multiple deployment environments (development, staging, production).

##### Architectural Patterns and Technologies
- Modular Structure: Emphasize the clean separation of concerns by module. Each module follows a similar pattern with DTOs, inputs, resolvers, services, and schemas.
- GraphQL: Note that all modules interact via GraphQL, making use of resolvers to map incoming operations to business logic.
- NestJS & Dependency Injection: Illustrate how NestJS’s dependency injection allows for loose coupling between modules and the shared configuration mechanisms.
- Middleware/Guards: Point out the use of guards (e.g., GQL Auth Guard, JWT, local strategy) that sit between the incoming request and the resolvers.

##### Final Things
- A clear title indicating “NestJS Server-Side Application Architecture”.
- That each module is detailed to accommodate each internal folder structure (e.g., inputs, DTOs, guards, and strategies for the auth module), which reinforces the level of granularity in the architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% High-Level Nodes
    Client("Client"):::client
    API("GraphQL API Gateway"):::api
    MainApp("Main Application Entry"):::infra
    Config("Configuration Service"):::infra
    E2E("End-to-End Tests"):::test

    %% Client to API and Main Entry flow
    Client -->|"GraphQLRequest"| API
    MainApp -->|"Bootstraps"| API

    %% API Layer Details
    API -->|"UsesSchemaAndResolvers"| Schema("GraphQL Schema"):::api

    %% Modules Subgraph (vertical layout)
    subgraph "Application Modules"
        direction TB

        %% Auth Module
        AuthResolver("Auth Resolver"):::module
        AuthService("Auth Service"):::module
        AuthResolver -->|"calls"| AuthService

        %% Code Ethics Module
        CodeEthicsResolver("Code Ethics Resolver"):::module
        CodeEthicsService("Code Ethics Service"):::module
        CodeEthicsResolver -->|"calls"| CodeEthicsService

        %% Ente Module
        EnteResolver("Ente Resolver"):::module
        EnteService("Ente Service"):::module
        EnteResolver -->|"calls"| EnteService

        %% Ethics Committe Module
        EthicsCommResolver("Ethics Committe Resolver"):::module
        EthicsCommService("Ethics Committe Service"):::module
        EthicsCommResolver -->|"calls"| EthicsCommService

        %% Integrity Rules Module
        IntegrityResolver("Integrity Rules Resolver"):::module
        IntegrityService("Integrity Rules Service"):::module
        IntegrityResolver -->|"calls"| IntegrityService

        %% KPIs Module
        KpisResolver("KPIs Resolver"):::module
        KpisService("KPIs Service"):::module
        KpisResolver -->|"calls"| KpisService

        %% Menu Module
        MenuResolver("Menu Resolver"):::module
        MenuService("Menu Service"):::module
        MenuResolver -->|"calls"| MenuService

        %% Plan Work Module
        PlanWorkResolver("Plan Work Resolver"):::module
        PlanWorkService("Plan Work Service"):::module
        PlanWorkResolver -->|"calls"| PlanWorkService

        %% Users Module
        UsersResolver("Users Resolver"):::module
        UsersService("Users Service"):::module
        UsersResolver -->|"calls"| UsersService
    end

    %% API Gateway routes to Module Resolvers
    API -->|"AuthQuery"| AuthResolver
    API -->|"CodeEthicsQuery"| CodeEthicsResolver
    API -->|"EnteQuery"| EnteResolver
    API -->|"EthicsCommQuery"| EthicsCommResolver
    API -->|"IntegrityQuery"| IntegrityResolver
    API -->|"KPIsQuery"| KpisResolver
    API -->|"MenuQuery"| MenuResolver
    API -->|"PlanWorkQuery"| PlanWorkResolver
    API -->|"UsersQuery"| UsersResolver

    %% All Module Services use the Configuration Service
    AuthService -->|"configInjection"| Config
    CodeEthicsService -->|"configInjection"| Config
    EnteService -->|"configInjection"| Config
    EthicsCommService -->|"configInjection"| Config
    IntegrityService -->|"configInjection"| Config
    KpisService -->|"configInjection"| Config
    MenuService -->|"configInjection"| Config
    PlanWorkService -->|"configInjection"| Config
    UsersService -->|"configInjection"| Config

    %% Deployment / Environment Subgraph
    subgraph "Deployment / Environment"
        Docker("Dockerfile"):::deploy
        Compose("Tem-docker-compose.yml"):::deploy
        Proc("Procfile"):::deploy
        Env("Environment Variables (.env.example)"):::deploy
    end

    %% Connections to Testing
    E2E -->|"validates API"| API

    %% Styles (colors and shapes)
    classDef client fill:#f4d03f,stroke:#000,stroke-width:2px;
    classDef api fill:#aed6f1,stroke:#000,stroke-width:2px;
    classDef module fill:#d5f5e3,stroke:#000,stroke-width:2px;
    classDef infra fill:#f9e79f,stroke:#000,stroke-width:2px;
    classDef deploy fill:#f5b7b1,stroke:#000,stroke-width:2px;
    classDef test fill:#d2b4de,stroke:#000,stroke-width:2px;

    %% Click Events for API Layer
    click API "https://github.com/rtcface/backend-oic/blob/main/schema.gql"

    %% Click Events for Resolver Files
    click AuthResolver "https://github.com/rtcface/backend-oic/blob/main/src/auth/auth.resolver.ts"
    click CodeEthicsResolver "https://github.com/rtcface/backend-oic/blob/main/src/code-ethics/code-ethics.resolver.ts"
    click EnteResolver "https://github.com/rtcface/backend-oic/blob/main/src/ente/ente.resolver.ts"
    click EthicsCommResolver "https://github.com/rtcface/backend-oic/blob/main/src/ethics-committe/ethics-committe.resolver.ts"
    click IntegrityResolver "https://github.com/rtcface/backend-oic/blob/main/src/integrity-rules/integrity-rules.resolver.ts"
    click KpisResolver "https://github.com/rtcface/backend-oic/blob/main/src/kpis/kpis.resolver.ts"
    click MenuResolver "https://github.com/rtcface/backend-oic/blob/main/src/menu/menu.resolver.ts"
    click PlanWorkResolver "https://github.com/rtcface/backend-oic/blob/main/src/plan-work/plan-work.resolver.ts"
    click UsersResolver "https://github.com/rtcface/backend-oic/blob/main/src/users/users.resolver.ts"

    %% Click Events for Module Directories (Authentication, Code Ethics, etc.)
    click AuthService "https://github.com/rtcface/backend-oic/tree/main/src/auth/"
    click CodeEthicsService "https://github.com/rtcface/backend-oic/tree/main/src/code-ethics/"
    click EnteService "https://github.com/rtcface/backend-oic/tree/main/src/ente/"
    click EthicsCommService "https://github.com/rtcface/backend-oic/tree/main/src/ethics-committe/"
    click IntegrityService "https://github.com/rtcface/backend-oic/tree/main/src/integrity-rules/"
    click KpisService "https://github.com/rtcface/backend-oic/tree/main/src/kpis/"
    click MenuService "https://github.com/rtcface/backend-oic/tree/main/src/menu/"
    click PlanWorkService "https://github.com/rtcface/backend-oic/tree/main/src/plan-work/"
    click UsersService "https://github.com/rtcface/backend-oic/tree/main/src/users/"

    %% Click Events for Supporting Infrastructure
    click Config "https://github.com/rtcface/backend-oic/blob/main/src/configuration/configuration.ts"
    click MainApp "https://github.com/rtcface/backend-oic/blob/main/src/main.ts"
    %% Environment configuration appears in both areas; using same file for deployment and infra.
    click Env "https://github.com/rtcface/backend-oic/blob/main/.env.example"
    
    %% Click Events for Deployment Files
    click Docker "https://github.com/rtcface/backend-oic/tree/main/Dockerfile"
    click Compose "https://github.com/rtcface/backend-oic/blob/main/Tem-docker-compose.yml"
    click Proc "https://github.com/rtcface/backend-oic/tree/main/Procfile"

    %% Click Event for Testing Folder
    click E2E "https://github.com/rtcface/backend-oic/tree/main/test/"
```
