# vavilla-rupesh/nrolehub_v_2 architecture

> Architecture diagram of the GitHub repository vavilla-rupesh/nrolehub_v_2, 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/vavilla-rupesh/nrolehub_v_2
- Repository: https://github.com/vavilla-rupesh/nrolehub_v_2

## Overview

##### Main Components
- Frontend Client: Represented by the "src" folder. This includes the React-based UI components, organized into pages and features for students, admins, and authentication. Note the use of Vite for development and Tailwind CSS for styling.
- Backend Server: Located in the "server/server" folder. It is built on Node.js and Express, with clearly separated API routes (in the routes folder) and modularized functionality (in the modules folder) for areas such as authentication, admin operations, events, payments, certificates, complaints, and notifications.
- External Services: Incorporate external communications such as payment gateways (via payment modules and paymentSignature logic) and email systems (mailer utility). Also note file uploads managed through “multer” for events-related files.

##### Relationships and Data Flow
- Within the Backend, illustrate how middleware (e.g., auth.middleware.js) intercepts requests, and how controllers within each module (like auth.controller.js, events.controller.js, etc.) handle business logic.
- Pathways to external services for payment processing, email notifications, and file management (uploads and certificates).

##### Architectural Patterns and Design Principles
- Modular Structure: Divide the backend into separate modules, each with its own controller, model, and service (e.g., auth, events, certificates, payments) which follows a service-oriented architecture.
- MVC-Like Organization: Even though not strictly MVC, the division into controllers (handling requests), models (data schema), and services (business logic) is evident.
- Separation of Concerns: Clearly demarcate the roles between frontend and backend, and within backend services and utilities.
- Use of Middleware: Emphasize the use of Express middleware to manage cross-cutting concerns like authentication and request processing.

##### Relevant Technologies and Tools
- For the Frontend: Vite, React, and Tailwind CSS.
- For the Backend: Node.js, Express, and PostgreSQL.
- Additional libraries/utilities include ESLint for code quality, and tools for payment signature verification, file uploads (multer), and email notifications.

##### Final Touches
- Component has a clear label.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "NRolEHub Frontend"
        FE["NRolEHub Frontend\n(React, Vite, Tailwind CSS)"]:::frontend
        FE_UI["UI Components & Pages"]:::frontend
    end

    subgraph "Backend Server"
        BS["Backend Server\n(Node.js & Express)"]:::backend
        API["API Routes\n(RESTful endpoints)"]:::backend
        MW["Middleware\n(Auth Middleware)"]:::backend
        subgraph "Modules"
            AuthM["Authentication Module\n(login, registration)"]:::module
            AdminM["Admin Module\n(admin operations)"]:::module
            EventsM["Events Module\n(event management, file uploads)"]:::module
            CertM["Certificates Module\n(certificate generation)"]:::module
            PayM["Payments Module\n(payment processing)"]:::module
            ComplaintsM["Complaints Module\n(handling complaints)"]:::module
            LeaderM["Leaderboard Module\n(tracking results)"]:::module
            NotifM["Notifications Module\n(email, in-app)"]:::module
        end
        subgraph "Utilities"
            MulterUtil["File Upload Utility"]:::utility
            PaymentSig["Payment Signature Utility"]:::utility
            MailerUtil["Email/Mailer Utility"]:::utility
        end
        DBConf["Database Config\n(PostgreSQL)"]:::config
    end

    subgraph "External Services"
        PaymentEx["Payment Gateway"]:::external
        EmailEx["Email Service"]:::external
        FileEx["File Storage"]:::external
    end

    %% Connections
    FE --> FE_UI
    FE -->|"RESTAPICalls"| API
    BS --> API
    API --> MW
    MW --> AuthM
    MW --> AdminM
    MW --> EventsM
    MW --> CertM
    MW --> PayM
    MW --> ComplaintsM
    MW --> LeaderM
    MW --> NotifM

    AuthM --> DBConf
    AdminM --> DBConf
    EventsM --> DBConf
    CertM --> DBConf
    PayM --> DBConf
    ComplaintsM --> DBConf
    LeaderM --> DBConf
    NotifM --> DBConf

    EventsM --> MulterUtil
    PayM --> PaymentSig
    NotifM --> MailerUtil

    PayM --> PaymentEx
    NotifM --> EmailEx
    EventsM --> FileEx

    %% Styles
    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef module fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef utility fill:#D1C4E9,stroke:#7E57C2,stroke-width:2px;
    classDef external fill:#FFCCBC,stroke:#D84315,stroke-width:2px;
    classDef config fill:#FFE0B2,stroke:#FB8C00,stroke-width:2px;

    %% Click Events
    click FE "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/src"
    click FE_UI "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/src/components"
    click BS "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/server/server"
    click API "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/server/server/api/routes"
    click MW "https://github.com/vavilla-rupesh/nrolehub_v_2/blob/main/server/server/api/middleware/auth.middleware.js"
    click AuthM "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/server/server/modules/auth"
    click AdminM "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/server/server/modules/admin"
    click EventsM "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/server/server/modules/events"
    click CertM "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/server/server/modules/certificates"
    click PayM "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/server/server/modules/payments"
    click PaymentSig "https://github.com/vavilla-rupesh/nrolehub_v_2/blob/main/server/server/modules/payments/utils/signatureVerification.js"
    click ComplaintsM "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/server/server/modules/complaint"
    click LeaderM "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/server/server/modules/leaderboard"
    click NotifM "https://github.com/vavilla-rupesh/nrolehub_v_2/tree/main/server/server/modules/notifications"
    click MailerUtil "https://github.com/vavilla-rupesh/nrolehub_v_2/blob/main/server/server/utils/mailer.js"
    click MulterUtil "https://github.com/vavilla-rupesh/nrolehub_v_2/blob/main/server/server/utils/multer.js"
    click DBConf "https://github.com/vavilla-rupesh/nrolehub_v_2/blob/main/server/server/config/dataBase.js"
```
