# its-shinde4241/intelliroom architecture

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

- Interactive diagram: https://gitdiagram.com/its-shinde4241/intelliroom
- Repository: https://github.com/its-shinde4241/intelliroom

## Overview

##### Project Type & Purpose
- This is a full-stack, collaborative real-time code editor and execution platform (“IntelliRoom”).
- Frontend: React + TypeScript + Vite, hosting Monaco Editor, UI components, state stores, auth flows.
- Backend: Node.js + Express + TypeScript, serving REST API, WebSockets, auth verification, Prisma ORM to MySQL.
- External Services: Firebase Auth for user identity; Judge0 API for code compilation/execution.

##### File Structure Analysis
- Top-level “frontend” and “backend” directories signal clear separation of client and server.
- Frontend subfolders: components/, pages/, store (Zustand), lib (axios + firebase helpers), hooks.
- Backend subfolders: controller (route handlers), routes (Express routers), middleware (auth guard), db (Prisma + Firebase Admin), lib (constants + helpers), websocket support.
- Prisma schema under backend/prisma. Config files: tsconfig, nodemon.json, package.json.

##### Key README Insights
- Describes architecture: React UI ↔ Express API ↔ MySQL via Prisma; real-time via WebSocket; Firebase Auth; Judge0 for execution.
- Enumerates API endpoints (auth, rooms, files, projects).
- Lists environment variables and deployment steps.
- Emphasizes security and extensibility.

##### Main Components
a. Client (Browser)
- React App (Monaco Editor, UI, Zustand stores, React Router)
- HTTP (REST) for CRUD (auth, rooms, files, projects)
- WebSocket (real-time code sync, presence)
- Firebase JS SDK for sign-in flows
b. Web Server
- Express API (controllers, routes, middleware)
- Auth verification (Firebase Admin SDK)
- WebSocket server (via Express‐integrated ws library or socket.io‐style)
c. Database
- MySQL, accessed by Prisma Client
- Entities: User, Room, Project, File, Message
d. External Services
- Firebase Auth (OAuth + email/password)
- Judge0 API (code compilation/execution)
e. (Optional) Gemini AI integration via external generative‐language API

##### Relationships & Interactions
- Client → HTTP → Express REST endpoints
- Client → WebSocket → Real-time channels per room
- Express → Prisma → MySQL for persistent data
- Express → Firebase Admin → Verify ID tokens
- Express → Judge0 API → Execute code, return results
- Client ← HTTP/WebSocket (data + events)

