# storevia/srmap-api architecture

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

- Interactive diagram: https://gitdiagram.com/storevia/srmap-api
- Repository: https://github.com/storevia/srmap-api

## Overview

Srmap API is a student portal and utility suite. Students use protected pages to access academic data and tools; requests are authenticated, served from stored data or fetched from SRM, then returned to the portal. Separate branches cover study resources, secure sharing, and the multiplayer/singleplayer arcade. The graph preserves README capabilities even where their implementation was not sampled. Edges without direct source excerpts rely on README statements; detailed wiring for several unsampled features is therefore not asserted.

Main entry points: [`src/app/(protected)/layout.tsx`](https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/layout.tsx) (Protected Portal), [`arcade-server/src/gateway/arcade.gateway.ts`](https://github.com/storevia/srmap-api/blob/main/arcade-server/src/gateway/arcade.gateway.ts) (Realtime Gateway), [`src/lib/database/mongodb.ts`](https://github.com/storevia/srmap-api/blob/main/src/lib/database/mongodb.ts) (MongoDB), [`src/app/api/srmapi/fetch/route.ts`](https://github.com/storevia/srmap-api/blob/main/src/app/api/srmapi/fetch/route.ts) (Academic Fetch Route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Student Portal"]
  node_portal_ui["Protected Portal<br/>[layout.tsx]"]
  node_local_state["Accounts &amp; Settings"]
end

subgraph group_academic["Academic Services"]
  node_attendance["Attendance Tools<br/>[page.tsx]"]
  node_timetable["Timetable Tools<br/>[page.tsx]"]
  node_exam_results["Exams &amp; Results<br/>[page.tsx]"]
  node_vacant["Vacant Classrooms<br/>[route.ts]"]
  node_srm_api["SRM Data Fetch<br/>[fetchData.ts]"]
  node_fetch_route["Academic Fetch Route<br/>[route.ts]"]
  node_academic_routes["Academic API Routes"]
end

subgraph group_sharing["Resources &amp; Sharing"]
  node_resources_ui["Study Resources<br/>[page.tsx]"]
  node_resource_admin["Resource Admin<br/>[page.tsx]"]
  node_share_ui["Secure Sharing<br/>[page.tsx]"]
  node_share_routes["Share API<br/>[route.ts]"]
  node_share_service["Share Service<br/>[shareService.ts]"]
  node_object_storage[("Object Storage<br/>[s3Clients.ts]")]
end

subgraph group_arcade["Arcade"]
  node_arcade_ui["Arcade Client<br/>[ArcadeContext.tsx]"]
  node_arcade_gateway["Realtime Gateway<br/>[arcade.gateway.ts]"]
  node_chess["Chess Games<br/>[chess.service.ts]"]
  node_typing["Typing Test"]
  node_matchmaking["Matchmaking"]
  node_arcade_chat["Game Chat<br/>[chat.service.ts]"]
end

subgraph group_platform["Platform Services"]
  node_auth["Request Auth<br/>[functions.ts]"]
  node_mongo[("MongoDB<br/>[mongodb.ts]")]
  node_sync_route["Settings Sync<br/>[route.ts]"]
end

node_student(("Student"))
node_srm_system["SRM Portal"]

node_student -->|"uses"| node_portal_ui
node_portal_ui -->|"opens"| node_attendance
node_portal_ui -->|"opens"| node_timetable
node_portal_ui -->|"opens"| node_exam_results
node_portal_ui -->|"queries"| node_vacant
node_portal_ui -->|"opens"| node_resources_ui
node_portal_ui -->|"opens"| node_share_ui
node_portal_ui -->|"opens"| node_arcade_ui
node_local_state -->|"syncs settings"| node_sync_route
node_sync_route -->|"reads/writes"| node_mongo
node_fetch_route -->|"authenticates"| node_auth
node_fetch_route -->|"fetches data"| node_srm_api
node_srm_api -.->|"scrapes"| node_srm_system
node_fetch_route -->|"reads/writes cache"| node_mongo
node_academic_routes -.->|"serves academic data"| node_srm_system
node_vacant -->|"checks timetable count"| node_mongo
node_student -->|"administers resources"| node_resource_admin
node_share_ui -.->|"requests shares"| node_share_routes
node_share_routes -->|"delegates"| node_share_service
node_share_service -->|"stores share records"| node_mongo
node_share_service -->|"uploads/deletes files"| node_object_storage
node_arcade_ui -.->|"connects realtime"| node_arcade_gateway
node_arcade_gateway -.->|"dispatches chess"| node_chess
node_arcade_gateway -.->|"dispatches typing"| node_typing
node_arcade_gateway -.->|"dispatches matching"| node_matchmaking
node_arcade_gateway -.->|"dispatches chat"| node_arcade_chat

click node_portal_ui "https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/layout.tsx"
click node_local_state "https://github.com/storevia/srmap-api/blob/main/src/context/LocalStorageContext.tsx"
click node_attendance "https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/attendance/page.tsx"
click node_timetable "https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/timetable/page.tsx"
click node_exam_results "https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/exams/internals/page.tsx"
click node_vacant "https://github.com/storevia/srmap-api/blob/main/src/app/api/vacant/route.ts"
click node_srm_api "https://github.com/storevia/srmap-api/blob/main/src/server/srmapi/fetchData.ts"
click node_fetch_route "https://github.com/storevia/srmap-api/blob/main/src/app/api/srmapi/fetch/route.ts"
click node_academic_routes "https://github.com/storevia/srmap-api/tree/main/src/app/api/srmapi"
click node_resources_ui "https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/resources/page.tsx"
click node_resource_admin "https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/admin/resources/page.tsx"
click node_share_ui "https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/share/page.tsx"
click node_share_routes "https://github.com/storevia/srmap-api/blob/main/src/app/api/share/create/route.ts"
click node_share_service "https://github.com/storevia/srmap-api/blob/main/src/server/share/shareService.ts"
click node_object_storage "https://github.com/storevia/srmap-api/blob/main/src/server/share/s3Clients.ts"
click node_arcade_ui "https://github.com/storevia/srmap-api/blob/main/src/context/ArcadeContext.tsx"
click node_arcade_gateway "https://github.com/storevia/srmap-api/blob/main/arcade-server/src/gateway/arcade.gateway.ts"
click node_chess "https://github.com/storevia/srmap-api/blob/main/arcade-server/src/games/chess/chess.service.ts"
click node_typing "https://github.com/storevia/srmap-api/blob/main/arcade-server/src/games/typingtest/typingtest.service.ts"
click node_matchmaking "https://github.com/storevia/srmap-api/blob/main/arcade-server/src/matchmaking/matchmaking.service.ts"
click node_arcade_chat "https://github.com/storevia/srmap-api/blob/main/arcade-server/src/chat/chat.service.ts"
click node_auth "https://github.com/storevia/srmap-api/blob/main/src/server/utils/functions.ts"
click node_mongo "https://github.com/storevia/srmap-api/blob/main/src/lib/database/mongodb.ts"
click node_sync_route "https://github.com/storevia/srmap-api/blob/main/src/app/api/sync/route.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_portal_ui,node_local_state toneBlue
class node_attendance,node_timetable,node_exam_results,node_vacant,node_srm_api,node_fetch_route,node_academic_routes toneAmber
class node_resources_ui,node_resource_admin,node_share_ui,node_share_routes,node_share_service,node_object_storage toneMint
class node_arcade_ui,node_arcade_gateway,node_chess,node_typing,node_matchmaking,node_arcade_chat toneRose
class node_auth,node_mongo,node_sync_route,node_student,node_srm_system toneIndigo
```

## Components

### Student Portal

- [Protected Portal](https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/layout.tsx): `src/app/(protected)/layout.tsx`
- [Accounts & Settings](https://github.com/storevia/srmap-api/blob/main/src/context/LocalStorageContext.tsx): `src/context/LocalStorageContext.tsx`

### Academic Services

- [Attendance Tools](https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/attendance/page.tsx): `src/app/(protected)/attendance/page.tsx`
- [Timetable Tools](https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/timetable/page.tsx): `src/app/(protected)/timetable/page.tsx`
- [Exams & Results](https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/exams/internals/page.tsx): `src/app/(protected)/exams/internals/page.tsx`
- [Vacant Classrooms](https://github.com/storevia/srmap-api/blob/main/src/app/api/vacant/route.ts): `src/app/api/vacant/route.ts`
- [SRM Data Fetch](https://github.com/storevia/srmap-api/blob/main/src/server/srmapi/fetchData.ts): `src/server/srmapi/fetchData.ts`
- [Academic Fetch Route](https://github.com/storevia/srmap-api/blob/main/src/app/api/srmapi/fetch/route.ts): `src/app/api/srmapi/fetch/route.ts`
- [Academic API Routes](https://github.com/storevia/srmap-api/tree/main/src/app/api/srmapi): `src/app/api/srmapi`

### Resources & Sharing

- [Study Resources](https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/resources/page.tsx): `src/app/(protected)/resources/page.tsx`
- [Resource Admin](https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/admin/resources/page.tsx): `src/app/(protected)/admin/resources/page.tsx`
- [Secure Sharing](https://github.com/storevia/srmap-api/blob/main/src/app/(protected)/share/page.tsx): `src/app/(protected)/share/page.tsx`
- [Share API](https://github.com/storevia/srmap-api/blob/main/src/app/api/share/create/route.ts): `src/app/api/share/create/route.ts`
- [Share Service](https://github.com/storevia/srmap-api/blob/main/src/server/share/shareService.ts): `src/server/share/shareService.ts`
- [Object Storage](https://github.com/storevia/srmap-api/blob/main/src/server/share/s3Clients.ts): `src/server/share/s3Clients.ts`

### Arcade

- [Arcade Client](https://github.com/storevia/srmap-api/blob/main/src/context/ArcadeContext.tsx): `src/context/ArcadeContext.tsx`
- [Realtime Gateway](https://github.com/storevia/srmap-api/blob/main/arcade-server/src/gateway/arcade.gateway.ts): `arcade-server/src/gateway/arcade.gateway.ts`
- [Chess Games](https://github.com/storevia/srmap-api/blob/main/arcade-server/src/games/chess/chess.service.ts): `arcade-server/src/games/chess/chess.service.ts`
- [Typing Test](https://github.com/storevia/srmap-api/blob/main/arcade-server/src/games/typingtest/typingtest.service.ts): `arcade-server/src/games/typingtest/typingtest.service.ts`
- [Matchmaking](https://github.com/storevia/srmap-api/blob/main/arcade-server/src/matchmaking/matchmaking.service.ts): `arcade-server/src/matchmaking/matchmaking.service.ts`
- [Game Chat](https://github.com/storevia/srmap-api/blob/main/arcade-server/src/chat/chat.service.ts): `arcade-server/src/chat/chat.service.ts`

### Platform Services

- [Request Auth](https://github.com/storevia/srmap-api/blob/main/src/server/utils/functions.ts): `src/server/utils/functions.ts`
- [MongoDB](https://github.com/storevia/srmap-api/blob/main/src/lib/database/mongodb.ts): `src/lib/database/mongodb.ts`
- [Settings Sync](https://github.com/storevia/srmap-api/blob/main/src/app/api/sync/route.ts): `src/app/api/sync/route.ts`

### Other components

- **Student**
- **SRM Portal**

## Connections

- Student → Protected Portal: uses
- Protected Portal → Attendance Tools: opens
- Protected Portal → Timetable Tools: opens
- Protected Portal → Exams & Results: opens
- Protected Portal → Vacant Classrooms: queries
- Protected Portal → Study Resources: opens
- Protected Portal → Secure Sharing: opens
- Protected Portal → Arcade Client: opens
- Accounts & Settings → Settings Sync: syncs settings (evidence: `src/context/LocalStorageContext.tsx`)
- Settings Sync → MongoDB: reads/writes (evidence: `src/app/api/sync/route.ts`)
- Academic Fetch Route → Request Auth: authenticates (evidence: `src/app/api/srmapi/fetch/route.ts`)
- Academic Fetch Route → SRM Data Fetch: fetches data (evidence: `src/app/api/srmapi/fetch/route.ts`)
- SRM Data Fetch → SRM Portal: scrapes
- Academic Fetch Route → MongoDB: reads/writes cache (evidence: `src/app/api/srmapi/fetch/route.ts`)
- Academic API Routes → SRM Portal: serves academic data
- Vacant Classrooms → MongoDB: checks timetable count (evidence: `src/app/api/vacant/route.ts`)
- Student → Resource Admin: administers resources
- Secure Sharing → Share API: requests shares
- Share API → Share Service: delegates (evidence: `src/app/api/share/create/route.ts`)
- Share Service → MongoDB: stores share records (evidence: `src/server/share/shareService.ts`)
- Share Service → Object Storage: uploads/deletes files (evidence: `src/server/share/shareService.ts`)
- Arcade Client → Realtime Gateway: connects realtime
- Realtime Gateway → Chess Games: dispatches chess
- Realtime Gateway → Typing Test: dispatches typing
- Realtime Gateway → Matchmaking: dispatches matching
- Realtime Gateway → Game Chat: dispatches chat
