# akcodz/codesync architecture

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

- Interactive diagram: https://gitdiagram.com/akcodz/codesync
- Repository: https://github.com/akcodz/codesync

## Overview

This is a collaborative coding platform: users authenticate, create or join projects, edit and save code, run it, and collaborate through chat/video. It also exposes coding problems and AI code review. The frontend routes users to these experiences; the Express backend handles account and project APIs, persistence, execution, and Stream token provisioning. Several page, AI, and execution implementations were not sampled, so their capabilities are shown without speculative call wiring.

Main entry points: [`frontend/src/routes/AppRoutes.jsx`](https://github.com/akcodz/codesync/blob/main/frontend/src/routes/AppRoutes.jsx) (App routes), [`backend/app.js`](https://github.com/akcodz/codesync/blob/main/backend/app.js) (Express app), [`backend/controllers/user.controller.js`](https://github.com/akcodz/codesync/blob/main/backend/controllers/user.controller.js) (User accounts), [`backend/controllers/project.controller.js`](https://github.com/akcodz/codesync/blob/main/backend/controllers/project.controller.js) (Project and code)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app_routes["App routes<br/>[AppRoutes.jsx]"]
  node_auth_guard["Private routes<br/>[PrivateRoutes.jsx]"]
  node_user_context["User context<br/>[UserContext.jsx]"]
  node_projects_ui["Project browser<br/>[Projects.jsx]"]
  node_project_ui["Collaborative editor<br/>[Project.jsx]"]
  node_editor["Code editor<br/>[CodeEditor.jsx]"]
  node_problems_ui["Problem catalog<br/>[Problems.jsx]"]
  node_problem_ui["Problem workspace<br/>[Problem.jsx]"]
  node_review_ui["AI code review<br/>[CodeReview.jsx]"]
end

subgraph group_backend["API and domain"]
  node_api_app["Express app<br/>[app.js]"]
  node_user_routes["User routes<br/>[user.routes.js]"]
  node_user_controller["User accounts<br/>[user.controller.js]"]
  node_user_model[("User records<br/>[user.model.js]")]
  node_project_routes["Project routes<br/>[project.routes.js]"]
  node_project_controller["Project and code"]
  node_project_model[("Project records<br/>[project.model.js]")]
  node_execution_service["Code execution"]
  node_ai_routes["AI routes<br/>[ai.routes.js]"]
  node_ai_controller["AI review API<br/>[ai.controller.js]"]
  node_ai_service["Review generation<br/>[ai.service.js]"]
  node_db["Database connection<br/>[db.js]"]
end

subgraph group_collaboration["Live collaboration"]
  node_chat_routes["Chat routes<br/>[chat.routes.js]"]
  node_chat_controller["Stream token API<br/>[chat.controller.js]"]
  node_stream_hook["Call and chat setup<br/>[UseStreamClient.js]"]
  node_stream_utils["Stream integration<br/>[stream.js]"]
end

subgraph group_integrations["External services"]
  node_stream_service{{"Stream services"}}
  node_gemini{{"Gemini AI"}}
  node_runtime{{"Code runner"}}
end

node_user(("User"))

node_user -->|"uses"| node_app_routes
node_app_routes -->|"guards private routes"| node_auth_guard
node_app_routes -->|"routes to"| node_projects_ui
node_app_routes -->|"routes to"| node_project_ui
node_app_routes -->|"routes to"| node_problems_ui
node_app_routes -->|"routes to"| node_problem_ui
node_app_routes -->|"routes to"| node_review_ui
node_auth_guard -->|"checks session"| node_user_context
node_api_app -->|"connects"| node_db
node_api_app -->|"mounts"| node_user_routes
node_api_app -->|"mounts"| node_project_routes
node_api_app -->|"mounts"| node_chat_routes
node_api_app -->|"mounts"| node_ai_routes
node_user_routes -->|"dispatches"| node_user_controller
node_user_controller -->|"reads and writes"| node_user_model
node_user_controller -->|"upserts user"| node_stream_utils
node_project_routes -->|"dispatches"| node_project_controller
node_project_controller -->|"reads and writes"| node_project_model
node_project_controller -->|"runs code"| node_execution_service
node_execution_service -.->|"executes"| node_runtime
node_ai_routes -->|"dispatches"| node_ai_controller
node_ai_service -->|"generates review"| node_gemini
node_chat_routes -->|"dispatches"| node_chat_controller
node_chat_controller -->|"creates token"| node_stream_utils
node_stream_hook -->|"requests token"| node_chat_routes
node_stream_hook -->|"connects call and chat"| node_stream_service
node_stream_utils -->|"provisions users"| node_stream_service

click node_app_routes "https://github.com/akcodz/codesync/blob/main/frontend/src/routes/AppRoutes.jsx"
click node_auth_guard "https://github.com/akcodz/codesync/blob/main/frontend/src/routes/PrivateRoutes.jsx"
click node_user_context "https://github.com/akcodz/codesync/blob/main/frontend/src/context/UserContext.jsx"
click node_projects_ui "https://github.com/akcodz/codesync/blob/main/frontend/src/pages/Projects.jsx"
click node_project_ui "https://github.com/akcodz/codesync/blob/main/frontend/src/pages/Project.jsx"
click node_editor "https://github.com/akcodz/codesync/blob/main/frontend/src/components/CodeEditor.jsx"
click node_problems_ui "https://github.com/akcodz/codesync/blob/main/frontend/src/pages/Problems.jsx"
click node_problem_ui "https://github.com/akcodz/codesync/blob/main/frontend/src/pages/Problem.jsx"
click node_review_ui "https://github.com/akcodz/codesync/blob/main/frontend/src/pages/CodeReview.jsx"
click node_api_app "https://github.com/akcodz/codesync/blob/main/backend/app.js"
click node_user_routes "https://github.com/akcodz/codesync/blob/main/backend/routes/user.routes.js"
click node_user_controller "https://github.com/akcodz/codesync/blob/main/backend/controllers/user.controller.js"
click node_user_model "https://github.com/akcodz/codesync/blob/main/backend/models/user.model.js"
click node_project_routes "https://github.com/akcodz/codesync/blob/main/backend/routes/project.routes.js"
click node_project_controller "https://github.com/akcodz/codesync/blob/main/backend/controllers/project.controller.js"
click node_project_model "https://github.com/akcodz/codesync/blob/main/backend/models/project.model.js"
click node_execution_service "https://github.com/akcodz/codesync/blob/main/backend/services/codeExecution.service.js"
click node_ai_routes "https://github.com/akcodz/codesync/blob/main/backend/routes/ai.routes.js"
click node_ai_controller "https://github.com/akcodz/codesync/blob/main/backend/controllers/ai.controller.js"
click node_ai_service "https://github.com/akcodz/codesync/blob/main/backend/services/ai.service.js"
click node_db "https://github.com/akcodz/codesync/blob/main/backend/db/db.js"
click node_chat_routes "https://github.com/akcodz/codesync/blob/main/backend/routes/chat.routes.js"
click node_chat_controller "https://github.com/akcodz/codesync/blob/main/backend/controllers/chat.controller.js"
click node_stream_hook "https://github.com/akcodz/codesync/blob/main/frontend/src/hooks/UseStreamClient.js"
click node_stream_utils "https://github.com/akcodz/codesync/blob/main/backend/utils/stream.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_app_routes,node_auth_guard,node_user_context,node_projects_ui,node_project_ui,node_editor,node_problems_ui,node_problem_ui,node_review_ui,node_user toneBlue
class node_api_app,node_user_routes,node_user_controller,node_user_model,node_project_routes,node_project_controller,node_project_model,node_execution_service,node_ai_routes,node_ai_controller,node_ai_service,node_db toneAmber
class node_chat_routes,node_chat_controller,node_stream_hook,node_stream_utils toneMint
class node_stream_service,node_gemini,node_runtime toneRose
```

## Components

### Web application

- [App routes](https://github.com/akcodz/codesync/blob/main/frontend/src/routes/AppRoutes.jsx): `frontend/src/routes/AppRoutes.jsx`
- [Private routes](https://github.com/akcodz/codesync/blob/main/frontend/src/routes/PrivateRoutes.jsx): `frontend/src/routes/PrivateRoutes.jsx`
- [User context](https://github.com/akcodz/codesync/blob/main/frontend/src/context/UserContext.jsx): `frontend/src/context/UserContext.jsx`
- [Project browser](https://github.com/akcodz/codesync/blob/main/frontend/src/pages/Projects.jsx): `frontend/src/pages/Projects.jsx`
- [Collaborative editor](https://github.com/akcodz/codesync/blob/main/frontend/src/pages/Project.jsx): `frontend/src/pages/Project.jsx`
- [Code editor](https://github.com/akcodz/codesync/blob/main/frontend/src/components/CodeEditor.jsx): `frontend/src/components/CodeEditor.jsx`
- [Problem catalog](https://github.com/akcodz/codesync/blob/main/frontend/src/pages/Problems.jsx): `frontend/src/pages/Problems.jsx`
- [Problem workspace](https://github.com/akcodz/codesync/blob/main/frontend/src/pages/Problem.jsx): `frontend/src/pages/Problem.jsx`
- [AI code review](https://github.com/akcodz/codesync/blob/main/frontend/src/pages/CodeReview.jsx): `frontend/src/pages/CodeReview.jsx`

### API and domain

- [Express app](https://github.com/akcodz/codesync/blob/main/backend/app.js): `backend/app.js`
- [User routes](https://github.com/akcodz/codesync/blob/main/backend/routes/user.routes.js): `backend/routes/user.routes.js`
- [User accounts](https://github.com/akcodz/codesync/blob/main/backend/controllers/user.controller.js): `backend/controllers/user.controller.js`
- [User records](https://github.com/akcodz/codesync/blob/main/backend/models/user.model.js): `backend/models/user.model.js`
- [Project routes](https://github.com/akcodz/codesync/blob/main/backend/routes/project.routes.js): `backend/routes/project.routes.js`
- [Project and code](https://github.com/akcodz/codesync/blob/main/backend/controllers/project.controller.js): `backend/controllers/project.controller.js`
- [Project records](https://github.com/akcodz/codesync/blob/main/backend/models/project.model.js): `backend/models/project.model.js`
- [Code execution](https://github.com/akcodz/codesync/blob/main/backend/services/codeExecution.service.js): `backend/services/codeExecution.service.js`
- [AI routes](https://github.com/akcodz/codesync/blob/main/backend/routes/ai.routes.js): `backend/routes/ai.routes.js`
- [AI review API](https://github.com/akcodz/codesync/blob/main/backend/controllers/ai.controller.js): `backend/controllers/ai.controller.js`
- [Review generation](https://github.com/akcodz/codesync/blob/main/backend/services/ai.service.js): `backend/services/ai.service.js`
- [Database connection](https://github.com/akcodz/codesync/blob/main/backend/db/db.js): `backend/db/db.js`

### Live collaboration

- [Chat routes](https://github.com/akcodz/codesync/blob/main/backend/routes/chat.routes.js): `backend/routes/chat.routes.js`
- [Stream token API](https://github.com/akcodz/codesync/blob/main/backend/controllers/chat.controller.js): `backend/controllers/chat.controller.js`
- [Call and chat setup](https://github.com/akcodz/codesync/blob/main/frontend/src/hooks/UseStreamClient.js): `frontend/src/hooks/UseStreamClient.js`
- [Stream integration](https://github.com/akcodz/codesync/blob/main/backend/utils/stream.js): `backend/utils/stream.js`

### External services

- **Stream services**
- **Gemini AI**
- **Code runner**

### Other components

- **User**

## Connections

- User → App routes: uses
- App routes → Private routes: guards private routes
- App routes → Project browser: routes to
- App routes → Collaborative editor: routes to
- App routes → Problem catalog: routes to
- App routes → Problem workspace: routes to
- App routes → AI code review: routes to
- Private routes → User context: checks session
- Express app → Database connection: connects
- Express app → User routes: mounts
- Express app → Project routes: mounts
- Express app → Chat routes: mounts
- Express app → AI routes: mounts
- User routes → User accounts: dispatches
- User accounts → User records: reads and writes
- User accounts → Stream integration: upserts user
- Project routes → Project and code: dispatches
- Project and code → Project records: reads and writes
- Project and code → Code execution: runs code
- Code execution → Code runner: executes
- AI routes → AI review API: dispatches
- Review generation → Gemini AI: generates review
- Chat routes → Stream token API: dispatches
- Stream token API → Stream integration: creates token
- Call and chat setup → Chat routes: requests token
- Call and chat setup → Stream services: connects call and chat
- Stream integration → Stream services: provisions users
