# mn-987/innovadigits-pms-backend architecture

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

- Interactive diagram: https://gitdiagram.com/mn-987/innovadigits-pms-backend
- Repository: https://github.com/mn-987/innovadigits-pms-backend

## Overview

##### Project Type Analysis
This is a backend REST API service for a Performance Management System, built with Node.js, following a modular architecture pattern. The project is structured around three core modules: Users/Teams, Competencies, and Feedback.

##### Main Components

A. Core Layers (Vertical Layers):
- API Layer (Routes)
- Controller Layer
- Service Layer
- Data Layer (Models)
- Middleware Layer
- Utility Layer

B. Cross-cutting Concerns:
- Authentication & Authorization
- Validation
- Error Handling
- Database Connection

**[Client Applications]**
- ↓
**[API Gateway/Routes]**
- ↓
**[Authentication & Validation Middleware]**
- ↓
**[Controllers]**
- ↓
**[Services]**
- ↓
**[Data Models]**
- ↓
**[Database]**

##### Detailed Component Breakdown

**Users & Teams Module:**
- User Management
- Team Management
- Authentication

**Competencies Module:**
- Categories
- Levels
- Competencies

**Feedback Module:**
- Feedback Management
- Feedback Metadata

B. Cross-cutting Concerns (show as vertical bars):
- Error Handling (util/errorHandling.js)
- Validation (middleware/validator)
- Authentication (middleware/auth)

##### Key Relationships to Highlight

- Dependency flow between modules (Users → Competencies → Feedback)
- Middleware chain for API requests
- Demonstrate the database relationships between models
- Authentication flow and how it integrates with other components

##### Technical Details

Database Layer:
- MongoDB connection (config/dbConnection.js)
- Model relationships

API Layer:
- Route groupings (auth, user, team, competency, feedback)
- Middleware chains

Service Layer:
- Business logic separation
- Inter-service communications

##### Additional Recommendations

- Notes for important architectural decisions
- Security boundaries and authentication checkpoints
- Public vs. protected endpoints

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Applications"]
        ClientApp["Web/Mobile Clients"]
    end

    subgraph API["API Gateway Layer"]
        AuthRoutes["Authentication Routes"]:::api
        UserRoutes["User Routes"]:::api
        TeamRoutes["Team Routes"]:::api
        CompRoutes["Competency Routes"]:::api
        FeedbackRoutes["Feedback Routes"]:::api
    end

    subgraph Security["Security Layer"]
        Auth["Authentication"]:::security
        Validation["Validation"]:::security
    end

    subgraph Controllers["Controller Layer"]
        AuthController["Auth Controller"]:::controller
        UserController["User Controller"]:::controller
        TeamController["Team Controller"]:::controller
        CompController["Competency Controller"]:::controller
        FeedbackController["Feedback Controller"]:::controller
    end

    subgraph Services["Service Layer"]
        AuthService["Auth Service"]:::service
        UserService["User Service"]:::service
        TeamService["Team Service"]:::service
        CompService["Competency Service"]:::service
        FeedbackService["Feedback Service"]:::service
    end

    subgraph Data["Data Layer"]
        UserModel["User Model"]:::data
        TeamModel["Team Model"]:::data
        CompModel["Competency Model"]:::data
        FeedbackModel["Feedback Model"]:::data
        MetadataModel["Feedback Metadata Model"]:::data
    end

    subgraph DB["Database"]
        MongoDB[(MongoDB)]:::database
    end

    subgraph Utils["Utility Layer"]
        ErrorHandling["Error Handling"]:::util
        DBConnection["Database Connection"]:::util
    end

    %% Connections
    ClientApp --> API
    
    AuthRoutes --> Auth
    UserRoutes --> Auth
    TeamRoutes --> Auth
    CompRoutes --> Auth
    FeedbackRoutes --> Auth

    Auth --> AuthController
    Auth --> UserController
    Auth --> TeamController
    Auth --> CompController
    Auth --> FeedbackController

    AuthController --> AuthService
    UserController --> UserService
    TeamController --> TeamService
    CompController --> CompService
    FeedbackController --> FeedbackService

    AuthService --> UserModel
    UserService --> UserModel
    TeamService --> TeamModel
    CompService --> CompModel
    FeedbackService --> FeedbackModel
    FeedbackService --> MetadataModel

    UserModel --> MongoDB
    TeamModel --> MongoDB
    CompModel --> MongoDB
    FeedbackModel --> MongoDB
    MetadataModel --> MongoDB

    DBConnection --> MongoDB

    %% Click Events
    click AuthRoutes "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/routes/auth.routes.js"
    click UserRoutes "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/routes/user.routes.js"
    click TeamRoutes "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/routes/team.routes.js"
    click CompRoutes "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/routes/competency.routes.js"
    click FeedbackRoutes "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/routes/feedback.routes.js"
    
    click AuthController "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/controller/auth.controller.js"
    click UserController "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/controller/user.controller.js"
    click TeamController "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/controller/team.controller.js"
    click CompController "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/controller/competency.controller.js"
    click FeedbackController "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/controller/feedback.controller.js"
    
    click AuthService "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/service/auth.service.js"
    click UserService "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/service/user.service.js"
    click TeamService "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/service/team.service.js"
    click CompService "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/service/competency.service.js"
    click FeedbackService "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/service/feedback.service.js"
    
    click UserModel "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/data/user.model.js"
    click TeamModel "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/data/team.model.js"
    click CompModel "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/data/competency.model.js"
    click FeedbackModel "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/data/feedback.model.js"
    click MetadataModel "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/data/feedback.metadata.model.js"
    
    click Auth "https://github.com/MN-987/innovaDigits-PMS-Backend/tree/main/middleware/auth"
    click Validation "https://github.com/MN-987/innovaDigits-PMS-Backend/tree/main/middleware/validator"
    click ErrorHandling "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/util/errorHandling.js"
    click DBConnection "https://github.com/MN-987/innovaDigits-PMS-Backend/blob/main/config/dbConnection.js"

    %% Styles
    classDef api fill:#2196F3,stroke:#1565C0,color:white
    classDef security fill:#F44336,stroke:#C62828,color:white
    classDef controller fill:#4CAF50,stroke:#2E7D32,color:white
    classDef service fill:#009688,stroke:#00695C,color:white
    classDef data fill:#FFC107,stroke:#FFA000,color:black
    classDef database fill:#607D8B,stroke:#455A64,color:white
    classDef util fill:#9E9E9E,stroke:#616161,color:white
```
