# aaditya-5281/stcmp architecture

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

- Interactive diagram: https://gitdiagram.com/aaditya-5281/stcmp
- Repository: https://github.com/aaditya-5281/stcmp

## Overview

##### Main Components

- Frontend Interface:
- React.js application with Redux for state management and React Router for navigation.
- Contains various UI components such as Login, Home, Attendance, Trainings, and Audit Inspection.
- Utilizes libraries like Chart.js for data visualization and React PDF for generating reports.

- Backend API Layer:
- Node.js server built with Express.js.
- Contains API endpoints grouped under directories like "APIs" (e.g., faculty-api.js and trainings-api.js) that handle business logic such as managing trainings, certifications, and faculty information.

- Database:
- MongoDB serves as the database for storing training records, faculty data, certifications, and other relevant information.

- External Services/Configuration:
- Environment variables (using Dotenv) to configure database connection strings and port settings.
- Cross-Origin Resource Sharing middleware (Cors) ensuring the frontend can communicate with the backend.

##### Relationships and Interactions

- The Frontend sends HTTP requests (likely via RESTful endpoints) to the Backend for data operations.
- The Backend processes these requests and interacts with MongoDB to store, retrieve, and update training and user data.
- Data Flow:
- User actions (such as logging in or querying training details) trigger API calls from React.
- API endpoints in the Express server receive the requests, perform business logic (including generating PDF reports or preparing data for charts), and return JSON responses.
- The frontend then updates the UI accordingly.

##### Architectural Patterns and Design Principles

- Separation of Concerns:
- Clear distinction between the frontend (UI/UX and state management) and backend (API logic and data management).

- Modularization:
- The file structure is organized with dedicated directories for frontend components and backend APIs, which promotes scalability and maintainability.

- Client-Server Communication:
- Defined interactions via HTTP (or potentially WebSocket for real-time updates) between the client and server.

##### Technologies Highlight

- Frontend:
- React.js, Redux, React Router, Bootstrap, Chart.js, React PDF.

- Backend:
- Node.js, Express.js, MongoDB, Cors, Dotenv.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend"
        Login["Login Component"]:::frontend
        Home["Home Component"]:::frontend
        Attendance_Details["Attendance Details"]:::frontend
        Update_Attendance["Update Attendance"]:::frontend
        All_Trainings["All Trainings"]:::frontend
        Create_Trainings["Create Trainings"]:::frontend
        My_Trainings["My Trainings"]:::frontend
        Training_Details["Training Details"]:::frontend
        Trainings["Trainings"]:::frontend
        Update_Training["Update Training"]:::frontend
        Audit_Inspection["Audit Inspection"]:::frontend
        Chart["Chart Visualization"]:::frontend
        Redux_Store["Redux Store"]:::frontend
        User_Slice["User Slice"]:::frontend
    end

    subgraph "Backend"
        Express_Server["Express Server"]:::backend
        Faculty_API["Faculty API"]:::api
        Trainings_API["Trainings API"]:::api
        Backend_Config["Backend Config"]:::config
    end

    subgraph "External Services"
        Env_Config["Environment Config"]:::config
    end

    subgraph "Database"
        MongoDB["((MongoDB Database))"]:::db
    end

    %% Frontend to Backend interactions
    Login -->|"HTTP_Request"| Express_Server
    Trainings -->|"HTTP_Request"| Express_Server
    Audit_Inspection -->|"HTTP_Request"| Express_Server

    %% Internal Frontend relation
    Redux_Store -->|"Manages"| User_Slice

    %% Backend interactions
    Express_Server -->|"delegates_to"| Faculty_API
    Express_Server -->|"delegates_to"| Trainings_API
    Express_Server -->|"CRUD"| MongoDB

    %% External and backend configuration
    Env_Config -.->|"configures"| Express_Server
    Backend_Config -.->|"configures"| Express_Server

    %% Click Events
    click Login "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/Login/Login.js"
    click Home "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/Home.js"
    click Attendance_Details "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/Attendance/AttendanceDetails.js"
    click Update_Attendance "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/Attendance/UpdateAttendance.js"
    click All_Trainings "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/Trainings/AllTrainings.js"
    click Create_Trainings "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/Trainings/CreateTrainings.js"
    click My_Trainings "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/Trainings/MyTrainings.js"
    click Training_Details "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/Trainings/TrainingDetails.js"
    click Trainings "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/Trainings/Trainings.js"
    click Update_Training "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/Trainings/UpdateTraining.js"
    click Audit_Inspection "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/AuditInspection/AuditInspection.js"
    click Chart "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/components/AuditInspection/Chart.js"
    click Redux_Store "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/redux/Store.js"
    click User_Slice "https://github.com/aaditya-5281/stcmp/blob/master/frontend/src/redux/slices/userSlice.js"
    click Express_Server "https://github.com/aaditya-5281/stcmp/blob/master/backend/server.js"
    click Faculty_API "https://github.com/aaditya-5281/stcmp/blob/master/backend/APIs/faculty-api.js"
    click Trainings_API "https://github.com/aaditya-5281/stcmp/blob/master/backend/APIs/trainings-api.js"
    click Backend_Config "https://github.com/aaditya-5281/stcmp/blob/master/backend/package.json"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef backend fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef api fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef config fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef db fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
```