##### Architectural Patterns & Principles
- Layered architecture: UI → Application/Service layer (controllers) → Data access layer (Prisma + Firebase Admin)
- Separation of concerns: REST for CRUD, WebSockets for real-time sync
- Stateless HTTP, stateful WebSocket channels
- Environment-driven configuration, secure credentials via env vars

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend"
        direction TB
        ReactApp["React App"]:::internal
        UIComponents["UI Components"]:::internal
        StateStore["State Store (Zustand)"]:::internal
        HTTPClient["HTTP Client"]:::internal
        WSClient["WebSocket Client"]:::internal
        FirebaseSDK["Firebase JS SDK"]:::internal
    end

    %% Backend Layer
    subgraph "Backend"
        direction TB
        ExpressServer["Express API Server"]:::internal
        subgraph "Controllers"
            AuthController["Auth Controller"]:::internal
            RoomController["Room Controller"]:::internal
            FileController["File Controller"]:::internal
            ProjectController["Project Controller"]:::internal
        end
        subgraph "Routes"
            AuthRoutes["Auth Routes"]:::internal
            RoomRoutes["Room Routes"]:::internal
            FileRoutes["File Routes"]:::internal
            ProjectRoutes["Project Routes"]:::internal
            AgentRouter["Agent Router"]:::internal
        end
        AuthMiddleware["Auth Middleware"]:::internal
        WSServer["WebSocket Server"]:::internal
        FirebaseAdmin["Firebase Admin"]:::internal
        PrismaService["Prisma Service"]:::internal
        Constants["Constants"]:::internal
        JWTHelper["JWT Helpers"]:::internal
        JudgeHelper["Judge0 Integration"]:::internal
    end

    %% Database
    subgraph "Database"
        direction TB
        MySQL["MySQL Database"]:::db
        PrismaSchema["Prisma Schema"]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        FirebaseAuth["Firebase Auth"]:::external
        Judge0API["Judge0 API"]:::external
    end

    %% Data Flows
    ReactApp -->|"uses"| UIComponents
    ReactApp -->|"manages state"| StateStore
    ReactApp -->|"REST API calls"| HTTPClient
    ReactApp -->|"WebSocket: codeSync"| WSClient
    ReactApp -->|"auth flows"| FirebaseSDK

    HTTPClient -->|"HTTP: GET/POST /api/*"| ExpressServer
    WSClient -->|"WS: codeSync, presence"| WSServer

    ExpressServer -->|"handles routes"| AuthRoutes
    ExpressServer -->|"handles routes"| RoomRoutes
    ExpressServer -->|"handles routes"| FileRoutes
    ExpressServer -->|"handles routes"| ProjectRoutes
    ExpressServer -->|"handles routes"| AgentRouter

    AuthRoutes -->|"calls"| AuthController
    RoomRoutes -->|"calls"| RoomController
    FileRoutes -->|"calls"| FileController
    ProjectRoutes -->|"calls"| ProjectController
    AgentRouter -->|"calls"| JudgeHelper

    ExpressServer -->|"middleware"| AuthMiddleware
    AuthMiddleware -->|"verifies token"| FirebaseAdmin
    ExpressServer -->|"executes code"| JudgeHelper

    ExpressServer -->|"DB operations"| PrismaService
    PrismaService -->|"schema defined in"| PrismaSchema
    PrismaService -->|"connects to"| MySQL

    FirebaseSDK -->|"OAuth, ID token"| FirebaseAuth
    FirebaseAdmin -->|"verifies token"| FirebaseAuth

    JudgeHelper -->|"executes code"| Judge0API

    %% Click Events
    click ReactApp "https://github.com/its-shinde4241/intelliroom/blob/main/frontend/src/App.tsx"
    click UIComponents "https://github.com/its-shinde4241/intelliroom/tree/main/frontend/src/components/"
    click StateStore "https://github.com/its-shinde4241/intelliroom/tree/main/frontend/src/store/"
    click HTTPClient "https://github.com/its-shinde4241/intelliroom/blob/main/frontend/src/lib/axiosInstance.ts"
    click FirebaseSDK "https://github.com/its-shinde4241/intelliroom/blob/main/frontend/src/lib/firebase.ts"
    click WSClient "https://github.com/its-shinde4241/intelliroom/blob/main/frontend/src/lib/helper.ts"
    click ExpressServer "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/index.ts"
    click AuthController "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/controller/authController.ts"
    click RoomController "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/controller/roomController.ts"
    click FileController "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/controller/fileController.ts"
    click ProjectController "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/controller/projectController.ts"
    click AuthRoutes "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/routes/authRoutes.ts"
    click RoomRoutes "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/routes/roomRoutes.ts"
    click FileRoutes "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/routes/fileRoutes.ts"
    click ProjectRoutes "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/routes/projectRoutes.ts"
    click AgentRouter "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/routes/agentRouter.ts"
    click AuthMiddleware "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/middleware/auth.ts"
    click WSServer "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/lib/websocket.ts"
    click FirebaseAdmin "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/db/firebase.ts"
    click PrismaService "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/db/prisma.ts"
    click PrismaSchema "https://github.com/its-shinde4241/intelliroom/blob/main/backend/prisma/schema.prisma"
    click JudgeHelper "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/lib/helper.ts"
    click Constants "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/lib/constants.ts"
    click JWTHelper "https://github.com/its-shinde4241/intelliroom/blob/main/backend/src/lib/jwt.ts"

    %% Styles
    classDef internal fill:#ccffcc,stroke:#006600,stroke-width:1px
    classDef db fill:#cce5ff,stroke:#003366,stroke-width:1px
    classDef external fill:#ffe0b3,stroke:#cc6600,stroke-width:1px
```
