# asdf-exe/habitor architecture

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

- Interactive diagram: https://gitdiagram.com/asdf-exe/habitor
- Repository: https://github.com/asdf-exe/habitor

## Overview

Habitor is a study and progress-tracking platform for competitive programmers and GATE aspirants. A student signs in, records study sessions, and uses the authenticated app to review analytics or update GATE, goals, Codeforces, and achievement progress. The React client calls an authenticated Express REST API backed by MongoDB. The graph preserves the documented feature areas; the sampled source supports the main routing, authentication, study-log, and GATE relationships. Other feature-specific client and server links are documented capabilities, not inspected call chains.

Main entry points: [`frontend/src/App.jsx`](https://github.com/asdf-exe/habitor/blob/main/frontend/src/App.jsx) (App routing), [`frontend/src/api/axios.js`](https://github.com/asdf-exe/habitor/blob/main/frontend/src/api/axios.js) (API client), [`backend/src/models`](https://github.com/asdf-exe/habitor/tree/main/backend/src/models) (MongoDB records), [`backend/src/server.js`](https://github.com/asdf-exe/habitor/blob/main/backend/src/server.js) (Express server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_app["App routing<br/>[App.jsx]"]
  node_authui["Auth context<br/>[AuthContext.jsx]"]
  node_api["API client<br/>[axios.js]"]
  node_dashboard["Dashboard analytics<br/>[Dashboard.jsx]"]
  node_studyui["Study log UI<br/>[StudyLog.jsx]"]
  node_heatmap["Study heatmap<br/>[StudyHeatmap.jsx]"]
  node_gateui["GATE tracker<br/>[GateTracker.jsx]"]
  node_gatesubject["GATE topics<br/>[GateSubject.jsx]"]
  node_goalui["Goal tracker<br/>[GoalTracker.jsx]"]
  node_cfui["Codeforces tracker<br/>[CFTracker.jsx]"]
  node_achievementui["Achievements UI<br/>[Achievements.jsx]"]
  node_profileui["Profile UI<br/>[Profile.jsx]"]
end

subgraph group_server["API server"]
  node_server["Express server<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_authcontroller["Auth logic<br/>[authController.js]"]
  node_authguard["JWT guard<br/>[auth.js]"]
  node_models[("MongoDB records")]
end

subgraph group_learning["Study tracking"]
  node_studyroute["Study routes<br/>[studyLogRoutes.js]"]
  node_studycontroller["Study sessions and streaks"]
end

subgraph group_progress["Progress features"]
  node_gatecontroller["GATE progress logic<br/>[gateController.js]"]
  node_goalcontroller["Goal logic<br/>[goalController.js]"]
  node_cfcontroller["Codeforces sync<br/>[cfController.js]"]
  node_achievementcontroller["Achievement logic"]
  node_progressroutes["Progress routes"]
end

node_student(("Student"))
node_mongodb[("MongoDB")]
node_codeforces["Codeforces service"]

node_student -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_studyui
node_app -->|"routes to"| node_gateui
node_app -->|"routes to"| node_gatesubject
node_app -->|"routes to"| node_goalui
node_app -->|"routes to"| node_cfui
node_app -->|"routes to"| node_achievementui
node_app -->|"routes to"| node_profileui
node_app -->|"checks session"| node_authui
node_authui -->|"requests auth"| node_api
node_studyui -->|"renders"| node_heatmap
node_studyui -->|"loads and saves"| node_api
node_dashboard -->|"loads analytics"| node_api
node_gateui -.->|"updates progress"| node_api
node_gatesubject -.->|"updates topics"| node_api
node_goalui -.->|"manages goals"| node_api
node_cfui -->|"loads ratings"| node_api
node_cfui -.->|"syncs ratings"| node_codeforces
node_achievementui -.->|"loads badges"| node_api
node_api -->|"calls REST API"| node_server
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_studyroute
node_server -->|"mounts"| node_progressroutes
node_authroutes -->|"dispatches to"| node_authcontroller
node_authroutes -->|"protects routes"| node_authguard
node_studyroute -->|"dispatches to"| node_studycontroller
node_studyroute -->|"protects routes"| node_authguard
node_progressroutes -.->|"dispatches to"| node_gatecontroller
node_progressroutes -.->|"dispatches to"| node_goalcontroller
node_progressroutes -.->|"dispatches to"| node_cfcontroller
node_progressroutes -.->|"dispatches to"| node_achievementcontroller
node_gatecontroller -->|"reads and writes"| node_models
node_studycontroller -->|"reads and writes"| node_models
node_authcontroller -->|"reads and writes"| node_models
node_goalcontroller -->|"reads and writes"| node_models
node_cfcontroller -->|"reads and writes"| node_models
node_achievementcontroller -->|"reads and writes"| node_models
node_server -->|"connects"| node_mongodb

click node_app "https://github.com/asdf-exe/habitor/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/asdf-exe/habitor/blob/main/frontend/src/context/AuthContext.jsx"
click node_api "https://github.com/asdf-exe/habitor/blob/main/frontend/src/api/axios.js"
click node_dashboard "https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/Dashboard.jsx"
click node_studyui "https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/StudyLog.jsx"
click node_heatmap "https://github.com/asdf-exe/habitor/blob/main/frontend/src/components/StudyHeatmap.jsx"
click node_gateui "https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/GateTracker.jsx"
click node_gatesubject "https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/GateSubject.jsx"
click node_goalui "https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/GoalTracker.jsx"
click node_cfui "https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/CFTracker.jsx"
click node_achievementui "https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/Achievements.jsx"
click node_profileui "https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/Profile.jsx"
click node_server "https://github.com/asdf-exe/habitor/blob/main/backend/src/server.js"
click node_authroutes "https://github.com/asdf-exe/habitor/blob/main/backend/src/routes/authRoutes.js"
click node_authcontroller "https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/authController.js"
click node_authguard "https://github.com/asdf-exe/habitor/blob/main/backend/src/middleware/auth.js"
click node_studyroute "https://github.com/asdf-exe/habitor/blob/main/backend/src/routes/studyLogRoutes.js"
click node_studycontroller "https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/studyLogController.js"
click node_gatecontroller "https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/gateController.js"
click node_goalcontroller "https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/goalController.js"
click node_cfcontroller "https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/cfController.js"
click node_achievementcontroller "https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/achievementController.js"
click node_progressroutes "https://github.com/asdf-exe/habitor/tree/main/backend/src/routes"
click node_models "https://github.com/asdf-exe/habitor/tree/main/backend/src/models"

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_api,node_dashboard,node_studyui,node_heatmap,node_gateui,node_gatesubject,node_goalui,node_cfui,node_achievementui,node_profileui toneBlue
class node_server,node_authroutes,node_authcontroller,node_authguard,node_models,node_mongodb toneAmber
class node_studyroute,node_studycontroller toneMint
class node_gatecontroller,node_goalcontroller,node_cfcontroller,node_achievementcontroller,node_progressroutes toneRose
class node_student,node_codeforces toneIndigo
```

## Components

### React client

- [App routing](https://github.com/asdf-exe/habitor/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth context](https://github.com/asdf-exe/habitor/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/asdf-exe/habitor/blob/main/frontend/src/api/axios.js): `frontend/src/api/axios.js`
- [Dashboard analytics](https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Study log UI](https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/StudyLog.jsx): `frontend/src/pages/StudyLog.jsx`
- [Study heatmap](https://github.com/asdf-exe/habitor/blob/main/frontend/src/components/StudyHeatmap.jsx): `frontend/src/components/StudyHeatmap.jsx`
- [GATE tracker](https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/GateTracker.jsx): `frontend/src/pages/GateTracker.jsx`
- [GATE topics](https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/GateSubject.jsx): `frontend/src/pages/GateSubject.jsx`
- [Goal tracker](https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/GoalTracker.jsx): `frontend/src/pages/GoalTracker.jsx`
- [Codeforces tracker](https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/CFTracker.jsx): `frontend/src/pages/CFTracker.jsx`
- [Achievements UI](https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/Achievements.jsx): `frontend/src/pages/Achievements.jsx`
- [Profile UI](https://github.com/asdf-exe/habitor/blob/main/frontend/src/pages/Profile.jsx): `frontend/src/pages/Profile.jsx`

### API server

- [Express server](https://github.com/asdf-exe/habitor/blob/main/backend/src/server.js): `backend/src/server.js`
- [Auth routes](https://github.com/asdf-exe/habitor/blob/main/backend/src/routes/authRoutes.js): `backend/src/routes/authRoutes.js`
- [Auth logic](https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [JWT guard](https://github.com/asdf-exe/habitor/blob/main/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`
- [MongoDB records](https://github.com/asdf-exe/habitor/tree/main/backend/src/models): `backend/src/models`

### Study tracking

- [Study routes](https://github.com/asdf-exe/habitor/blob/main/backend/src/routes/studyLogRoutes.js): `backend/src/routes/studyLogRoutes.js`
- [Study sessions and streaks](https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/studyLogController.js): `backend/src/controllers/studyLogController.js`

### Progress features

- [GATE progress logic](https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/gateController.js): `backend/src/controllers/gateController.js`
- [Goal logic](https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/goalController.js): `backend/src/controllers/goalController.js`
- [Codeforces sync](https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/cfController.js): `backend/src/controllers/cfController.js`
- [Achievement logic](https://github.com/asdf-exe/habitor/blob/main/backend/src/controllers/achievementController.js): `backend/src/controllers/achievementController.js`
- [Progress routes](https://github.com/asdf-exe/habitor/tree/main/backend/src/routes): `backend/src/routes`

### Other components

- **Student**
- **MongoDB**
- **Codeforces service**

## Connections

- Student → App routing: uses (evidence: `README.md`)
- App routing → Dashboard analytics: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Study log UI: routes to (evidence: `frontend/src/App.jsx`)
- App routing → GATE tracker: routes to (evidence: `frontend/src/App.jsx`)
- App routing → GATE topics: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Goal tracker: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Codeforces tracker: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Achievements UI: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Profile UI: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Auth context: checks session (evidence: `frontend/src/App.jsx`)
- Auth context → API client: requests auth (evidence: `frontend/src/context/AuthContext.jsx`)
- Study log UI → Study heatmap: renders (evidence: `frontend/src/pages/StudyLog.jsx`)
- Study log UI → API client: loads and saves (evidence: `frontend/src/pages/StudyLog.jsx`)
- Dashboard analytics → API client: loads analytics (evidence: `frontend/src/pages/Dashboard.jsx`)
- GATE tracker → API client: updates progress (evidence: `README.md`)
- GATE topics → API client: updates topics (evidence: `README.md`)
- Goal tracker → API client: manages goals (evidence: `README.md`)
- Codeforces tracker → API client: loads ratings (evidence: `frontend/src/pages/CFTracker.jsx`)
- Codeforces tracker → Codeforces service: syncs ratings (evidence: `README.md`)
- Achievements UI → API client: loads badges (evidence: `README.md`)
- API client → Express server: calls REST API (evidence: `README.md`)
- Express server → Auth routes: mounts (evidence: `backend/src/server.js`)
- Express server → Study routes: mounts (evidence: `backend/src/server.js`)
- Express server → Progress routes: mounts (evidence: `backend/src/server.js`)
- Auth routes → Auth logic: dispatches to (evidence: `backend/src/routes/authRoutes.js`)
- Auth routes → JWT guard: protects routes (evidence: `backend/src/routes/authRoutes.js`)
- Study routes → Study sessions and streaks: dispatches to (evidence: `backend/src/routes/studyLogRoutes.js`)
- Study routes → JWT guard: protects routes (evidence: `backend/src/routes/studyLogRoutes.js`)
- Progress routes → GATE progress logic: dispatches to (evidence: `backend/src/routes/gateRoutes.js`)
- Progress routes → Goal logic: dispatches to (evidence: `backend/src/routes/goalRoutes.js`)
- Progress routes → Codeforces sync: dispatches to (evidence: `backend/src/routes/cfRoutes.js`)
- Progress routes → Achievement logic: dispatches to (evidence: `backend/src/routes/achievementRoutes.js`)
- GATE progress logic → MongoDB records: reads and writes (evidence: `backend/src/controllers/gateController.js`)
- Study sessions and streaks → MongoDB records: reads and writes (evidence: `backend/src/controllers/studyLogController.js`)
- Auth logic → MongoDB records: reads and writes (evidence: `backend/src/controllers/authController.js`)
- Goal logic → MongoDB records: reads and writes (evidence: `backend/src/controllers/goalController.js`)
- Codeforces sync → MongoDB records: reads and writes (evidence: `backend/src/controllers/cfController.js`)
- Achievement logic → MongoDB records: reads and writes (evidence: `backend/src/controllers/achievementController.js`)
- Express server → MongoDB: connects (evidence: `backend/src/server.js`)
