# avi-kedare-75/codepair architecture

> Architecture diagram of the GitHub repository avi-kedare-75/codepair, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/avi-kedare-75/codepair
- Repository: https://github.com/avi-kedare-75/codepair

## Overview

CodePair is a browser-based collaborative coding workspace. Users authenticate, create or join rooms, then edit shared files, chat, call collaborators, and run code; the workspace also offers AI chat, inline suggestions, and complexity analysis. The server supplies REST endpoints and Socket.IO events, with MongoDB-backed users and room state and external AI and execution services. The graph follows documented routes and excerpted calls; some feature internals are unsampled, so their detailed connections are omitted.

Main entry points: [`client/src/pages/Room/EditorPage.jsx`](https://github.com/avi-kedare-75/codepair/blob/main/client/src/pages/Room/EditorPage.jsx) (Collaborative workspace), [`server/src/app.js`](https://github.com/avi-kedare-75/codepair/blob/main/server/src/app.js) (HTTP API), [`client/src/routes/AppRoutes.jsx`](https://github.com/avi-kedare-75/codepair/blob/main/client/src/routes/AppRoutes.jsx) (App routes), [`server/src/routes/authRoutes.js`](https://github.com/avi-kedare-75/codepair/blob/main/server/src/routes/authRoutes.js) (Authentication routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_routes["App routes<br/>[AppRoutes.jsx]"]
  node_home["Sign in and register<br/>[Home.jsx]"]
  node_authctx["Auth state<br/>[AuthContext.jsx]"]
  node_api["HTTP client<br/>[api.js]"]
  node_dashboard["Room dashboard<br/>[Dashboard.jsx]"]
  node_workspace["Collaborative workspace<br/>[EditorPage.jsx]"]
  node_editor["Code editor<br/>[Editor.jsx]"]
  node_files["File explorer<br/>[Sidebar.jsx]"]
  node_chat["Room chat<br/>[ChatPanel.jsx]"]
  node_video["Video calling<br/>[useWebRTC.jsx]"]
  node_aiui["AI workspace tools<br/>[AiPanel.jsx]"]
  node_inline["Inline AI widget<br/>[AiInlineWidget.jsx]"]
  node_complexity["Complexity badge"]
  node_socketclient["Socket client<br/>[socket.js]"]
end

subgraph group_server["Application server"]
  node_httpserver["HTTP API<br/>[app.js]"]
  node_authroutes["Authentication routes<br/>[authRoutes.js]"]
  node_roomroutes["Room routes<br/>[roomRoutes.js]"]
  node_socketserver["Collaboration events<br/>[socket.js]"]
  node_airoutes["AI routes<br/>[aiRoutes.js]"]
  node_aiservice["AI service<br/>[aiService.js]"]
  node_execution["Code execution<br/>[executeCode.js]"]
end

subgraph group_state["Persistence"]
  node_userstore[("User and OTP records<br/>[User.js]")]
  node_roomstore[("Room and file records<br/>[Room.js]")]
  node_otpstore[("OTP records<br/>[Otp.js]")]
end

subgraph group_integrations["External services"]
  node_database[("MongoDB")]
  node_aiproviders{{"AI providers"}}
  node_runner{{"Isolated execution API"}}
  node_mail{{"Email service"}}
end

node_developer(("Developer"))

node_developer -->|"opens workspace"| node_routes
node_routes -->|"routes to"| node_home
node_routes -->|"routes to"| node_dashboard
node_routes -->|"routes to"| node_workspace
node_home -->|"uses auth"| node_authctx
node_dashboard -->|"uses auth"| node_authctx
node_authctx -->|"sends requests"| node_api
node_authctx -.->|"auth requests"| node_httpserver
node_dashboard -.->|"room requests"| node_httpserver
node_workspace -->|"renders"| node_editor
node_workspace -->|"renders"| node_files
node_workspace -->|"renders"| node_chat
node_workspace -->|"uses calling"| node_video
node_workspace -->|"renders"| node_aiui
node_editor -->|"renders"| node_inline
node_workspace -->|"renders"| node_complexity
node_workspace -->|"initializes"| node_socketclient
node_socketclient -.->|"Socket.IO events"| node_socketserver
node_workspace -->|"requests analysis"| node_airoutes
node_workspace -.->|"runs code"| node_runner
node_httpserver -->|"mounts"| node_authroutes
node_httpserver -->|"mounts"| node_roomroutes
node_httpserver -->|"mounts"| node_airoutes
node_authroutes -->|"reads and writes"| node_userstore
node_authroutes -->|"reads and writes"| node_otpstore
node_authroutes -->|"sends OTP email"| node_mail
node_roomroutes -->|"reads and writes"| node_roomstore
node_socketserver -->|"uses room state"| node_roomstore
node_socketserver -->|"dispatches execution"| node_execution
node_execution -.->|"submits code"| node_runner
node_airoutes -->|"loads room files"| node_roomstore
node_airoutes -->|"calls AI tasks"| node_aiservice
node_aiservice -->|"requests generation"| node_aiproviders
node_userstore -.->|"persists records"| node_database
node_roomstore -.->|"persists room state"| node_database
node_otpstore -.->|"persists OTPs"| node_database

click node_routes "https://github.com/avi-kedare-75/codepair/blob/main/client/src/routes/AppRoutes.jsx"
click node_home "https://github.com/avi-kedare-75/codepair/blob/main/client/src/pages/Home/Home.jsx"
click node_authctx "https://github.com/avi-kedare-75/codepair/blob/main/client/src/context/AuthContext.jsx"
click node_api "https://github.com/avi-kedare-75/codepair/blob/main/client/src/services/api.js"
click node_dashboard "https://github.com/avi-kedare-75/codepair/blob/main/client/src/pages/Room/Dashboard.jsx"
click node_workspace "https://github.com/avi-kedare-75/codepair/blob/main/client/src/pages/Room/EditorPage.jsx"
click node_editor "https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Editor/Editor.jsx"
click node_files "https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Sidebar/Sidebar.jsx"
click node_chat "https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Chat/ChatPanel.jsx"
click node_video "https://github.com/avi-kedare-75/codepair/blob/main/client/src/hooks/useWebRTC.jsx"
click node_aiui "https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Editor/AiPanel.jsx"
click node_inline "https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Editor/AiInlineWidget.jsx"
click node_complexity "https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Editor/ComplexityBadge.jsx"
click node_socketclient "https://github.com/avi-kedare-75/codepair/blob/main/client/src/services/socket.js"
click node_httpserver "https://github.com/avi-kedare-75/codepair/blob/main/server/src/app.js"
click node_authroutes "https://github.com/avi-kedare-75/codepair/blob/main/server/src/routes/authRoutes.js"
click node_roomroutes "https://github.com/avi-kedare-75/codepair/blob/main/server/src/routes/roomRoutes.js"
click node_socketserver "https://github.com/avi-kedare-75/codepair/blob/main/server/src/config/socket.js"
click node_airoutes "https://github.com/avi-kedare-75/codepair/blob/main/server/src/routes/aiRoutes.js"
click node_aiservice "https://github.com/avi-kedare-75/codepair/blob/main/server/src/services/aiService.js"
click node_execution "https://github.com/avi-kedare-75/codepair/blob/main/server/src/services/executeCode.js"
click node_userstore "https://github.com/avi-kedare-75/codepair/blob/main/server/src/models/User.js"
click node_roomstore "https://github.com/avi-kedare-75/codepair/blob/main/server/src/models/Room.js"
click node_otpstore "https://github.com/avi-kedare-75/codepair/blob/main/server/src/models/Otp.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routes,node_home,node_authctx,node_api,node_dashboard,node_workspace,node_editor,node_files,node_chat,node_video,node_aiui,node_inline,node_complexity,node_socketclient toneBlue
class node_httpserver,node_authroutes,node_roomroutes,node_socketserver,node_airoutes,node_aiservice,node_execution toneAmber
class node_userstore,node_roomstore,node_otpstore toneMint
class node_database,node_aiproviders,node_runner,node_mail toneRose
class node_developer toneIndigo
```

## Components

### Web client

- [App routes](https://github.com/avi-kedare-75/codepair/blob/main/client/src/routes/AppRoutes.jsx): `client/src/routes/AppRoutes.jsx`
- [Sign in and register](https://github.com/avi-kedare-75/codepair/blob/main/client/src/pages/Home/Home.jsx): `client/src/pages/Home/Home.jsx`
- [Auth state](https://github.com/avi-kedare-75/codepair/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [HTTP client](https://github.com/avi-kedare-75/codepair/blob/main/client/src/services/api.js): `client/src/services/api.js`
- [Room dashboard](https://github.com/avi-kedare-75/codepair/blob/main/client/src/pages/Room/Dashboard.jsx): `client/src/pages/Room/Dashboard.jsx`
- [Collaborative workspace](https://github.com/avi-kedare-75/codepair/blob/main/client/src/pages/Room/EditorPage.jsx): `client/src/pages/Room/EditorPage.jsx`
- [Code editor](https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Editor/Editor.jsx): `client/src/components/Editor/Editor.jsx`
- [File explorer](https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Sidebar/Sidebar.jsx): `client/src/components/Sidebar/Sidebar.jsx`
- [Room chat](https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Chat/ChatPanel.jsx): `client/src/components/Chat/ChatPanel.jsx`
- [Video calling](https://github.com/avi-kedare-75/codepair/blob/main/client/src/hooks/useWebRTC.jsx): `client/src/hooks/useWebRTC.jsx`
- [AI workspace tools](https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Editor/AiPanel.jsx): `client/src/components/Editor/AiPanel.jsx`
- [Inline AI widget](https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Editor/AiInlineWidget.jsx): `client/src/components/Editor/AiInlineWidget.jsx`
- [Complexity badge](https://github.com/avi-kedare-75/codepair/blob/main/client/src/components/Editor/ComplexityBadge.jsx): `client/src/components/Editor/ComplexityBadge.jsx`
- [Socket client](https://github.com/avi-kedare-75/codepair/blob/main/client/src/services/socket.js): `client/src/services/socket.js`

### Application server

- [HTTP API](https://github.com/avi-kedare-75/codepair/blob/main/server/src/app.js): `server/src/app.js`
- [Authentication routes](https://github.com/avi-kedare-75/codepair/blob/main/server/src/routes/authRoutes.js): `server/src/routes/authRoutes.js`
- [Room routes](https://github.com/avi-kedare-75/codepair/blob/main/server/src/routes/roomRoutes.js): `server/src/routes/roomRoutes.js`
- [Collaboration events](https://github.com/avi-kedare-75/codepair/blob/main/server/src/config/socket.js): `server/src/config/socket.js`
- [AI routes](https://github.com/avi-kedare-75/codepair/blob/main/server/src/routes/aiRoutes.js): `server/src/routes/aiRoutes.js`
- [AI service](https://github.com/avi-kedare-75/codepair/blob/main/server/src/services/aiService.js): `server/src/services/aiService.js`
- [Code execution](https://github.com/avi-kedare-75/codepair/blob/main/server/src/services/executeCode.js): `server/src/services/executeCode.js`

### Persistence

- [User and OTP records](https://github.com/avi-kedare-75/codepair/blob/main/server/src/models/User.js): `server/src/models/User.js`
- [Room and file records](https://github.com/avi-kedare-75/codepair/blob/main/server/src/models/Room.js): `server/src/models/Room.js`
- [OTP records](https://github.com/avi-kedare-75/codepair/blob/main/server/src/models/Otp.js): `server/src/models/Otp.js`

### External services

- **MongoDB**
- **AI providers**
- **Isolated execution API**
- **Email service**

### Other components

- **Developer**

## Connections

- Developer → App routes: opens workspace (evidence: `README.md`)
- App routes → Sign in and register: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- App routes → Room dashboard: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- App routes → Collaborative workspace: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Sign in and register → Auth state: uses auth (evidence: `client/src/pages/Home/Home.jsx`)
- Room dashboard → Auth state: uses auth (evidence: `client/src/pages/Room/Dashboard.jsx`)
- Auth state → HTTP client: sends requests (evidence: `client/src/context/AuthContext.jsx`)
- Auth state → HTTP API: auth requests (evidence: `README.md`)
- Room dashboard → HTTP API: room requests (evidence: `README.md`)
- Collaborative workspace → Code editor: renders (evidence: `client/src/pages/Room/EditorPage.jsx`)
- Collaborative workspace → File explorer: renders (evidence: `client/src/pages/Room/EditorPage.jsx`)
- Collaborative workspace → Room chat: renders (evidence: `client/src/pages/Room/EditorPage.jsx`)
- Collaborative workspace → Video calling: uses calling (evidence: `client/src/pages/Room/EditorPage.jsx`)
- Collaborative workspace → AI workspace tools: renders (evidence: `client/src/pages/Room/EditorPage.jsx`)
- Code editor → Inline AI widget: renders (evidence: `client/src/components/Editor/Editor.jsx`)
- Collaborative workspace → Complexity badge: renders (evidence: `client/src/pages/Room/EditorPage.jsx`)
- Collaborative workspace → Socket client: initializes (evidence: `client/src/pages/Room/EditorPage.jsx`)
- Socket client → Collaboration events: Socket.IO events (evidence: `README.md`)
- Collaborative workspace → AI routes: requests analysis (evidence: `client/src/pages/Room/EditorPage.jsx`)
- Collaborative workspace → Isolated execution API: runs code (evidence: `README.md`)
- HTTP API → Authentication routes: mounts (evidence: `server/src/app.js`)
- HTTP API → Room routes: mounts (evidence: `server/src/app.js`)
- HTTP API → AI routes: mounts (evidence: `server/src/app.js`)
- Authentication routes → User and OTP records: reads and writes (evidence: `server/src/routes/authRoutes.js`)
- Authentication routes → OTP records: reads and writes (evidence: `server/src/routes/authRoutes.js`)
- Authentication routes → Email service: sends OTP email (evidence: `server/src/routes/authRoutes.js`)
- Room routes → Room and file records: reads and writes (evidence: `server/src/routes/roomRoutes.js`)
- Collaboration events → Room and file records: uses room state (evidence: `server/src/config/socket.js`)
- Collaboration events → Code execution: dispatches execution (evidence: `server/src/config/socket.js`)
- Code execution → Isolated execution API: submits code (evidence: `README.md`)
- AI routes → Room and file records: loads room files (evidence: `server/src/routes/aiRoutes.js`)
- AI routes → AI service: calls AI tasks (evidence: `server/src/routes/aiRoutes.js`)
- AI service → AI providers: requests generation (evidence: `server/src/services/aiService.js`)
- User and OTP records → MongoDB: persists records (evidence: `README.md`)
- Room and file records → MongoDB: persists room state (evidence: `README.md`)
- OTP records → MongoDB: persists OTPs (evidence: `README.md`)
