# marcortes22/nandayurebackend architecture

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

- Interactive diagram: https://gitdiagram.com/marcortes22/nandayurebackend
- Repository: https://github.com/marcortes22/nandayurebackend

## Overview

##### Main Components
- App Layer – The entry point (src/main.ts) and the top-level module (src/app.module.ts) that imports and configures all the individual domain modules.
- Domain Modules – Each folder under src (e.g., “analitics”, “annuities”, “attendance”, “auth”, “departments”, “payroll”, etc.) represents a domain module that comprises:
– Controllers: Manage HTTP endpoints (e.g., “*.controller.ts” files).
– Services: Contain business logic (e.g., “*.service.ts” files).
– DTOs and Entities: Define data transfer objects and data models.
– Repositories & Database Seeders: Handle persistence (often interacting with the “src/db” module and the generic repository pattern in “src/core/generic-repository”)

##### Relationships and Interactions
- Within each module, illustrate a simplified flow:
Controller ⇨ Service ⇨ Repository ⇨ Database.
- External integrations (e.g., mail-client, google-drive-files) linking to the respective modules that use them.
- If applicable, show shared components such as the Core (e.g., exception filters, generic repository) as a “common utilities” or “shared services” block that sits adjacent to all modules.

##### Architectural Patterns & Technologies
- Modular Architecture – Emphasize that each domain module is self-contained and registered in the main application module.
- Layered Pattern – Separate presentation (controllers), business logic (services), persistence (repositories, database drivers), and integration layers.
- Dependency Injection – Mention NestJS’s dependency injection pattern used across controllers, services, and modules.
- Testing – Note the presence of test directories (e.g., “__tests__” and “test”) which underscores that unit and e2e tests accompany these modules.
- Tools/Frameworks – Clearly indicate that the project leverages NestJS (a Node.js framework), TypeScript, and likely an ORM based on the structure of the repository files.

##### Detailing Essential Architectural Elements
- Module is represented visually with internal separation (e.g., list “Controller”, “Service”, “Repository” within each module if space allows).
- Annotations that specify that the project adheres to NestJS best practices such as dependency injection, modular routing, and layered separation of concerns.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application Core"
        Main["Main (src/main.ts)"]:::appLayer
        AppModule["App Module (src/app.module.ts)"]:::appLayer
        Main --> AppModule
    end

    subgraph "Domain Modules"
        Analytics["Analytics Module"]:::domain
        Annuities["Annuities Module"]:::domain
        Attendance["Attendance Module"]:::domain
        Auth["Auth Module"]:::domain
        Dept["Departments Module"]:::domain
        Payroll["Payroll Module"]:::domain
        AuthGuards["Auth Guards"]:::domain

        %% Internal flow for Attendance Module
        AttController["Attendance Controller"]:::domain
        AttService["Attendance Service"]:::domain
        AttRepository["Attendance Repository"]:::domain

        %% Connections from AppModule to each module
        AppModule --> Analytics
        AppModule --> Annuities
        AppModule --> Attendance
        AppModule --> Auth
        AppModule --> Dept
        AppModule --> Payroll

        %% Attendance Module internal flow
        Attendance --> AttController
        AttController --> AttService
        AttService --> AttRepository

        %% Auth module uses guards
        Auth -->|"uses"| AuthGuards

        %% Auth secures certain modules
        Auth ---|"secures"| Attendance
        Auth ---|"secures"| Payroll
    end

    subgraph "External Services"
        MailClient["Mail Client"]:::external
        GoogleDrive["Google Drive Files"]:::external
        Attendance -->|"integrates"| MailClient
        Payroll -->|"integrates"| GoogleDrive
    end

    subgraph "Database & Persistence"
        GenericRepo["Generic Repository"]:::persistence
        Database["Database (ORM, seeding)"]:::persistence
        GenericRepo --> Database
        AttRepository --> GenericRepo
    end

    %% Click Events
    click Main "https://github.com/marcortes22/nandayurebackend/blob/main/src/main.ts"
    click AppModule "https://github.com/marcortes22/nandayurebackend/blob/main/src/app.module.ts"
    click Analytics "https://github.com/marcortes22/nandayurebackend/blob/main/src/analitics/analitics.module.ts"
    click Annuities "https://github.com/marcortes22/nandayurebackend/blob/main/src/annuities/annuities.module.ts"
    click Attendance "https://github.com/marcortes22/nandayurebackend/blob/main/src/attendance/attendance.module.ts"
    click Auth "https://github.com/marcortes22/nandayurebackend/blob/main/src/auth/auth.module.ts"
    click AuthGuards "https://github.com/marcortes22/nandayurebackend/tree/main/src/auth/guards"
    click Dept "https://github.com/marcortes22/nandayurebackend/blob/main/src/departments/departments.module.ts"
    click Payroll "https://github.com/marcortes22/nandayurebackend/blob/main/src/payroll/payroll.module.ts"
    click MailClient "https://github.com/marcortes22/nandayurebackend/blob/main/src/mail-client/mail-client.module.ts"
    click GoogleDrive "https://github.com/marcortes22/nandayurebackend/blob/main/src/google-drive-files/google-drive-files.module.ts"
    click Database "https://github.com/marcortes22/nandayurebackend/tree/main/src/db"
    click GenericRepo "https://github.com/marcortes22/nandayurebackend/tree/main/src/core/generic-repository"

    %% Styles
    classDef appLayer fill:#B3E5FC,stroke:#333,stroke-width:2px;
    classDef domain fill:#C8E6C9,stroke:#333,stroke-width:2px;
    classDef external fill:#FFECB3,stroke:#333,stroke-width:2px;
    classDef persistence fill:#FFF9C4,stroke:#333,stroke-width:2px;
```
