# harsha943vf/code_galaxy architecture

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

- Interactive diagram: https://gitdiagram.com/harsha943vf/code_galaxy
- Repository: https://github.com/harsha943vf/code_galaxy

## Overview

CodeGalaxy combines a browser-based collaborative coding workspace with authentication and an AI-assisted study planner. Users enter through the routed React app, then can register or log in, work in shared editor rooms, exchange collaboration events, and execute code; separately, authenticated learners generate and manage study plans with AI-created quizzes, explanations, and resources. The server excerpt shows the HTTP and Socket.io entry points and their responsibilities; the client’s broader wiring is only partly sampled, so some documented feature links are not asserted as direct calls.

Main entry points: [`server/src/routes/studyPlan.ts`](https://github.com/harsha943vf/code_galaxy/blob/main/server/src/routes/studyPlan.ts) (Study plan endpoints), [`server/src/server.ts`](https://github.com/harsha943vf/code_galaxy/blob/main/server/src/server.ts) (HTTP and socket server), [`client/src/App.tsx`](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/App.tsx) (Route application), [`client/src/context/FileContext.tsx`](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/context/FileContext.tsx) (Shared file state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Route application<br/>[App.tsx]"]
  node_authui["Login and registration<br/>[RegisterPage.tsx]"]
  node_authhook["Auth context hook<br/>[useAuth.ts]"]
end

subgraph group_collab["Collaborative editor"]
  node_editorpage["Editor room page<br/>[EditorPage.tsx]"]
  node_filecontext["Shared file state<br/>[FileContext.tsx]"]
  node_editor["Code editor<br/>[Editor.tsx]"]
  node_chat["Room chat<br/>[ChatInput.tsx]"]
  node_socketclient["Socket state<br/>[SocketContext.tsx]"]
  node_runcontext["Code execution state<br/>[RunCodeContext.tsx]"]
  node_compileapi["Compiler API client<br/>[oneCompiler.ts]"]
end

subgraph group_backend["API and persistence"]
  node_server["HTTP and socket server<br/>[server.ts]"]
  node_authroutes["Auth endpoints<br/>[auth.ts]"]
  node_authmw["JWT verification<br/>[auth.ts]"]
  node_usermodel[("User records<br/>[User.ts]")]
  node_database[("MongoDB connection<br/>[database.ts]")]
end

subgraph group_learning["Study planner"]
  node_studyui["Study plan pages"]
  node_detailui["Plan details"]
  node_studyroute["Study plan endpoints<br/>[studyPlan.ts]"]
  node_studyservice["AI study generation"]
  node_studydb[("Study plan records<br/>[StudyPlan.ts]")]
end

node_user(("Visitor or learner"))
node_gemini{{"Gemini AI"}}
node_compiler{{"OneCompiler"}}

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_editorpage
node_app -->|"routes to"| node_studyui
node_app -->|"routes to"| node_detailui
node_authui -->|"uses"| node_authhook
node_authui -.->|"requests auth"| node_authroutes
node_server -->|"mounts routes"| node_authroutes
node_authroutes -->|"verifies token"| node_authmw
node_authroutes -->|"reads and writes"| node_usermodel
node_server -->|"connects"| node_database
node_editorpage -.->|"uses workspace state"| node_filecontext
node_filecontext -.->|"supplies file state"| node_editor
node_editorpage -.->|"offers room chat"| node_chat
node_filecontext -->|"emits sync events"| node_socketclient
node_socketclient -->|"exchanges room events"| node_server
node_runcontext -->|"reads active files"| node_filecontext
node_runcontext -.->|"requests execution"| node_compileapi
node_compileapi -.->|"posts compile request"| node_server
node_server -->|"forwards code"| node_compiler
node_studyui -.->|"requests plans"| node_studyroute
node_detailui -.->|"requests plan details"| node_studyroute
node_server -->|"mounts routes"| node_studyroute
node_studyroute -->|"requires authentication"| node_authmw
node_studyroute -->|"generates learning content"| node_studyservice
node_studyservice -->|"generates content"| node_gemini
node_studyroute -->|"loads and saves plans"| node_studydb
node_studyroute -.->|"returns plan results"| node_studyui

click node_app "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/App.tsx"
click node_authui "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/pages/RegisterPage.tsx"
click node_authhook "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/hooks/useAuth.ts"
click node_editorpage "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/pages/EditorPage.tsx"
click node_filecontext "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/context/FileContext.tsx"
click node_editor "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/components/editor/Editor.tsx"
click node_chat "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/components/chats/ChatInput.tsx"
click node_socketclient "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/context/SocketContext.tsx"
click node_runcontext "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/context/RunCodeContext.tsx"
click node_compileapi "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/api/oneCompiler.ts"
click node_server "https://github.com/harsha943vf/code_galaxy/blob/main/server/src/server.ts"
click node_authroutes "https://github.com/harsha943vf/code_galaxy/blob/main/server/src/routes/auth.ts"
click node_authmw "https://github.com/harsha943vf/code_galaxy/blob/main/server/src/middleware/auth.ts"
click node_usermodel "https://github.com/harsha943vf/code_galaxy/blob/main/server/src/models/User.ts"
click node_database "https://github.com/harsha943vf/code_galaxy/blob/main/server/src/config/database.ts"
click node_studyui "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/pages/StudyPlannerPage.tsx"
click node_detailui "https://github.com/harsha943vf/code_galaxy/blob/main/client/src/pages/StudyPlanDetailsPage.tsx"
click node_studyroute "https://github.com/harsha943vf/code_galaxy/blob/main/server/src/routes/studyPlan.ts"
click node_studyservice "https://github.com/harsha943vf/code_galaxy/blob/main/server/src/services/studyPlanService.ts"
click node_studydb "https://github.com/harsha943vf/code_galaxy/blob/main/server/src/models/StudyPlan.ts"

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_authui,node_authhook toneBlue
class node_editorpage,node_filecontext,node_editor,node_chat,node_socketclient,node_runcontext,node_compileapi toneAmber
class node_server,node_authroutes,node_authmw,node_usermodel,node_database toneMint
class node_studyui,node_detailui,node_studyroute,node_studyservice,node_studydb toneRose
class node_user,node_gemini,node_compiler toneIndigo
```

## Components

### Web client

- [Route application](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Login and registration](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/pages/RegisterPage.tsx): `client/src/pages/RegisterPage.tsx`
- [Auth context hook](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/hooks/useAuth.ts): `client/src/hooks/useAuth.ts`

### Collaborative editor

- [Editor room page](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/pages/EditorPage.tsx): `client/src/pages/EditorPage.tsx`
- [Shared file state](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/context/FileContext.tsx): `client/src/context/FileContext.tsx`
- [Code editor](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/components/editor/Editor.tsx): `client/src/components/editor/Editor.tsx`
- [Room chat](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/components/chats/ChatInput.tsx): `client/src/components/chats/ChatInput.tsx`
- [Socket state](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/context/SocketContext.tsx): `client/src/context/SocketContext.tsx`
- [Code execution state](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/context/RunCodeContext.tsx): `client/src/context/RunCodeContext.tsx`
- [Compiler API client](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/api/oneCompiler.ts): `client/src/api/oneCompiler.ts`

### API and persistence

- [HTTP and socket server](https://github.com/harsha943vf/code_galaxy/blob/main/server/src/server.ts): `server/src/server.ts`
- [Auth endpoints](https://github.com/harsha943vf/code_galaxy/blob/main/server/src/routes/auth.ts): `server/src/routes/auth.ts`
- [JWT verification](https://github.com/harsha943vf/code_galaxy/blob/main/server/src/middleware/auth.ts): `server/src/middleware/auth.ts`
- [User records](https://github.com/harsha943vf/code_galaxy/blob/main/server/src/models/User.ts): `server/src/models/User.ts`
- [MongoDB connection](https://github.com/harsha943vf/code_galaxy/blob/main/server/src/config/database.ts): `server/src/config/database.ts`

### Study planner

- [Study plan pages](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/pages/StudyPlannerPage.tsx): `client/src/pages/StudyPlannerPage.tsx`
- [Plan details](https://github.com/harsha943vf/code_galaxy/blob/main/client/src/pages/StudyPlanDetailsPage.tsx): `client/src/pages/StudyPlanDetailsPage.tsx`
- [Study plan endpoints](https://github.com/harsha943vf/code_galaxy/blob/main/server/src/routes/studyPlan.ts): `server/src/routes/studyPlan.ts`
- [AI study generation](https://github.com/harsha943vf/code_galaxy/blob/main/server/src/services/studyPlanService.ts): `server/src/services/studyPlanService.ts`
- [Study plan records](https://github.com/harsha943vf/code_galaxy/blob/main/server/src/models/StudyPlan.ts): `server/src/models/StudyPlan.ts`

### Other components

- **Visitor or learner**
- **Gemini AI**
- **OneCompiler**

## Connections

- Visitor or learner → Route application: opens (evidence: `client/src/App.tsx`)
- Route application → Login and registration: routes to (evidence: `client/src/App.tsx`)
- Route application → Editor room page: routes to (evidence: `client/src/App.tsx`)
- Route application → Study plan pages: routes to (evidence: `client/src/App.tsx`)
- Route application → Plan details: routes to (evidence: `client/src/App.tsx`)
- Login and registration → Auth context hook: uses (evidence: `client/src/hooks/useAuth.ts`)
- Login and registration → Auth endpoints: requests auth
- HTTP and socket server → Auth endpoints: mounts routes (evidence: `server/src/server.ts`)
- Auth endpoints → JWT verification: verifies token (evidence: `server/src/routes/auth.ts`)
- Auth endpoints → User records: reads and writes (evidence: `server/src/routes/auth.ts`)
- HTTP and socket server → MongoDB connection: connects (evidence: `server/src/server.ts`)
- Editor room page → Shared file state: uses workspace state
- Shared file state → Code editor: supplies file state
- Editor room page → Room chat: offers room chat
- Shared file state → Socket state: emits sync events (evidence: `client/src/context/FileContext.tsx`)
- Socket state → HTTP and socket server: exchanges room events (evidence: `server/src/server.ts`)
- Code execution state → Shared file state: reads active files (evidence: `client/src/context/RunCodeContext.tsx`)
- Code execution state → Compiler API client: requests execution
- Compiler API client → HTTP and socket server: posts compile request
- HTTP and socket server → OneCompiler: forwards code (evidence: `server/src/server.ts`)
- Study plan pages → Study plan endpoints: requests plans
- Plan details → Study plan endpoints: requests plan details
- HTTP and socket server → Study plan endpoints: mounts routes (evidence: `server/src/server.ts`)
- Study plan endpoints → JWT verification: requires authentication (evidence: `server/src/routes/studyPlan.ts`)
- Study plan endpoints → AI study generation: generates learning content (evidence: `server/src/routes/studyPlan.ts`)
- AI study generation → Gemini AI: generates content (evidence: `server/src/services/studyPlanService.ts`)
- Study plan endpoints → Study plan records: loads and saves plans (evidence: `server/src/routes/studyPlan.ts`)
- Study plan endpoints → Study plan pages: returns plan results
