# aashay205/wecode architecture

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

- Interactive diagram: https://gitdiagram.com/aashay205/wecode
- Repository: https://github.com/aashay205/wecode

## Overview

WeCode’s main workflow is account access, room creation or joining, collaborative editing and discussion, then host-run code execution with shared output. The graph includes the documented collaboration, room controls, persistence and comment capabilities. Backend socket handling and several page implementations are unsampled, so their connections are limited to relationships documented in the README; source-level call ownership is shown where excerpts establish it.

Main entry points: [`frontend/src/pages/EditorPage.tsx`](https://github.com/aashay205/wecode/blob/main/frontend/src/pages/EditorPage.tsx) (Room editor), [`frontend/src/socket/socket.ts`](https://github.com/aashay205/wecode/blob/main/frontend/src/socket/socket.ts) (Socket client), [`backend/src/socket/index.ts`](https://github.com/aashay205/wecode/blob/main/backend/src/socket/index.ts) (Collaboration events), [`backend/src/lib/prisma.ts`](https://github.com/aashay205/wecode/blob/main/backend/src/lib/prisma.ts) (Prisma connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["App routing<br/>[App.tsx]"]
  node_home["Home and auth<br/>[Home.tsx]"]
  node_editor["Room editor<br/>[EditorPage.tsx]"]
  node_room_hook["Room state<br/>[useRoom.ts]"]
  node_editor_sync["Code and language sync<br/>[useEditorSync.ts]"]
  node_cursor_sync["Cursor sync<br/>[useCursors.ts]"]
  node_comment_sync["Comment state<br/>[useComments.ts]"]
  node_comment_ui["Comment interface<br/>[CommentPanel.tsx]"]
  node_client_socket["Socket client<br/>[socket.ts]"]
end

subgraph group_backend["Backend services"]
  node_api_app["HTTP application<br/>[app.ts]"]
  node_auth_routes["Authentication routes<br/>[auth.ts]"]
  node_auth_service["Auth and tokens<br/>[auth.ts]"]
  node_room_routes["Room creation<br/>[rooms.ts]"]
  node_socket_server["Collaboration events<br/>[index.ts]"]
  node_execution["Code execution<br/>[codeExecution.ts]"]
  node_prisma["Prisma connection<br/>[prisma.ts]"]
end

subgraph group_state["Persistent state"]
  node_postgres[("PostgreSQL state<br/>[schema.prisma]")]
end

subgraph group_integrations["External services"]
  node_jdoodle["JDoodle API"]
end

node_participant(("Participant"))

node_participant -->|"opens app"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_editor
node_participant -->|"registers or logs in"| node_home
node_home -.->|"authenticates via API"| node_api_app
node_api_app -->|"mounts"| node_auth_routes
node_api_app -->|"mounts"| node_room_routes
node_auth_routes -->|"calls"| node_auth_service
node_auth_service -->|"reads and creates users"| node_prisma
node_room_routes -->|"verifies token"| node_auth_service
node_room_routes -->|"creates room"| node_prisma
node_participant -->|"creates or joins room"| node_room_hook
node_room_hook -.->|"joins room"| node_client_socket
node_editor -.->|"uses room state"| node_room_hook
node_editor -.->|"uses editor sync"| node_editor_sync
node_editor -.->|"uses cursor sync"| node_cursor_sync
node_editor -.->|"uses comments"| node_comment_sync
node_comment_sync -.->|"supplies discussions"| node_comment_ui
node_editor_sync -->|"emits and receives events"| node_client_socket
node_cursor_sync -->|"emits and receives events"| node_client_socket
node_comment_sync -->|"emits and receives events"| node_client_socket
node_client_socket -.->|"collaborates over sockets"| node_socket_server
node_socket_server -.->|"persists room state and discussions"| node_prisma
node_participant -->|"edits and discusses"| node_editor
node_participant -.->|"requests host execution"| node_execution
node_socket_server -.->|"dispatches run request"| node_execution
node_execution -.->|"runs code"| node_jdoodle
node_socket_server -.->|"broadcasts results"| node_client_socket
node_prisma -.->|"reads and writes"| node_postgres

click node_app "https://github.com/aashay205/wecode/blob/main/frontend/src/App.tsx"
click node_home "https://github.com/aashay205/wecode/blob/main/frontend/src/pages/Home.tsx"
click node_editor "https://github.com/aashay205/wecode/blob/main/frontend/src/pages/EditorPage.tsx"
click node_room_hook "https://github.com/aashay205/wecode/blob/main/frontend/src/hooks/useRoom.ts"
click node_editor_sync "https://github.com/aashay205/wecode/blob/main/frontend/src/hooks/useEditorSync.ts"
click node_cursor_sync "https://github.com/aashay205/wecode/blob/main/frontend/src/hooks/useCursors.ts"
click node_comment_sync "https://github.com/aashay205/wecode/blob/main/frontend/src/hooks/useComments.ts"
click node_comment_ui "https://github.com/aashay205/wecode/blob/main/frontend/src/components/CommentPanel.tsx"
click node_client_socket "https://github.com/aashay205/wecode/blob/main/frontend/src/socket/socket.ts"
click node_api_app "https://github.com/aashay205/wecode/blob/main/backend/src/app.ts"
click node_auth_routes "https://github.com/aashay205/wecode/blob/main/backend/src/routes/auth.ts"
click node_auth_service "https://github.com/aashay205/wecode/blob/main/backend/src/services/auth.ts"
click node_room_routes "https://github.com/aashay205/wecode/blob/main/backend/src/routes/rooms.ts"
click node_socket_server "https://github.com/aashay205/wecode/blob/main/backend/src/socket/index.ts"
click node_execution "https://github.com/aashay205/wecode/blob/main/backend/src/services/codeExecution.ts"
click node_prisma "https://github.com/aashay205/wecode/blob/main/backend/src/lib/prisma.ts"
click node_postgres "https://github.com/aashay205/wecode/blob/main/backend/prisma/schema.prisma"

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_app,node_home,node_editor,node_room_hook,node_editor_sync,node_cursor_sync,node_comment_sync,node_comment_ui,node_client_socket toneBlue
class node_api_app,node_auth_routes,node_auth_service,node_room_routes,node_socket_server,node_execution,node_prisma toneAmber
class node_postgres toneMint
class node_jdoodle toneRose
class node_participant toneIndigo
```

## Components

### Frontend experience

- [App routing](https://github.com/aashay205/wecode/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Home and auth](https://github.com/aashay205/wecode/blob/main/frontend/src/pages/Home.tsx): `frontend/src/pages/Home.tsx`
- [Room editor](https://github.com/aashay205/wecode/blob/main/frontend/src/pages/EditorPage.tsx): `frontend/src/pages/EditorPage.tsx`
- [Room state](https://github.com/aashay205/wecode/blob/main/frontend/src/hooks/useRoom.ts): `frontend/src/hooks/useRoom.ts`
- [Code and language sync](https://github.com/aashay205/wecode/blob/main/frontend/src/hooks/useEditorSync.ts): `frontend/src/hooks/useEditorSync.ts`
- [Cursor sync](https://github.com/aashay205/wecode/blob/main/frontend/src/hooks/useCursors.ts): `frontend/src/hooks/useCursors.ts`
- [Comment state](https://github.com/aashay205/wecode/blob/main/frontend/src/hooks/useComments.ts): `frontend/src/hooks/useComments.ts`
- [Comment interface](https://github.com/aashay205/wecode/blob/main/frontend/src/components/CommentPanel.tsx): `frontend/src/components/CommentPanel.tsx`
- [Socket client](https://github.com/aashay205/wecode/blob/main/frontend/src/socket/socket.ts): `frontend/src/socket/socket.ts`

### Backend services

- [HTTP application](https://github.com/aashay205/wecode/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Authentication routes](https://github.com/aashay205/wecode/blob/main/backend/src/routes/auth.ts): `backend/src/routes/auth.ts`
- [Auth and tokens](https://github.com/aashay205/wecode/blob/main/backend/src/services/auth.ts): `backend/src/services/auth.ts`
- [Room creation](https://github.com/aashay205/wecode/blob/main/backend/src/routes/rooms.ts): `backend/src/routes/rooms.ts`
- [Collaboration events](https://github.com/aashay205/wecode/blob/main/backend/src/socket/index.ts): `backend/src/socket/index.ts`
- [Code execution](https://github.com/aashay205/wecode/blob/main/backend/src/services/codeExecution.ts): `backend/src/services/codeExecution.ts`
- [Prisma connection](https://github.com/aashay205/wecode/blob/main/backend/src/lib/prisma.ts): `backend/src/lib/prisma.ts`

### Persistent state

- [PostgreSQL state](https://github.com/aashay205/wecode/blob/main/backend/prisma/schema.prisma): `backend/prisma/schema.prisma`

### External services

- **JDoodle API**

### Other components

- **Participant**

## Connections

- Participant → App routing: opens app (evidence: `README.md`)
- App routing → Home and auth: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Room editor: routes to (evidence: `frontend/src/App.tsx`)
- Participant → Home and auth: registers or logs in (evidence: `README.md`)
- Home and auth → HTTP application: authenticates via API (evidence: `README.md`)
- HTTP application → Authentication routes: mounts (evidence: `backend/src/app.ts`)
- HTTP application → Room creation: mounts (evidence: `backend/src/app.ts`)
- Authentication routes → Auth and tokens: calls (evidence: `backend/src/routes/auth.ts`)
- Auth and tokens → Prisma connection: reads and creates users (evidence: `backend/src/services/auth.ts`)
- Room creation → Auth and tokens: verifies token (evidence: `backend/src/routes/rooms.ts`)
- Room creation → Prisma connection: creates room (evidence: `backend/src/routes/rooms.ts`)
- Participant → Room state: creates or joins room (evidence: `README.md`)
- Room state → Socket client: joins room (evidence: `README.md`)
- Room editor → Room state: uses room state (evidence: `README.md`)
- Room editor → Code and language sync: uses editor sync (evidence: `README.md`)
- Room editor → Cursor sync: uses cursor sync (evidence: `README.md`)
- Room editor → Comment state: uses comments (evidence: `README.md`)
- Comment state → Comment interface: supplies discussions (evidence: `README.md`)
- Code and language sync → Socket client: emits and receives events (evidence: `frontend/src/hooks/useEditorSync.ts`)
- Cursor sync → Socket client: emits and receives events (evidence: `frontend/src/hooks/useCursors.ts`)
- Comment state → Socket client: emits and receives events (evidence: `frontend/src/hooks/useComments.ts`)
- Socket client → Collaboration events: collaborates over sockets (evidence: `README.md`)
- Collaboration events → Prisma connection: persists room state and discussions (evidence: `README.md`)
- Participant → Room editor: edits and discusses (evidence: `README.md`)
- Participant → Code execution: requests host execution (evidence: `README.md`)
- Collaboration events → Code execution: dispatches run request (evidence: `README.md`)
- Code execution → JDoodle API: runs code (evidence: `README.md`)
- Collaboration events → Socket client: broadcasts results (evidence: `README.md`)
- Prisma connection → PostgreSQL state: reads and writes (evidence: `README.md`)
