# atuldhull/math-collective architecture

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

- Interactive diagram: https://gitdiagram.com/atuldhull/math-collective
- Repository: https://github.com/atuldhull/math-collective

## Overview

Math Collective is a competitive mathematics platform for university communities. Students browse problems and roadmaps, get AI study help, submit work, join events and live quizzes, and earn recognition; teachers and administrators manage content, events, payments, and users. The graph follows the user-facing workflow into backend domain handlers and shared services, while retaining major documented branches such as social features, portfolios, messaging, and administration. Some links rely on README descriptions because the corresponding source was not sampled; those relationships are shown as documented rather than inferred from imports.

Main entry points: [`backend/config/supabase.js`](https://github.com/atuldhull/math-collective/blob/main/backend/config/supabase.js) (Supabase database), [`frontend/src/app/App.jsx`](https://github.com/atuldhull/math-collective/blob/main/frontend/src/app/App.jsx) (Web application), [`backend/controllers/notificationController.js`](https://github.com/atuldhull/math-collective/blob/main/backend/controllers/notificationController.js) (Notification delivery), [`frontend/src/features/problems/pages/ProblemDetailPage.jsx`](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/problems/pages/ProblemDetailPage.jsx) (Problem study)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Student experience"]
  node_webapp["Web application<br/>[App.jsx]"]
end

subgraph group_learning["Learning and competition"]
  node_problem_discovery["Problem catalogue"]
  node_problem_detail["Problem study"]
  node_problem_submit["Problem submission"]
  node_roadmaps["Learning roadmaps"]
  node_ai_companion["AI study companion<br/>[AiCompanion.jsx]"]
  node_arena["Challenge arena<br/>[ArenaPage.jsx]"]
  node_live_quiz["Live quizzes<br/>[LiveQuizPage.jsx]"]
  node_events["Events and attendance<br/>[EventsPage.jsx]"]
  node_leaderboards["Leaderboards and XP"]
  node_problem_service["Problem domain"]
  node_roadmap_service["Roadmap domain"]
  node_quiz_service["Quiz runtime<br/>[quiz.js]"]
  node_event_service["Event management"]
  node_panda_tools["PANDA tools<br/>[pandaTools.js]"]
end

subgraph group_community["Community features"]
  node_profiles["Profiles and portfolios"]
  node_messaging["E2EE messaging"]
  node_notification_service["Notification delivery"]
end

subgraph group_operations["Administration"]
  node_admin_portal["Admin operations"]
  node_admin_api["Admin handlers<br/>[adminController.js]"]
end

subgraph group_platform["Platform services"]
  node_backend_api["HTTP API<br/>[app.js]"]
  node_ai_service["AI provider layer<br/>[llm.js]"]
  node_database[("Supabase database<br/>[supabase.js]")]
  node_socket_runtime["Socket.IO server<br/>[index.js]"]
end

node_student(("Student"))
node_teacher(("Teacher / admin"))
node_llm_provider{{"Gemini / OpenRouter"}}

node_student -->|"uses"| node_webapp
node_teacher -->|"uses"| node_webapp
node_webapp -.->|"opens"| node_problem_discovery
node_problem_discovery -->|"opens"| node_problem_detail
node_problem_detail -->|"submits"| node_problem_submit
node_problem_detail -->|"asks for hints"| node_ai_companion
node_student -->|"browses"| node_roadmaps
node_student -->|"solves challenges"| node_arena
node_student -->|"joins"| node_live_quiz
node_teacher -->|"hosts"| node_live_quiz
node_student -->|"checks in"| node_events
node_student -->|"views rankings"| node_leaderboards
node_student -->|"views"| node_profiles
node_student -->|"messages"| node_messaging
node_webapp -.->|"requests"| node_backend_api
node_backend_api -.->|"routes requests"| node_problem_service
node_backend_api -.->|"routes requests"| node_roadmap_service
node_problem_service -->|"reads and writes"| node_database
node_roadmap_service -->|"reads and writes"| node_database
node_problem_service -->|"notifies users"| node_notification_service
node_roadmap_service -->|"notifies users"| node_notification_service
node_ai_companion -.->|"requests tutoring"| node_ai_service
node_ai_service -->|"calls models"| node_llm_provider
node_ai_service -.->|"supports tool calls"| node_panda_tools
node_live_quiz -->|"uses realtime"| node_socket_runtime
node_socket_runtime -.->|"dispatches quiz events"| node_quiz_service
node_events -.->|"registers"| node_event_service
node_event_service -->|"reads and writes"| node_database
node_teacher -->|"manages"| node_admin_portal
node_admin_portal -.->|"requests operations"| node_admin_api
node_admin_api -.->|"manages records"| node_database
node_event_service -->|"sends payment notices"| node_notification_service
node_notification_service -->|"persists notifications"| node_database

click node_webapp "https://github.com/atuldhull/math-collective/blob/main/frontend/src/app/App.jsx"
click node_problem_discovery "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/problems/pages/ProblemsListPage.jsx"
click node_problem_detail "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/problems/pages/ProblemDetailPage.jsx"
click node_problem_submit "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/problems/pages/SubmitProblemPage.jsx"
click node_roadmaps "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/roadmaps/pages/RoadmapsListPage.jsx"
click node_ai_companion "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/problems/components/AiCompanion.jsx"
click node_arena "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/arena/pages/ArenaPage.jsx"
click node_live_quiz "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/student/pages/LiveQuizPage.jsx"
click node_events "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/events/pages/EventsPage.jsx"
click node_leaderboards "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/public/pages/LeaderboardPage.jsx"
click node_profiles "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/profile/pages/RichProfilePage.jsx"
click node_messaging "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/student/pages/NotificationsPage.jsx"
click node_backend_api "https://github.com/atuldhull/math-collective/blob/main/backend/app.js"
click node_problem_service "https://github.com/atuldhull/math-collective/blob/main/backend/controllers/problemController.js"
click node_roadmap_service "https://github.com/atuldhull/math-collective/blob/main/backend/controllers/roadmapController.js"
click node_quiz_service "https://github.com/atuldhull/math-collective/blob/main/backend/socket/quiz.js"
click node_event_service "https://github.com/atuldhull/math-collective/blob/main/backend/controllers/event/eventCrudController.js"
click node_ai_service "https://github.com/atuldhull/math-collective/blob/main/backend/lib/llm.js"
click node_panda_tools "https://github.com/atuldhull/math-collective/blob/main/backend/lib/pandaTools.js"
click node_notification_service "https://github.com/atuldhull/math-collective/blob/main/backend/controllers/notificationController.js"
click node_admin_portal "https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/admin/pages/AdminOverviewPage.jsx"
click node_admin_api "https://github.com/atuldhull/math-collective/blob/main/backend/controllers/adminController.js"
click node_database "https://github.com/atuldhull/math-collective/blob/main/backend/config/supabase.js"
click node_socket_runtime "https://github.com/atuldhull/math-collective/blob/main/backend/socket/index.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_webapp toneBlue
class node_problem_discovery,node_problem_detail,node_problem_submit,node_roadmaps,node_ai_companion,node_arena,node_live_quiz,node_events,node_leaderboards,node_problem_service,node_roadmap_service,node_quiz_service,node_event_service,node_panda_tools toneAmber
class node_profiles,node_messaging,node_notification_service,node_llm_provider toneMint
class node_admin_portal,node_admin_api toneRose
class node_backend_api,node_ai_service,node_database,node_socket_runtime,node_student,node_teacher toneIndigo
```

## Components

### Student experience

- [Web application](https://github.com/atuldhull/math-collective/blob/main/frontend/src/app/App.jsx): `frontend/src/app/App.jsx`

### Learning and competition

- [Problem catalogue](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/problems/pages/ProblemsListPage.jsx): `frontend/src/features/problems/pages/ProblemsListPage.jsx`
- [Problem study](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/problems/pages/ProblemDetailPage.jsx): `frontend/src/features/problems/pages/ProblemDetailPage.jsx`
- [Problem submission](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/problems/pages/SubmitProblemPage.jsx): `frontend/src/features/problems/pages/SubmitProblemPage.jsx`
- [Learning roadmaps](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/roadmaps/pages/RoadmapsListPage.jsx): `frontend/src/features/roadmaps/pages/RoadmapsListPage.jsx`
- [AI study companion](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/problems/components/AiCompanion.jsx): `frontend/src/features/problems/components/AiCompanion.jsx`
- [Challenge arena](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/arena/pages/ArenaPage.jsx): `frontend/src/features/arena/pages/ArenaPage.jsx`
- [Live quizzes](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/student/pages/LiveQuizPage.jsx): `frontend/src/features/student/pages/LiveQuizPage.jsx`
- [Events and attendance](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/events/pages/EventsPage.jsx): `frontend/src/features/events/pages/EventsPage.jsx`
- [Leaderboards and XP](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/public/pages/LeaderboardPage.jsx): `frontend/src/features/public/pages/LeaderboardPage.jsx`
- [Problem domain](https://github.com/atuldhull/math-collective/blob/main/backend/controllers/problemController.js): `backend/controllers/problemController.js`
- [Roadmap domain](https://github.com/atuldhull/math-collective/blob/main/backend/controllers/roadmapController.js): `backend/controllers/roadmapController.js`
- [Quiz runtime](https://github.com/atuldhull/math-collective/blob/main/backend/socket/quiz.js): `backend/socket/quiz.js`
- [Event management](https://github.com/atuldhull/math-collective/blob/main/backend/controllers/event/eventCrudController.js): `backend/controllers/event/eventCrudController.js`
- [PANDA tools](https://github.com/atuldhull/math-collective/blob/main/backend/lib/pandaTools.js): `backend/lib/pandaTools.js`

### Community features

- [Profiles and portfolios](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/profile/pages/RichProfilePage.jsx): `frontend/src/features/profile/pages/RichProfilePage.jsx`
- [E2EE messaging](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/student/pages/NotificationsPage.jsx): `frontend/src/features/student/pages/NotificationsPage.jsx`
- [Notification delivery](https://github.com/atuldhull/math-collective/blob/main/backend/controllers/notificationController.js): `backend/controllers/notificationController.js`

### Administration

- [Admin operations](https://github.com/atuldhull/math-collective/blob/main/frontend/src/features/admin/pages/AdminOverviewPage.jsx): `frontend/src/features/admin/pages/AdminOverviewPage.jsx`
- [Admin handlers](https://github.com/atuldhull/math-collective/blob/main/backend/controllers/adminController.js): `backend/controllers/adminController.js`

### Platform services

- [HTTP API](https://github.com/atuldhull/math-collective/blob/main/backend/app.js): `backend/app.js`
- [AI provider layer](https://github.com/atuldhull/math-collective/blob/main/backend/lib/llm.js): `backend/lib/llm.js`
- [Supabase database](https://github.com/atuldhull/math-collective/blob/main/backend/config/supabase.js): `backend/config/supabase.js`
- [Socket.IO server](https://github.com/atuldhull/math-collective/blob/main/backend/socket/index.js): `backend/socket/index.js`

### Other components

- **Student**
- **Teacher / admin**
- **Gemini / OpenRouter**

## Connections

- Student → Web application: uses (evidence: `README.md`)
- Teacher / admin → Web application: uses (evidence: `README.md`)
- Web application → Problem catalogue: opens
- Problem catalogue → Problem study: opens (evidence: `README.md`)
- Problem study → Problem submission: submits (evidence: `README.md`)
- Problem study → AI study companion: asks for hints (evidence: `README.md`)
- Student → Learning roadmaps: browses (evidence: `README.md`)
- Student → Challenge arena: solves challenges (evidence: `README.md`)
- Student → Live quizzes: joins (evidence: `README.md`)
- Teacher / admin → Live quizzes: hosts (evidence: `README.md`)
- Student → Events and attendance: checks in (evidence: `README.md`)
- Student → Leaderboards and XP: views rankings (evidence: `README.md`)
- Student → Profiles and portfolios: views (evidence: `README.md`)
- Student → E2EE messaging: messages (evidence: `README.md`)
- Web application → HTTP API: requests
- HTTP API → Problem domain: routes requests
- HTTP API → Roadmap domain: routes requests
- Problem domain → Supabase database: reads and writes (evidence: `backend/controllers/problemController.js`)
- Roadmap domain → Supabase database: reads and writes (evidence: `backend/controllers/roadmapController.js`)
- Problem domain → Notification delivery: notifies users (evidence: `backend/controllers/problemController.js`)
- Roadmap domain → Notification delivery: notifies users (evidence: `backend/controllers/roadmapController.js`)
- AI study companion → AI provider layer: requests tutoring
- AI provider layer → Gemini / OpenRouter: calls models (evidence: `README.md`)
- AI provider layer → PANDA tools: supports tool calls
- Live quizzes → Socket.IO server: uses realtime (evidence: `README.md`)
- Socket.IO server → Quiz runtime: dispatches quiz events
- Events and attendance → Event management: registers
- Event management → Supabase database: reads and writes (evidence: `backend/controllers/event/eventCrudController.js`)
- Teacher / admin → Admin operations: manages (evidence: `README.md`)
- Admin operations → Admin handlers: requests operations
- Admin handlers → Supabase database: manages records
- Event management → Notification delivery: sends payment notices (evidence: `backend/controllers/event/eventCrudController.js`)
- Notification delivery → Supabase database: persists notifications (evidence: `backend/controllers/notificationController.js`)
