# harshit-exe/vjti-appnew architecture

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

- Interactive diagram: https://gitdiagram.com/harshit-exe/vjti-appnew
- Repository: https://github.com/harshit-exe/vjti-appnew

## Overview

##### Project Type & Purpose
- Full-stack web application built on Next.js (app router) with React components, Tailwind CSS, and serverless API routes.
- Purpose: Provide a VR-inspired collaboration environment for remote workers, integrating AI-powered tools (content generation, automated scheduling), real-time chat/video, document editing, and wellness features.

##### High-Level Architecture Components
A. Client (Web Browser)
– Tech: React + Next.js pages under src/app, UI components, Tailwind CSS.
– Features:
- Authentication flows (login, signup, OTP)
- Role-based sections (Admin, Department-Head, Employee)
- VR Meeting pages, Real-time doc editor, Chat UI, Video calls, Task dashboards, Wellness tools.
B. Next.js Server / API Layer (Serverless Functions)
– Located in pages/api (e.g., socket/io.js).
– Responsibilities:
- REST / RPC endpoints for data fetching (user/profile/task management).
- WebSocket (Socket.IO) server for real-time chat/video signaling.
- Authentication / session management.
C. Database / Persistence
– Not explicit in code, but implied: external database (e.g., MongoDB, PostgreSQL, or Sanity/Groq).
– Stores users, departments, tasks, chat history, meeting metadata.
D. External AI Services
– Hooks: useAI, useGroqAI, groqAI.js suggest connection to an AI backend (possibly OpenAI or a custom Groq endpoint).
– Responsibilities: content generation, prompt optimization.
E. CDN / Static Assets
– Hosted via Vercel or similar.
F. Hosting / Deployment
– Vercel serverless platform (next.config.mjs present).
– Builds & deploys front and back ends together.

##### Relationships & Data Flows
1. Browser ↔ Next.js Server
- Initial page render (SSR/SSG).
- API calls over HTTPS for CRUD operations (tasks, departments, user data).
2. Browser ↔ WebSocket Server
- Real-time chat messages, video call signaling, collaborative editing presence.
3. Next.js Server ↔ Database
- Reads/writes user profiles, tasks, chat logs.
4. Next.js Server ↔ External AI API
- For generating content, automating scheduling.
5. Browser ↔ CDN
- Loads static assets, images, client JS bundles.

##### Architectural Patterns & Principles
- Modular UI components (src/components/*) separated by domain (auth, admin, employee, editor, socket, ui primitives).
- App router conventions: grouping by user roles and features under src/app/(auth), (company), (department-head), (employee).
- Serverless functions for thin backend layer—scales with usage.
- Real-time event-driven via Socket.IO.
- Hooks for encapsulating business logic (AI calls, tokenization, toast notifications).

– Component labels (e.g., Next.js App Router, Socket.IO Server, AI Hook Service).
– Group related components in containers (e.g., “src/components/editor” under Editor UI).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        EmployeeBrowser["Employee Browser"]:::ui
        DeptHeadBrowser["Department-Head Browser"]:::ui
        AdminBrowser["Admin Browser"]:::ui
    end

    %% Frontend Components
    subgraph "Next.js Frontend" 
        direction TB
        AuthFlow["Authentication Flow"]:::ui
        AdminDash["Admin Dashboard"]:::ui
        DeptHeadDash["Dept-Head Dashboard"]:::ui
        EmployeeDash["Employee Dashboard"]:::ui
        VRMeeting["VR Meeting Page"]:::ui
    end

    %% Backend Layer
    subgraph "Backend Layer" 
        direction TB
        APIGateway["Serverless API Gateway"]:::api
        SocketServer["Socket.IO Signaling Server"]:::realtime
        AIConnector["AI Service Connector"]:::ai
    end

    %% Data Layer
    subgraph "Data & Storage"
        direction TB
        Database["Database"]:::db
        CDN["Static Assets CDN"]:::db
        ExternalAI["External AI APIs"]:::ai
    end

    %% Connections
    EmployeeBrowser -->|HTTPS REST| AuthFlow
    DeptHeadBrowser -->|HTTPS REST| AuthFlow
    AdminBrowser -->|HTTPS REST| AuthFlow

    AuthFlow -->|REST| APIGateway
    EmployeeBrowser -->|REST| EmployeeDash
    DeptHeadBrowser -->|REST| DeptHeadDash
    AdminBrowser -->|REST| AdminDash
    EmployeeBrowser -->|CSR| VRMeeting

    EmployeeDash -->|REST| APIGateway
    DeptHeadDash -->|REST| APIGateway
    AdminDash -->|REST| APIGateway

    EmployeeBrowser -->|WS Events| SocketServer
    DeptHeadBrowser -->|WS Events| SocketServer
    AdminBrowser -->|WS Events| SocketServer

    APIGateway -->|DB Queries| Database
    APIGateway -->|Invoke| AIConnector
    SocketServer -->|DB Writes| Database
    AIConnector -->|HTTP| ExternalAI

    EmployeeBrowser -->|GET Static| CDN
    DeptHeadBrowser -->|GET Static| CDN
    AdminBrowser -->|GET Static| CDN

    %% Click Events
    click AuthFlow "https://github.com/harshit-exe/vjti-appnew/tree/main/src/app/(auth)"
    click AdminDash "https://github.com/harshit-exe/vjti-appnew/tree/main/src/app/(company)/admin"
    click DeptHeadDash "https://github.com/harshit-exe/vjti-appnew/tree/main/src/app/(department-head)/tl-dashboard"
    click EmployeeDash "https://github.com/harshit-exe/vjti-appnew/tree/main/src/app/(employee)/dashboard"
    click VRMeeting "https://github.com/harshit-exe/vjti-appnew/blob/main/src/app/meeting/[roomID]/page.js"
    click SocketServer "https://github.com/harshit-exe/vjti-appnew/blob/main/pages/api/socket/io.js"
    click EditorUI "https://github.com/harshit-exe/vjti-appnew/blob/main/src/components/editor/Editor.jsx"
    click AIConnector "https://github.com/harshit-exe/vjti-appnew/blob/main/src/hooks/useAI.js"
    click UIPrimitives "https://github.com/harshit-exe/vjti-appnew/tree/main/src/components/ui"
    click GlobalLayout "https://github.com/harshit-exe/vjti-appnew/blob/main/src/app/layout.js"
    click StaticAssets "https://github.com/harshit-exe/vjti-appnew/tree/main/public/"
    click NextConfig "https://github.com/harshit-exe/vjti-appnew/blob/main/next.config.mjs"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366D6,stroke-width:1px
    classDef api fill:#D6F5D6,stroke:#228B22,stroke-width:1px
    classDef realtime fill:#FFE5B4,stroke:#FF8C00,stroke-width:1px
    classDef db fill:#E0E0E0,stroke:#606060,stroke-width:1px
    classDef ai fill:#F3E5FF,stroke:#800080,stroke-width:1px
```
