# mradipatil770-cpu/cybersathi architecture

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

- Interactive diagram: https://gitdiagram.com/mradipatil770-cpu/cybersathi
- Repository: https://github.com/mradipatil770-cpu/cybersathi

## Overview

CyberSathi is a story-driven cybersecurity training platform with a separate institutional learning-management workflow. Learners authenticate or enter as guests, choose a scenario, investigate evidence through interactive challenges, and receive debriefs and progression rewards. The React client serves gameplay, learning notes, and role-based institution dashboards; authenticated data operations go through FastAPI to Supabase, while guest progress stays in browser storage. README documents capabilities beyond the sampled source, so uncertain implementation-level links are omitted.

Main entry points: [`frontend/src/pages/Storyline.jsx`](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/pages/Storyline.jsx) (Scenario gameplay), [`frontend/src/lib/apiClient.js`](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/apiClient.js) (API client), [`frontend/src/pages/MissionDetails.jsx`](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/pages/MissionDetails.jsx) (Scenario map), [`frontend/src/context/AuthContext.jsx`](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/context/AuthContext.jsx) (Auth context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Scenario learning"]
  node_landing["Scenario discovery<br/>[Landing.jsx]"]
  node_mission["Scenario map<br/>[MissionDetails.jsx]"]
  node_storyline["Scenario gameplay<br/>[Storyline.jsx]"]
  node_levelengine["Challenge selector<br/>[LevelEngine.jsx]"]
  node_challenges["Challenge types"]
  node_storydata["Scenario content<br/>[storylines.js]"]
  node_learningnotes["Learning notes"]
end

subgraph group_identity["Identity and access"]
  node_app["React application<br/>[App.jsx]"]
  node_authcontext["Auth context<br/>[AuthContext.jsx]"]
end

subgraph group_progress["Player progress"]
  node_dashboard["Player dashboard<br/>[Dashboard.jsx]"]
  node_progressclient["Progress client<br/>[progress.js]"]
  node_scoring["Scoring logic<br/>[scoring.js]"]
  node_rewards["Achievements and streaks"]
  node_leaderboard["Leaderboard"]
end

subgraph group_institutions["Institution management"]
  node_institutiondash["Institution dashboards"]
  node_institutionclient["Institution services"]
end

subgraph group_services["Backend services"]
  node_apiclient["API client<br/>[apiClient.js]"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_routers["API route modules"]
  node_authverify["Session verification<br/>[auth.py]"]
  node_supabaseadmin["Database access<br/>[supabase_admin.py]"]
end

node_learner(("Learner"))
node_authprovider["Supabase Auth"]
node_supabase[("Supabase data services")]
node_gueststorage[("Browser progress storage")]

node_learner -->|"uses"| node_app
node_app -->|"provides auth"| node_authcontext
node_authcontext -->|"signs in"| node_authprovider
node_authcontext -->|"ensures profile"| node_apiclient
node_learner -->|"discovers scenarios"| node_landing
node_landing -->|"opens scenario"| node_mission
node_mission -->|"starts investigation"| node_storyline
node_storyline -->|"loads scenario"| node_storydata
node_storyline -->|"renders level"| node_levelengine
node_levelengine -->|"selects challenge"| node_challenges
node_mission -->|"opens notes"| node_learningnotes
node_storyline -->|"opens notes"| node_learningnotes
node_learner -->|"views progress"| node_dashboard
node_storyline -->|"saves progress"| node_progressclient
node_progressclient -.->|"stores guest data"| node_gueststorage
node_progressclient -->|"syncs progress"| node_apiclient
node_storyline -->|"scores attempts"| node_scoring
node_dashboard -->|"loads rewards"| node_rewards
node_dashboard -->|"loads standings"| node_leaderboard
node_learner -->|"uses institution tools"| node_institutiondash
node_institutiondash -->|"requests institution data"| node_institutionclient
node_institutionclient -->|"sends requests"| node_apiclient
node_apiclient -->|"calls API"| node_backend
node_backend -->|"dispatches routes"| node_routers
node_routers -->|"verifies sessions"| node_authverify
node_apiclient -->|"gets access token"| node_authprovider
node_authverify -->|"validates token"| node_authprovider
node_routers -->|"reads and writes"| node_supabaseadmin
node_supabaseadmin -->|"accesses data"| node_supabase
node_leaderboard -.->|"subscribes to changes"| node_supabase

click node_app "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/App.jsx"
click node_authcontext "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/context/AuthContext.jsx"
click node_landing "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/pages/Landing.jsx"
click node_mission "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/pages/MissionDetails.jsx"
click node_storyline "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/pages/Storyline.jsx"
click node_levelengine "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/components/storyline/LevelEngine.jsx"
click node_challenges "https://github.com/mradipatil770-cpu/cybersathi/tree/main/frontend/src/components/challenges"
click node_storydata "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/data/storylines.js"
click node_learningnotes "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/components/storyline/DocumentationViewer.jsx"
click node_dashboard "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/pages/Dashboard.jsx"
click node_progressclient "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/progress.js"
click node_scoring "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/scoring.js"
click node_rewards "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/db/achievementService.js"
click node_leaderboard "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/db/leaderboardService.js"
click node_institutiondash "https://github.com/mradipatil770-cpu/cybersathi/tree/main/frontend/src/pages/institution"
click node_institutionclient "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/db/institutionService.js"
click node_apiclient "https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/apiClient.js"
click node_backend "https://github.com/mradipatil770-cpu/cybersathi/blob/main/backend/app/main.py"
click node_routers "https://github.com/mradipatil770-cpu/cybersathi/tree/main/backend/app/routers"
click node_authverify "https://github.com/mradipatil770-cpu/cybersathi/blob/main/backend/app/auth.py"
click node_supabaseadmin "https://github.com/mradipatil770-cpu/cybersathi/blob/main/backend/app/supabase_admin.py"

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_landing,node_mission,node_storyline,node_levelengine,node_challenges,node_storydata,node_learningnotes toneBlue
class node_app,node_authcontext,node_supabase,node_gueststorage toneAmber
class node_dashboard,node_progressclient,node_scoring,node_rewards,node_leaderboard toneMint
class node_institutiondash,node_institutionclient toneRose
class node_apiclient,node_backend,node_routers,node_authverify,node_supabaseadmin,node_learner,node_authprovider toneIndigo
```

## Components

### Scenario learning

- [Scenario discovery](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/pages/Landing.jsx): `frontend/src/pages/Landing.jsx`
- [Scenario map](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/pages/MissionDetails.jsx): `frontend/src/pages/MissionDetails.jsx`
- [Scenario gameplay](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/pages/Storyline.jsx): `frontend/src/pages/Storyline.jsx`
- [Challenge selector](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/components/storyline/LevelEngine.jsx): `frontend/src/components/storyline/LevelEngine.jsx`
- [Challenge types](https://github.com/mradipatil770-cpu/cybersathi/tree/main/frontend/src/components/challenges): `frontend/src/components/challenges`
- [Scenario content](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/data/storylines.js): `frontend/src/data/storylines.js`
- [Learning notes](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/components/storyline/DocumentationViewer.jsx): `frontend/src/components/storyline/DocumentationViewer.jsx`

### Identity and access

- [React application](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth context](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`

### Player progress

- [Player dashboard](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Progress client](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/progress.js): `frontend/src/lib/progress.js`
- [Scoring logic](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/scoring.js): `frontend/src/lib/scoring.js`
- [Achievements and streaks](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/db/achievementService.js): `frontend/src/lib/db/achievementService.js`
- [Leaderboard](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/db/leaderboardService.js): `frontend/src/lib/db/leaderboardService.js`

### Institution management

- [Institution dashboards](https://github.com/mradipatil770-cpu/cybersathi/tree/main/frontend/src/pages/institution): `frontend/src/pages/institution`
- [Institution services](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/db/institutionService.js): `frontend/src/lib/db/institutionService.js`

### Backend services

- [API client](https://github.com/mradipatil770-cpu/cybersathi/blob/main/frontend/src/lib/apiClient.js): `frontend/src/lib/apiClient.js`
- [FastAPI application](https://github.com/mradipatil770-cpu/cybersathi/blob/main/backend/app/main.py): `backend/app/main.py`
- [API route modules](https://github.com/mradipatil770-cpu/cybersathi/tree/main/backend/app/routers): `backend/app/routers`
- [Session verification](https://github.com/mradipatil770-cpu/cybersathi/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Database access](https://github.com/mradipatil770-cpu/cybersathi/blob/main/backend/app/supabase_admin.py): `backend/app/supabase_admin.py`

### Other components

- **Learner**
- **Supabase Auth**
- **Supabase data services**
- **Browser progress storage**

## Connections

- Learner → React application: uses
- React application → Auth context: provides auth
- Auth context → Supabase Auth: signs in
- Auth context → API client: ensures profile
- Learner → Scenario discovery: discovers scenarios
- Scenario discovery → Scenario map: opens scenario
- Scenario map → Scenario gameplay: starts investigation
- Scenario gameplay → Scenario content: loads scenario
- Scenario gameplay → Challenge selector: renders level
- Challenge selector → Challenge types: selects challenge
- Scenario map → Learning notes: opens notes
- Scenario gameplay → Learning notes: opens notes
- Learner → Player dashboard: views progress
- Scenario gameplay → Progress client: saves progress
- Progress client → Browser progress storage: stores guest data
- Progress client → API client: syncs progress
- Scenario gameplay → Scoring logic: scores attempts
- Player dashboard → Achievements and streaks: loads rewards
- Player dashboard → Leaderboard: loads standings
- Learner → Institution dashboards: uses institution tools
- Institution dashboards → Institution services: requests institution data
- Institution services → API client: sends requests
- API client → FastAPI application: calls API
- FastAPI application → API route modules: dispatches routes
- API route modules → Session verification: verifies sessions
- API client → Supabase Auth: gets access token
- Session verification → Supabase Auth: validates token
- API route modules → Database access: reads and writes
- Database access → Supabase data services: accesses data
- Leaderboard → Supabase data services: subscribes to changes
