From e6fd6187b21a79bc4f07b2cd79640875abfd1d72 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sat, 4 Apr 2026 23:17:16 +0530 Subject: [PATCH 01/24] fix: Readme file updated --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 38e5b1a..dcb3986 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ > _Code together. Think faster._ -A real-time collaborative code editor with AI-powered assistance. Multiple users can simultaneously write, edit, and debug code in the same room — with live cursor tracking, instant code synchronization, and an AI assistant powered by Google Gemini that streams responses in real-time. +- A real-time collaborative code editor with AI-powered assistance. Multiple users can simultaneously write, edit, and debug code in the same room — with live cursor tracking, instant code synchronization, and an AI assistant powered by Google Gemini that streams responses in real-time. + +- Designed a stateless backend architecture by replacing in-memory state with Redis, enabling horizontal scaling across multiple server instances. [![CI Pipeline](https://github.com/rah7202/smart-code-lab/actions/workflows/ci.yml/badge.svg)](https://github.com/rah7202/smart-code-lab/actions) From 054ae67b4fb6bcdb54ba10a08e5a9d63830e0fdb Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sat, 4 Apr 2026 23:22:33 +0530 Subject: [PATCH 02/24] fix: Readme file updated --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dcb3986..f5c0764 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,15 @@ > _Code together. Think faster._ -- A real-time collaborative code editor with AI-powered assistance. Multiple users can simultaneously write, edit, and debug code in the same room — with live cursor tracking, instant code synchronization, and an AI assistant powered by Google Gemini that streams responses in real-time. +- **Core System:** A real-time collaborative code editor with AI-powered assistance. Multiple users can simultaneously write, edit, and debug code in the same room — with live cursor tracking, instant code synchronization, and an AI assistant powered by Google Gemini that streams responses in real-time. -- Designed a stateless backend architecture by replacing in-memory state with Redis, enabling horizontal scaling across multiple server instances. +- **Scalability:** Designed a stateless backend architecture by replacing in-memory state with Redis, enabling horizontal scaling across multiple server instances. + +- **AI Integration:** Implemented an AI assistant with streaming responses (SSE), delivering real-time incremental outputs similar to ChatGPT. + +- **Distribution:** Developed a Redis-based data model **(room:{id}:users)** as a single source of truth for user presence, ensuring consistency in distributed environments. + +- **Persistence + reliability:** Built a snapshot persistence system with authenticated fetch keepalive, ensuring code is saved reliably even during page unload events. [![CI Pipeline](https://github.com/rah7202/smart-code-lab/actions/workflows/ci.yml/badge.svg)](https://github.com/rah7202/smart-code-lab/actions) From 364af7e6dbe793b458814664d2d0b83b9ae32511 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 01:21:59 +0530 Subject: [PATCH 03/24] fix: Readme file updated --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f5c0764..8df3e87 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,15 @@ > _Code together. Think faster._ -- **Core System:** A real-time collaborative code editor with AI-powered assistance. Multiple users can simultaneously write, edit, and debug code in the same room — with live cursor tracking, instant code synchronization, and an AI assistant powered by Google Gemini that streams responses in real-time. +- **Real-Time Collaboration:** A real-time collaborative code editor with AI-powered assistance. Multiple users can simultaneously write, edit, and debug code in the same room — with live cursor tracking, instant code synchronization, and an AI assistant powered by Google Gemini that streams responses in real-time. - **Scalability:** Designed a stateless backend architecture by replacing in-memory state with Redis, enabling horizontal scaling across multiple server instances. - **AI Integration:** Implemented an AI assistant with streaming responses (SSE), delivering real-time incremental outputs similar to ChatGPT. -- **Distribution:** Developed a Redis-based data model **(room:{id}:users)** as a single source of truth for user presence, ensuring consistency in distributed environments. +- **Distributed Architecture:** Developed a Redis-based data model **(room:{id}:users)** as a single source of truth for user presence, ensuring consistency in distributed environments. -- **Persistence + reliability:** Built a snapshot persistence system with authenticated fetch keepalive, ensuring code is saved reliably even during page unload events. +- **Persistence & Reliability:** Built a snapshot persistence system with authenticated fetch keepalive, ensuring code is saved reliably even during page unload events. [![CI Pipeline](https://github.com/rah7202/smart-code-lab/actions/workflows/ci.yml/badge.svg)](https://github.com/rah7202/smart-code-lab/actions) From 02088014908b142ea20f592c14b3d92c7d3587af Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 02:14:51 +0530 Subject: [PATCH 04/24] fix: Readme file updated --- README.md | 87 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 8df3e87..033dfd3 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ - **Real-Time Collaboration:** A real-time collaborative code editor with AI-powered assistance. Multiple users can simultaneously write, edit, and debug code in the same room — with live cursor tracking, instant code synchronization, and an AI assistant powered by Google Gemini that streams responses in real-time. -- **Scalability:** Designed a stateless backend architecture by replacing in-memory state with Redis, enabling horizontal scaling across multiple server instances. +- **Scalability:** Designed a stateless backend architecture by replacing in-memory state with Redis, enabling **horizontal scaling across multiple server** instances. -- **AI Integration:** Implemented an AI assistant with streaming responses (SSE), delivering real-time incremental outputs similar to ChatGPT. +- **AI Integration:** Implemented an **AI assistant with streaming responses (SSE)**, delivering real-time incremental outputs similar to ChatGPT. - **Distributed Architecture:** Developed a Redis-based data model **(room:{id}:users)** as a single source of truth for user presence, ensuring consistency in distributed environments. @@ -45,38 +45,56 @@ --- -## Architecture +## System Architecture -``` -┌─────────────────────────────────────┐ -│ Frontend (React) │ -│ ┌──────────┐ ┌──────┐ ┌────────┐ │ -│ │ Monaco │ │ AI │ │Version │ │ -│ │ Editor │ │Panel │ │History │ │ -│ └────┬─────┘ └──┬───┘ └───┬────┘ │ -│ │ │ │ │ -│ ┌────┴──────────┴──────────┴────┐ │ -│ │ Hooks Layer │ │ -│ │ useCollaboration │ │ -│ │ useAI (SSE streaming) │ │ -│ │ useEditorPersistence │ │ -│ └────┬──────────┬──────────┬────┘ │ -└───────┼──────────┼──────────┼───────┘ - │ WebSocket│ REST/SSE │ REST - │ │ │ -┌───────┼──────────┼──────────┼───────┐ -│ │ Backend (Express) │ │ -│ ┌────┴────┐ ┌───┴───┐ ┌───┴────┐ │ -│ │Socket.IO│ │ AI │ │ Room │ │ -│ │ Server │ │Service│ │Service │ │ -│ └────┬────┘ └───┬───┘ └───┬────┘ │ -│ │ │ │ │ -│ ┌────┴──────────┴──────────┴────┐ │ -│ │ Data Layer │ │ -│ │ PostgreSQL Redis │ │ -│ │ (Prisma ORM) (state/adapter)│ │ -│ └───────────────────────────────┘ │ -└─────────────────────────────────────┘ +```mermaid +flowchart TB + subgraph Client["🖥️ Frontend · React 19 + Vite"] + direction LR + Monaco["Monaco Editor"] + AIP["AI Panel"] + VH["Version History"] + end + + subgraph HooksLayer["🪝 Hooks Layer"] + direction LR + HC["useCollaboration"] + HA["useAI"] + HP["useEditorPersistence"] + end + + Client --> HooksLayer + + HC <-->|"WebSocket"| SocketIO + HA <-->|"SSE Stream"| AIRoute + HP <-->|"REST + JWT"| RoomRoute + + subgraph Server["⚙️ Backend · Express 5"] + + MW["Middleware\nHelmet · CORS · Rate Limit · JWT · Zod"] + + subgraph Core["Services"] + direction LR + SocketIO["Socket.IO Server\n+ Redis Adapter"] + AIRoute["AI Service\nGemini 2.5 Flash"] + RoomRoute["Room Service"] + CompileSvc["Compile Service"] + end + + MW --> Core + end + + CompileSvc -->|"HTTP"| Judge0["Judge0 API"] + AIRoute -->|"API"| Gemini["Google Gemini"] + + subgraph DataStores["💾 Data Layer"] + direction LR + PG["PostgreSQL · Prisma\nUser · Room · Snapshot · AIMessage"] + RD["Redis\nRoom State · Presence · Pub/Sub"] + end + + Core --> DataStores + SocketIO -.->|"horizontal scaling"| RD ``` --- @@ -142,7 +160,7 @@ smart-code-lab/ - **Node.js** ≥ 20 - **npm** ≥ 9 -- **PostgreSQL** (local or hosted, e.g., Neon) +- **PostgreSQL** (local or hosted, e.g., Neon DB) - **Redis** (local or hosted, e.g., Render Redis) - **Gemini API Key** — [Get one here](https://aistudio.google.com/apikey) @@ -285,7 +303,6 @@ frontend job (runs after backend passes): | **Yjs / CRDT Integration** | 🔵 Next Major | Replace keystroke broadcasting with binary delta sync for better concurrency | | **Docker Compose** | 🟡 Medium | Redis + PostgreSQL + App in one-command setup | | **More Languages** | 🟡 Medium | Java, Go, Rust, etc. | -| **Room Sharing Link** | 🟢 Easy | Copy-to-clipboard shareable URL | | **AI Context Awareness** | 🔵 Future | Pass execution output to Gemini for smarter debugging | | **JWT Blacklist on Logout** | 🟢 Easy | `redis.set(blacklist:${token})` with TTL | From 9f33911fae39deebd3cfeca271a5ff2b19f2823b Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 03:30:20 +0530 Subject: [PATCH 05/24] fix: Added a copy feature in RoomId input tag --- frontend/src/components/Home.tsx | 37 ++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Home.tsx b/frontend/src/components/Home.tsx index ee8b4d8..5e22559 100644 --- a/frontend/src/components/Home.tsx +++ b/frontend/src/components/Home.tsx @@ -5,12 +5,15 @@ import toast from "react-hot-toast"; import { socket } from "../socket"; import { getUserFromToken } from "../utils/auth"; import { AxiosError } from "axios"; +import { FiCopy } from "react-icons/fi"; +import { FaCheck } from "react-icons/fa" import Footer from "./Footer"; export default function Home() { const navigate = useNavigate(); const [roomId, setRoomId] = useState(""); + const [copied, setCopied] = useState(false); const user = getUserFromToken(); const name = user?.username?.charAt(0).toUpperCase() + user?.username?.slice(1); @@ -47,6 +50,22 @@ export default function Home() { toast.success("Joined room successfully"); }; + const handleCopy = async () => { + if (!roomId) return + + try { + await navigator.clipboard.writeText(roomId); + setCopied(true); + toast.success("Room ID Copied"); + + setTimeout(() => setCopied(false), 1500); + + + } catch { + toast.error("Copy Failed"); + } + }; + const handleLogout = () => { try { @@ -71,10 +90,20 @@ export default function Home() { )}
- { setRoomId(e.target.value) }} /> - +
+ { setRoomId(e.target.value) }} /> + {roomId.trim() && ( + + )} +
+ + From b7f14fb1eaa3f1799e0fb89338f5629cd9b9c194 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 03:30:37 +0530 Subject: [PATCH 06/24] fix: Readme file updated --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 033dfd3..b115dda 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ ```mermaid flowchart TB - subgraph Client["🖥️ Frontend · React 19 + Vite"] + subgraph Client["🖥️ Frontend · React + Vite"] direction LR Monaco["Monaco Editor"] AIP["AI Panel"] @@ -69,7 +69,7 @@ flowchart TB HA <-->|"SSE Stream"| AIRoute HP <-->|"REST + JWT"| RoomRoute - subgraph Server["⚙️ Backend · Express 5"] + subgraph Server["⚙️ Backend · Express"] MW["Middleware\nHelmet · CORS · Rate Limit · JWT · Zod"] @@ -89,7 +89,7 @@ flowchart TB subgraph DataStores["💾 Data Layer"] direction LR - PG["PostgreSQL · Prisma\nUser · Room · Snapshot · AIMessage"] + PG["PostgreSQL · Prisma ORM\nUser · Room · Snapshot · AIMessage"] RD["Redis\nRoom State · Presence · Pub/Sub"] end From 976f17320e75fa89ebcd745b7f96e22a72d8db4f Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 10:04:50 +0530 Subject: [PATCH 07/24] fix: Readme file updated --- backend/README.md | 108 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/backend/README.md b/backend/README.md index 1bea843..0f5ae15 100644 --- a/backend/README.md +++ b/backend/README.md @@ -67,6 +67,114 @@ backend/ ## Architecture +### System Architecture + +```mermaid +flowchart LR + + Client["🌐 Client\n(Browser)"] + + subgraph MiddlewarePipeline["🛡️ Middleware Pipeline"] + direction TB + M1["Helmet\nSecurity Headers"] + M2["CORS\nOrigin Allowlist"] + M3["Body Parser\nJSON · 50KB limit"] + M4["Rate Limiter\n100 req/min"] + M1 --> M2 --> M3 --> M4 + end + + Client -->|"HTTP / REST"| MiddlewarePipeline + + subgraph AuthGate["🔐 Auth Gate"] + direction TB + JWT["JWT Verify\nExtract userId"] + ZOD["Zod Validate\nSchema check"] + JWT --> ZOD + end + + MiddlewarePipeline --> AuthGate + + subgraph API["📋 API Routes"] + direction TB + + subgraph R1["Auth"] + A1["POST /signup"] + A2["POST /signin"] + end + + subgraph R2["Room"] + B1["GET /:roomId"] + B2["POST /create"] + B3["POST /:roomId/save"] + end + + subgraph R3["Compile"] + C1["POST /compile"] + end + + subgraph R4["AI"] + D1["POST /generate"] + D2["POST /stream ← SSE"] + D3["GET /history/:roomId"] + D4["DELETE /history/:roomId"] + end + + subgraph R5["Snapshot"] + E1["POST /:roomId"] + E2["GET /:roomId"] + end + end + + AuthGate --> API + + subgraph Services["⚙️ Service Layer"] + direction TB + AuthSvc["Auth Service\nbcrypt + JWT sign"] + RoomSvc["Room Service\nFind or Create"] + CompileSvc["Judge0 Service\nCode Execution"] + AISvc["AI Service\nGemini 2.5 Flash\nBatch + Stream"] + SnapSvc["Snapshot Service\nDeduplicated Save"] + end + + R1 --> AuthSvc + R2 --> RoomSvc + R3 --> CompileSvc + R4 --> AISvc + R5 --> SnapSvc + + subgraph DataLayer["💾 Data Stores"] + direction TB + PG["PostgreSQL\n(Prisma ORM)\n───\nUser · Room\nCodeSnapshot\nAIMessage"] + RD["Redis\n───\nRoom state\nUser presence\nSocket mapping"] + end + + AuthSvc & RoomSvc & SnapSvc --> PG + RoomSvc --> RD + + subgraph External["🌍 External APIs"] + direction TB + Judge0["Judge0 CE\nCode Runner"] + Gemini["Google Gemini\nAI Generation"] + end + + CompileSvc --> Judge0 + AISvc --> Gemini + + WSClient["🔌 Socket.IO\nClient"] + + subgraph SocketServer["🔌 Socket.IO Server"] + direction TB + SAuth["JWT Handshake Auth"] + SEvents["Events\n───\njoin · content-edited\ncursor-move · disconnect"] + SAdapter["Redis Adapter\nMulti-server pub/sub"] + SAuth --> SEvents --> SAdapter + end + + WSClient -->|"WebSocket"| SocketServer + SAdapter --> RD + SEvents --> PG +``` + ### Request Flow ``` From e52692a02edd394a77464dae8f2f4899f16af873 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 10:05:12 +0530 Subject: [PATCH 08/24] fix: Readme file updated --- frontend/README.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/frontend/README.md b/frontend/README.md index 23d32c8..0a9831e 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -59,6 +59,71 @@ frontend/ ## Architecture +### System Architecture + +```mermaid +flowchart TB + + subgraph Pages["🖥️ Pages (React Router)"] + Login["Login"] + Signup["Signup"] + Home["Home"] + Editor["EditorPage"] + end + + Login & Signup -->|"JWT token"| Home + Home -->|"/editor/:roomId"| Editor + + subgraph EditorLayout["📐 EditorPage Layout"] + direction LR + + subgraph Left["Editor Panel (2/3)"] + Monaco["Monaco Editor\n(Uncontrolled)"] + Toolbar["Selection Toolbar\nExplain · Review · Fix · Optimize"] + end + + subgraph Right["Right Panel (1/3)"] + Input["Code Input + Run"] + AI["AI Chat Panel\n(Resizable)"] + Versions["Version History"] + end + end + + Editor --> EditorLayout + + subgraph Hooks["🪝 Custom Hooks (Separation of Concerns)"] + direction LR + usePersist["useEditorPersistence\n───\nDB load/save\nCtrl+S snapshots\nDebounced auto-save\nbeforeunload backup"] + + useCollab["useCollaboration\n───\nSocket.IO lifecycle\nRoom join/leave\nCursor decorations\nCode broadcast"] + + useAI["useAI\n───\nSSE stream reader\nRate limit (5/min)\n3 modes: code · selection · question\nChat history state"] + end + + Monaco -->|"onChange\n(user keystrokes only)"| usePersist + Monaco -->|"emitCodeChange"| useCollab + Toolbar -->|"onAsk(prompt, code)"| useAI + Input -->|"analyzeCode()"| useAI + + useCollab -->|"applyCode()\ncursor CSS"| Monaco + usePersist -->|"applyCode()\napplyLang()"| Monaco + + subgraph Transport["📡 Communication Layer"] + direction LR + Axios["Axios\n(REST + JWT)"] + Socket["Socket.IO\n(WebSocket)"] + SSE["fetch\n(SSE Stream)"] + end + + usePersist --> Axios + useCollab --> Socket + useAI --> SSE + + Backend["⚙️ Backend API\nhttp://localhost:8000"] + + Axios & Socket & SSE --> Backend +``` + ### EditorPage — The Orchestration Hub `EditorPage.tsx` is the main page component. It owns Monaco, refs, and imperative helpers — but delegates all business logic to three custom hooks: From 8fdf7a7e191fbbff288005e337443a97b45a5525 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 12:12:55 +0530 Subject: [PATCH 09/24] fix: Readme file updated --- frontend/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/README.md b/frontend/README.md index 0a9831e..c80d10c 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -62,19 +62,20 @@ frontend/ ### System Architecture ```mermaid +%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#3b82f6', 'edgeLabelBackground':'#ffffff', 'tertiaryColor': '#f3f4f6'}}}%% flowchart TB subgraph Pages["🖥️ Pages (React Router)"] Login["Login"] Signup["Signup"] Home["Home"] - Editor["EditorPage"] + Editor["Editor Page"] end Login & Signup -->|"JWT token"| Home Home -->|"/editor/:roomId"| Editor - subgraph EditorLayout["📐 EditorPage Layout"] + subgraph Editor Layout["📐 Editor Page Layout"] direction LR subgraph Left["Editor Panel (2/3)"] @@ -89,7 +90,7 @@ flowchart TB end end - Editor --> EditorLayout + Editor --> Editor Layout subgraph Hooks["🪝 Custom Hooks (Separation of Concerns)"] direction LR @@ -124,7 +125,7 @@ flowchart TB Axios & Socket & SSE --> Backend ``` -### EditorPage — The Orchestration Hub +### Editor Page — The Orchestration Hub `EditorPage.tsx` is the main page component. It owns Monaco, refs, and imperative helpers — but delegates all business logic to three custom hooks: From 13ba14aea1304265eef9c8d97b46b1fc6f4fd306 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 12:13:57 +0530 Subject: [PATCH 10/24] fix: Readme file updated --- frontend/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/README.md b/frontend/README.md index c80d10c..98aa3f1 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -75,7 +75,7 @@ flowchart TB Login & Signup -->|"JWT token"| Home Home -->|"/editor/:roomId"| Editor - subgraph Editor Layout["📐 Editor Page Layout"] + subgraph EditorLayout["📐 Editor Page Layout"] direction LR subgraph Left["Editor Panel (2/3)"] From 8e7bd0526281a8ed0ee49194b69af260b2a1d7c3 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 12:15:03 +0530 Subject: [PATCH 11/24] fix: Readme file updated --- frontend/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/README.md b/frontend/README.md index 98aa3f1..ca5afe5 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -90,7 +90,7 @@ flowchart TB end end - Editor --> Editor Layout + Editor --> EditorLayout subgraph Hooks["🪝 Custom Hooks (Separation of Concerns)"] direction LR From 53b4a8af2f591bbb56597ab1be12d5b6d690ba58 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 12:39:16 +0530 Subject: [PATCH 12/24] fix: Readme file updated --- frontend/README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/frontend/README.md b/frontend/README.md index ca5afe5..a974499 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -61,8 +61,7 @@ frontend/ ### System Architecture -```mermaid -%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#3b82f6', 'edgeLabelBackground':'#ffffff', 'tertiaryColor': '#f3f4f6'}}}%% +%%{init: {'theme': 'base'}}%% flowchart TB subgraph Pages["🖥️ Pages (React Router)"] @@ -123,7 +122,20 @@ flowchart TB Backend["⚙️ Backend API\nhttp://localhost:8000"] Axios & Socket & SSE --> Backend -``` + + %% 🎨 CLASS DEFINITIONS + classDef pages fill:#3b82f6,stroke:#1e40af,color:#fff + classDef layout fill:#10b981,stroke:#065f46,color:#fff + classDef hooks fill:#f59e0b,stroke:#92400e,color:#fff + classDef transport fill:#8b5cf6,stroke:#5b21b6,color:#fff + classDef backend fill:#ef4444,stroke:#7f1d1d,color:#fff + + %% 🎯 APPLY CLASSES + class Login,Signup,Home,Editor pages + class Monaco,Toolbar,Input,AI,Versions layout + class usePersist,useCollab,useAI hooks + class Axios,Socket,SSE transport + class Backend backend ### Editor Page — The Orchestration Hub From 6c4239a080675ca3a6ee097f1c986df6369860ff Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 12:41:02 +0530 Subject: [PATCH 13/24] fix: Readme file updated --- frontend/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/README.md b/frontend/README.md index a974499..69103a7 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -61,6 +61,7 @@ frontend/ ### System Architecture +``` %%{init: {'theme': 'base'}}%% flowchart TB @@ -136,6 +137,7 @@ flowchart TB class usePersist,useCollab,useAI hooks class Axios,Socket,SSE transport class Backend backend +``` ### Editor Page — The Orchestration Hub From 76919189e06917673b1279af2c500900afa509d5 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 12:42:20 +0530 Subject: [PATCH 14/24] fix: Readme file updated --- frontend/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/README.md b/frontend/README.md index 69103a7..af476c8 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -61,7 +61,7 @@ frontend/ ### System Architecture -``` +```mermaid %%{init: {'theme': 'base'}}%% flowchart TB From dd7539f6072b91f149926a1a812f82e562d24f2f Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 12:46:38 +0530 Subject: [PATCH 15/24] fix: Readme file updated --- frontend/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/README.md b/frontend/README.md index af476c8..becb5eb 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -96,7 +96,7 @@ flowchart TB direction LR usePersist["useEditorPersistence\n───\nDB load/save\nCtrl+S snapshots\nDebounced auto-save\nbeforeunload backup"] - useCollab["useCollaboration\n───\nSocket.IO lifecycle\nRoom join/leave\nCursor decorations\nCode broadcast"] + useCollab["useCollab\n(Realtime Sync)\n───\nSocket.IO lifecycle\nRoom join/leave\nCursor decorations\nCode broadcast"] useAI["useAI\n───\nSSE stream reader\nRate limit (5/min)\n3 modes: code · selection · question\nChat history state"] end From 55833f8ec69b796a060cf1b3597bb026d68a384c Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 12:48:54 +0530 Subject: [PATCH 16/24] fix: Readme file updated --- frontend/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/README.md b/frontend/README.md index becb5eb..7e644d0 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -93,7 +93,7 @@ flowchart TB Editor --> EditorLayout subgraph Hooks["🪝 Custom Hooks (Separation of Concerns)"] - direction LR + direction TB usePersist["useEditorPersistence\n───\nDB load/save\nCtrl+S snapshots\nDebounced auto-save\nbeforeunload backup"] useCollab["useCollab\n(Realtime Sync)\n───\nSocket.IO lifecycle\nRoom join/leave\nCursor decorations\nCode broadcast"] From 3a913fbc9ac6afd293c20fc0da72cd279d010b08 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 12:55:25 +0530 Subject: [PATCH 17/24] fix: Readme file updated --- frontend/README.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/frontend/README.md b/frontend/README.md index 7e644d0..a6d2e9f 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -93,12 +93,15 @@ flowchart TB Editor --> EditorLayout subgraph Hooks["🪝 Custom Hooks (Separation of Concerns)"] - direction TB - usePersist["useEditorPersistence\n───\nDB load/save\nCtrl+S snapshots\nDebounced auto-save\nbeforeunload backup"] + direction TB - useCollab["useCollab\n(Realtime Sync)\n───\nSocket.IO lifecycle\nRoom join/leave\nCursor decorations\nCode broadcast"] + spacer1[" "]:::invisible - useAI["useAI\n───\nSSE stream reader\nRate limit (5/min)\n3 modes: code · selection · question\nChat history state"] + usePersist["useEditorPersistence\n───\nDB load/save\nCtrl+S snapshots\nDebounced auto-save\nbeforeunload backup"] + + useCollab["useCollab\n(Realtime Sync)\n───\nSocket.IO lifecycle\nRoom join/leave\nCursor decorations\nCode broadcast"] + + useAI["useAI\n───\nSSE stream reader\nRate limit (5/min)\n3 modes: code · selection · question\nChat history state"] end Monaco -->|"onChange\n(user keystrokes only)"| usePersist @@ -110,10 +113,13 @@ flowchart TB usePersist -->|"applyCode()\napplyLang()"| Monaco subgraph Transport["📡 Communication Layer"] - direction LR - Axios["Axios\n(REST + JWT)"] - Socket["Socket.IO\n(WebSocket)"] - SSE["fetch\n(SSE Stream)"] + direction LR + + spacer2[" "]:::invisible + + Axios["Axios\n(REST + JWT)"] + Socket["Socket.IO\n(WebSocket)"] + SSE["fetch\n(SSE Stream)"] end usePersist --> Axios From 65dc605e1d63065b66b96926f41c979ced8f8510 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 12:57:07 +0530 Subject: [PATCH 18/24] fix: Readme file updated --- frontend/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/README.md b/frontend/README.md index a6d2e9f..ff17f6f 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -136,6 +136,8 @@ flowchart TB classDef hooks fill:#f59e0b,stroke:#92400e,color:#fff classDef transport fill:#8b5cf6,stroke:#5b21b6,color:#fff classDef backend fill:#ef4444,stroke:#7f1d1d,color:#fff + classDef invisible fill:transparent,stroke:none,color:transparent + %% 🎯 APPLY CLASSES class Login,Signup,Home,Editor pages @@ -143,6 +145,7 @@ flowchart TB class usePersist,useCollab,useAI hooks class Axios,Socket,SSE transport class Backend backend + class spacer1,spacer2 invisible ``` ### Editor Page — The Orchestration Hub From 15622e4ab2ef4da6841a6e8fedeb955c58393925 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 13:02:52 +0530 Subject: [PATCH 19/24] fix: Readme file updated --- frontend/README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/frontend/README.md b/frontend/README.md index ff17f6f..6e2226a 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -96,12 +96,18 @@ flowchart TB direction TB spacer1[" "]:::invisible - + + + usePersist["\nuseEditorPersistence\n───\nDB load/save\nCtrl+S snapshots\nDebounced auto-save\nbeforeunload backup"] + + useCollab["\nuseCollab\n(Realtime Sync)\n───\nSocket.IO lifecycle\nRoom join/leave\nCursor decorations\nCode broadcast"] + + useAI["\nuseAI\n───\nSSE stream reader\nRate limit (5/min)\n3 modes: code · selection · question\nChat history state"] end Monaco -->|"onChange\n(user keystrokes only)"| usePersist @@ -117,9 +123,13 @@ flowchart TB spacer2[" "]:::invisible - Axios["Axios\n(REST + JWT)"] + + + Axios["\nAxios\n(REST + JWT)"] + Socket["\nSocket.IO\n(WebSocket)"] + SSE["\nfetch\n(SSE Stream)"] end usePersist --> Axios From 697e7404a09e2a9de02d702981384bf26a4418da Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 13:03:47 +0530 Subject: [PATCH 20/24] fix: Readme file updated --- frontend/README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/frontend/README.md b/frontend/README.md index 6e2226a..f74bd73 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -96,12 +96,6 @@ flowchart TB direction TB spacer1[" "]:::invisible - usePersist["\nuseEditorPersistence\n───\nDB load/save\nCtrl+S snapshots\nDebounced auto-save\nbeforeunload backup"] @@ -123,10 +117,6 @@ flowchart TB spacer2[" "]:::invisible - - Axios["\nAxios\n(REST + JWT)"] Socket["\nSocket.IO\n(WebSocket)"] SSE["\nfetch\n(SSE Stream)"] From 75467e4955947ac5fab6f30da55f586cdf5364cf Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 13:05:04 +0530 Subject: [PATCH 21/24] fix: Readme file updated --- frontend/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/README.md b/frontend/README.md index f74bd73..ff17f6f 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -97,11 +97,11 @@ flowchart TB spacer1[" "]:::invisible - usePersist["\nuseEditorPersistence\n───\nDB load/save\nCtrl+S snapshots\nDebounced auto-save\nbeforeunload backup"] + usePersist["useEditorPersistence\n───\nDB load/save\nCtrl+S snapshots\nDebounced auto-save\nbeforeunload backup"] - useCollab["\nuseCollab\n(Realtime Sync)\n───\nSocket.IO lifecycle\nRoom join/leave\nCursor decorations\nCode broadcast"] + useCollab["useCollab\n(Realtime Sync)\n───\nSocket.IO lifecycle\nRoom join/leave\nCursor decorations\nCode broadcast"] - useAI["\nuseAI\n───\nSSE stream reader\nRate limit (5/min)\n3 modes: code · selection · question\nChat history state"] + useAI["useAI\n───\nSSE stream reader\nRate limit (5/min)\n3 modes: code · selection · question\nChat history state"] end Monaco -->|"onChange\n(user keystrokes only)"| usePersist @@ -117,9 +117,9 @@ flowchart TB spacer2[" "]:::invisible - Axios["\nAxios\n(REST + JWT)"] - Socket["\nSocket.IO\n(WebSocket)"] - SSE["\nfetch\n(SSE Stream)"] + Axios["Axios\n(REST + JWT)"] + Socket["Socket.IO\n(WebSocket)"] + SSE["fetch\n(SSE Stream)"] end usePersist --> Axios From eccfd87531546c9f1103ceb42f8276d3e85f2d53 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 14:35:07 +0530 Subject: [PATCH 22/24] fix: Readme file updated --- backend/README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/backend/README.md b/backend/README.md index 0f5ae15..c37d903 100644 --- a/backend/README.md +++ b/backend/README.md @@ -70,6 +70,8 @@ backend/ ### System Architecture ```mermaid + +%%{init: {'theme': 'base'}}%% flowchart LR Client["🌐 Client\n(Browser)"] @@ -173,6 +175,28 @@ flowchart LR WSClient -->|"WebSocket"| SocketServer SAdapter --> RD SEvents --> PG + + %% 🎨 COLOR DEFINITIONS + classDef client fill:#3b82f6,stroke:#1e40af,color:#fff + classDef core fill:#10b981,stroke:#065f46,color:#fff + classDef service fill:#f59e0b,stroke:#92400e,color:#fff + classDef socket fill:#8b5cf6,stroke:#5b21b6,color:#fff + classDef data fill:#ef4444,stroke:#7f1d1d,color:#fff + classDef external fill:#f3f4f6,stroke:#9ca3af,color:#111 + + %% 🎯 APPLY COLORS + class Client client + + class M1,M2,M3,M4,JWT,ZOD,A1,A2,B1,B2,B3,C1,D1,D2,D3,D4,E1,E2 core + + class AuthSvc,RoomSvc,CompileSvc,AISvc,SnapSvc service + + class WSClient,SAuth,SEvents,SAdapter socket + + class PG,RD data + + class Judge0,Gemini external + ``` ### Request Flow @@ -653,7 +677,7 @@ Room (1) ──→ (N) AIMessage # Run all tests with coverage npm test -# Coverage thresholds: 70% lines, 70% functions +# Coverage thresholds: 70% lines, 60% functions ``` Test environment variables are set in `src/__tests__/envSetup.ts` — `JWT_SECRET`, `NODE_ENV=test`, and `DATABASE_URL` are all provided so no real database is needed (Prisma is mocked). From a3dc61100107519884ff6f9f7b0cfa811f9d6753 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 14:37:28 +0530 Subject: [PATCH 23/24] fix: Readme file updated --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index b115dda..f00e5da 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,9 @@ ## System Architecture ```mermaid +%%{init: {'theme': 'base'}}%% flowchart TB + subgraph Client["🖥️ Frontend · React + Vite"] direction LR Monaco["Monaco Editor"] @@ -95,6 +97,34 @@ flowchart TB Core --> DataStores SocketIO -.->|"horizontal scaling"| RD + + %% 🎨 COLOR DEFINITIONS + classDef client fill:#3b82f6,stroke:#1e40af,color:#fff + classDef core fill:#10b981,stroke:#065f46,color:#fff + classDef service fill:#f59e0b,stroke:#92400e,color:#fff + classDef realtime fill:#8b5cf6,stroke:#5b21b6,color:#fff + classDef data fill:#ef4444,stroke:#7f1d1d,color:#fff + classDef external fill:#f3f4f6,stroke:#9ca3af,color:#111 + + %% 🎯 APPLY COLORS + + %% Frontend + class Monaco,AIP,VH client + + %% Hooks + Middleware + class HC,HA,HP,MW core + + %% Services + class AIRoute,RoomRoute,CompileSvc service + + %% Realtime + class SocketIO realtime + + %% Data + class PG,RD data + + %% External APIs + class Judge0,Gemini external ``` --- From f3a9a227bea3c665328798d497f8d4070233bfe4 Mon Sep 17 00:00:00 2001 From: rah7202 Date: Sun, 5 Apr 2026 15:14:59 +0530 Subject: [PATCH 24/24] fix: Readme file updated --- backend/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/README.md b/backend/README.md index c37d903..813a8dc 100644 --- a/backend/README.md +++ b/backend/README.md @@ -211,10 +211,10 @@ Client Request CORS (origin allowlist) │ ▼ - Rate Limiter (global: 100/min, AI: 10/min) + Body Parser (50KB limit) │ ▼ - Body Parser (50KB limit) + Rate Limiter (global: 100/min, AI: 10/min) │ ▼ authenticate middleware (JWT verify)