# meghnakorim/vp-portal architecture

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

- Interactive diagram: https://gitdiagram.com/meghnakorim/vp-portal
- Repository: https://github.com/meghnakorim/vp-portal

## Overview

##### Project type and purpose
- This is a full-stack web application–the “VP Portal”–that provides a Request Management System.
- Frontend: a React.js single-page application deployed as a static site on AWS S3.
- Backend: a Node.js/Express.js REST API server.
- Database: MongoDB for persisting users and requests.
- File storage: local “uploads” folder (could be swapped for S3) for attachments.
- Email service: SMTP or a mail API for notifications and OTP.

##### File structure
- Top-level directories:
- frontend/ – React app source, components, pages, context, public assets
- backend/ – Express.js server, controllers, routes, models, middleware, utils, and file uploads
- MVC pattern in backend:
- models/ define Mongoose schemas (User, Request)
- controllers/ implement business logic (auth, request handling, file upload)
- routes/ map HTTP paths to controllers
- scripts/ for initial setup (createAdmin, setupDatabase).
- utils/ for helper functions (sendEmail, sendOtpMail, tempStorage).
- package.json files for each tier describe dependencies.
- GitHub-style README outlines purpose, tech stack, deployment.

##### README for additional insights
- Describes core flows: user registration, login, submit request, admin approval/rejection with email notifications.
- Tech stack summary: React + MUI + Recharts, Node/Express, MongoDB, AWS S3.

##### Key details to capture
- Authentication middleware intercepting specific routes.
- Role-based access: admin vs. student/faculty.
- Data flow for critical user stories: Submit Request, Admin Approve/Reject, Email notification.
- Initialization scripts (createAdmin, setupDatabase) can be shown as one-off deployment tasks.

##### Final recommendations
- Expanded view (subcomponents inside the Express API, including controllers, middleware, utils).
- Iterate with the team to refine any missing external integrations (e.g., authentication provider, monitoring).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["React Single-Page Application"]:::frontend
        IndexJS["Frontend Entry Point\n(index.js)"]:::frontend
        AppJS["Root Component\n(App.js)"]:::frontend
        Components["UI Components"]:::frontend
        Pages["Page Views"]:::frontend
        Context["React Context\n(AuthContext.js)"]:::frontend
        Public["Static Public Assets\n(index.html)"]:::frontend
    end

    %% Hosting Layer
    subgraph "Hosting Layer"
        S3["AWS S3 (Static CDN)"]:::external
    end

    %% API Layer
    subgraph "API Layer"
        API["Express.js API Server"]:::backend
        IndexAPI["API Entry Point\n(index.js)"]:::backend
        Middleware["Auth Middleware\n(auth.js)"]:::backend
        subgraph "Controllers"
            AuthCtrl["Authentication Controller"]:::backend
            RequestCtrl["Request Handling Controller"]:::backend
            UploadCtrl["File Upload Controller"]:::backend
        end
        subgraph "Routes"
            AuthRoutes["Authentication Routes"]:::backend
            RequestRoutes["Request Routes"]:::backend
            UploadRoutes["File Upload Routes"]:::backend
        end
        subgraph "Models"
            UserModel["User Schema"]:::database
            RequestModel["Request Schema"]:::database
        end
        subgraph "Utils"
            EmailUtil["Email Utility"]:::backend
            OtpUtil["OTP Email Utility"]:::backend
            TempStorage["Temporary Storage Utility"]:::backend
        end
        subgraph "Scripts"
            CreateAdmin["createAdmin.js"]:::backend
            SetupDB["setupDatabase.js"]:::backend
        end
        Uploads["File Storage\n(uploads/)"]:::external
        EmailService["Email Service\n(SMTP/SES)"]:::external
    end

    %% Data Layer
    subgraph "Data Layer"
        MongoDB["MongoDB Database"]:::database
    end

    %% Flows
    Browser -->|"Initial Load"| S3
    Browser -->|"API Calls (Auth, Requests, Upload)"| API
    S3 -->|Serves| Browser
    API -->|uses middleware| Middleware
    API -->|routes| AuthRoutes
    API -->|routes| RequestRoutes
    API -->|routes| UploadRoutes
    Middleware --> AuthCtrl
    AuthRoutes --> AuthCtrl
    RequestRoutes --> RequestCtrl
    UploadRoutes --> UploadCtrl
    AuthCtrl -->|CRUD| UserModel
    RequestCtrl -->|CRUD| RequestModel
    UploadCtrl -->|Stores Files| Uploads
    API -->|calls| EmailService
    EmailService -.->|sends emails| Browser
    API -->|connects to| MongoDB
    API --> EmailUtil
    API --> OtpUtil
    API --> TempStorage
    API --> CreateAdmin
    API --> SetupDB

    %% Click Events
    click Browser "https://github.com/meghnakorim/vp-portal/tree/main/frontend/src"
    click IndexJS "https://github.com/meghnakorim/vp-portal/blob/main/frontend/src/index.js"
    click AppJS "https://github.com/meghnakorim/vp-portal/blob/main/frontend/src/App.js"
    click Components "https://github.com/meghnakorim/vp-portal/tree/main/frontend/src/components"
    click Pages "https://github.com/meghnakorim/vp-portal/tree/main/frontend/src/pages"
    click Context "https://github.com/meghnakorim/vp-portal/blob/main/frontend/src/context/AuthContext.js"
    click Public "https://github.com/meghnakorim/vp-portal/blob/main/frontend/public/index.html"
    click IndexAPI "https://github.com/meghnakorim/vp-portal/blob/main/backend/index.js"
    click AuthCtrl "https://github.com/meghnakorim/vp-portal/blob/main/backend/controllers/authController.js"
    click RequestCtrl "https://github.com/meghnakorim/vp-portal/blob/main/backend/controllers/requestController.js"
    click UploadCtrl "https://github.com/meghnakorim/vp-portal/blob/main/backend/controllers/uploadController.js"
    click Middleware "https://github.com/meghnakorim/vp-portal/blob/main/backend/middleware/auth.js"
    click UserModel "https://github.com/meghnakorim/vp-portal/blob/main/backend/models/User.js"
    click RequestModel "https://github.com/meghnakorim/vp-portal/blob/main/backend/models/Request.js"
    click AuthRoutes "https://github.com/meghnakorim/vp-portal/blob/main/backend/routes/auth.js"
    click RequestRoutes "https://github.com/meghnakorim/vp-portal/blob/main/backend/routes/requestRoutes.js"
    click UploadRoutes "https://github.com/meghnakorim/vp-portal/blob/main/backend/routes/uploadRoutes.js"
    click EmailUtil "https://github.com/meghnakorim/vp-portal/blob/main/backend/utils/sendEmail.js"
    click OtpUtil "https://github.com/meghnakorim/vp-portal/blob/main/backend/utils/sendotpmail.js"
    click TempStorage "https://github.com/meghnakorim/vp-portal/blob/main/backend/utils/tempStorage.js"
    click Uploads "https://github.com/meghnakorim/vp-portal/tree/main/backend/uploads"
    click CreateAdmin "https://github.com/meghnakorim/vp-portal/blob/main/backend/scripts/createAdmin.js"
    click SetupDB "https://github.com/meghnakorim/vp-portal/blob/main/backend/scripts/setupDatabase.js"

    %% Styles
    classDef frontend fill:#FFA500,stroke:#333,stroke-width:1px
    classDef backend fill:#8FBC8F,stroke:#333,stroke-width:1px
    classDef external fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef database fill:#90EE90,stroke:#333,stroke-width:1px
```
