# amanrcy1/mocktest-app architecture

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

- Interactive diagram: https://gitdiagram.com/amanrcy1/mocktest-app
- Repository: https://github.com/amanrcy1/mocktest-app

## Overview

Mockzam is a UPSC mock-test and study platform. The main user journey is sign-in and onboarding, choosing a test mode and exam, taking a timed test with integrity controls, then reviewing performance; dashboards and leaderboards extend that journey. The graph includes the documented AI, administration, bookmark, and PWA branches. Some README-listed test pages are absent from the supplied tree, and many subsystem sources were not excerpted, so uncertain implementation links are omitted. Cross-service AI routing is shown only where documented.

Main entry points: [`src/App.js`](https://github.com/amanrcy1/mocktest-app/blob/main/src/App.js) (Route shell), [`src/config/firebase.js`](https://github.com/amanrcy1/mocktest-app/blob/main/src/config/firebase.js) (Firebase client), [`src/pages/user/Dashboard.js`](https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/user/Dashboard.js) (User dashboard), [`src/context/AuthContext.js`](https://github.com/amanrcy1/mocktest-app/blob/main/src/context/AuthContext.js) (Auth context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_app["Route shell<br/>[App.js]"]
  node_landing["Landing and demo<br/>[Landing.js]"]
  node_chatwidget["AI chat widget<br/>[AiChatWidget.js]"]
  node_install["Install banner<br/>[InstallBanner.js]"]
  node_pwa["PWA install hook<br/>[usePWAInstall.js]"]
end

subgraph group_identity["Identity and setup"]
  node_authpage["Sign-in<br/>[Auth.js]"]
  node_auth["Auth context<br/>[AuthContext.js]"]
  node_onboarding["Onboarding<br/>[Onboarding.js]"]
end

subgraph group_testing["Test and learning"]
  node_patterns["Exam patterns<br/>[examPatterns.js]"]
  node_testservices["Test services<br/>[testService.js]"]
  node_questions["Question service<br/>[questionService.js]"]
  node_teststate["Test state<br/>[useTestState.js]"]
  node_session["Session persistence<br/>[useTestSession.js]"]
  node_timer["Test timer<br/>[useTimer.js]"]
  node_integrity["Anti-cheat<br/>[useAntiCheat.js]"]
end

subgraph group_insights["Progress and admin"]
  node_dashboard["User dashboard<br/>[Dashboard.js]"]
  node_leaderboard["Leaderboard<br/>[Leaderboard.js]"]
  node_profile["Profile<br/>[Profile.js]"]
  node_admin["Admin management<br/>[ManageQuestions.js]"]
  node_adminusers["User administration<br/>[Users.js]"]
  node_bookmarks["Bookmark service<br/>[bookmarkService.js]"]
end

subgraph group_platform["Services and platform"]
  node_firebase["Firebase client<br/>[firebase.js]"]
  node_chatservice["Chat service<br/>[chatService.js]"]
  node_aiservice["AI explanations<br/>[aiService.js]"]
  node_chatapi["Chat endpoint<br/>[ai-chat.js]"]
  node_explainapi["Explanation endpoint<br/>[ai-explanation.js]"]
  node_groq["Groq LLM"]
  node_firestore[("Cloud Firestore")]
  node_storage[("Firebase Storage")]
end

node_aspirant(("Aspirant"))

node_aspirant -->|"opens"| node_app
node_app -->|"routes to"| node_authpage
node_authpage -->|"signs in"| node_auth
node_auth -->|"uses auth"| node_firebase
node_auth -->|"reads and writes"| node_firestore
node_app -->|"routes to"| node_onboarding
node_onboarding -->|"uses exam choices"| node_patterns
node_aspirant -->|"browses"| node_landing
node_app -.->|"routes to"| node_landing
node_app -->|"routes to"| node_dashboard
node_dashboard -->|"reads results"| node_firestore
node_dashboard -.->|"shows resumable session"| node_session
node_app -.->|"routes test workflow"| node_testservices
node_testservices -->|"uses Firebase"| node_firebase
node_testservices -.->|"reads and writes"| node_firestore
node_questions -->|"uses Firebase"| node_firebase
node_questions -.->|"reads questions"| node_firestore
node_teststate -.->|"persists session"| node_session
node_timer -.->|"tracks test time"| node_teststate
node_integrity -.->|"guards test"| node_teststate
node_dashboard -.->|"offers rankings"| node_leaderboard
node_dashboard -.->|"links profile"| node_profile
node_admin -->|"uses Firebase"| node_firebase
node_admin -.->|"manages questions"| node_firestore
node_app -->|"routes admin"| node_admin
node_app -->|"routes admin"| node_adminusers
node_bookmarks -.->|"stores bookmarks"| node_firestore
node_chatwidget -->|"sends messages"| node_chatservice
node_chatservice -.->|"requests chat"| node_chatapi
node_aiservice -->|"requests explanation"| node_explainapi
node_chatapi -->|"requests inference"| node_groq
node_explainapi -->|"requests inference"| node_groq
node_chatapi -->|"verifies token"| node_firebase
node_explainapi -->|"verifies token"| node_firebase
node_app -->|"shows install prompt"| node_install
node_install -->|"uses install hook"| node_pwa

click node_app "https://github.com/amanrcy1/mocktest-app/blob/main/src/App.js"
click node_authpage "https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/auth/Auth.js"
click node_auth "https://github.com/amanrcy1/mocktest-app/blob/main/src/context/AuthContext.js"
click node_firebase "https://github.com/amanrcy1/mocktest-app/blob/main/src/config/firebase.js"
click node_onboarding "https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/Onboarding.js"
click node_patterns "https://github.com/amanrcy1/mocktest-app/blob/main/src/utils/examPatterns.js"
click node_landing "https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/Landing.js"
click node_testservices "https://github.com/amanrcy1/mocktest-app/blob/main/src/services/testService.js"
click node_questions "https://github.com/amanrcy1/mocktest-app/blob/main/src/services/questionService.js"
click node_teststate "https://github.com/amanrcy1/mocktest-app/blob/main/src/hooks/useTestState.js"
click node_session "https://github.com/amanrcy1/mocktest-app/blob/main/src/hooks/useTestSession.js"
click node_timer "https://github.com/amanrcy1/mocktest-app/blob/main/src/hooks/useTimer.js"
click node_integrity "https://github.com/amanrcy1/mocktest-app/blob/main/src/hooks/useAntiCheat.js"
click node_dashboard "https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/user/Dashboard.js"
click node_leaderboard "https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/user/Leaderboard.js"
click node_profile "https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/user/Profile.js"
click node_admin "https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/admin/ManageQuestions.js"
click node_adminusers "https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/admin/Users.js"
click node_bookmarks "https://github.com/amanrcy1/mocktest-app/blob/main/src/services/bookmarkService.js"
click node_chatwidget "https://github.com/amanrcy1/mocktest-app/blob/main/src/components/ui/AiChatWidget.js"
click node_chatservice "https://github.com/amanrcy1/mocktest-app/blob/main/src/services/chatService.js"
click node_aiservice "https://github.com/amanrcy1/mocktest-app/blob/main/src/services/aiService.js"
click node_chatapi "https://github.com/amanrcy1/mocktest-app/blob/main/api/ai-chat.js"
click node_explainapi "https://github.com/amanrcy1/mocktest-app/blob/main/api/ai-explanation.js"
click node_install "https://github.com/amanrcy1/mocktest-app/blob/main/src/components/ui/InstallBanner.js"
click node_pwa "https://github.com/amanrcy1/mocktest-app/blob/main/src/hooks/usePWAInstall.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_app,node_landing,node_chatwidget,node_install,node_pwa toneBlue
class node_authpage,node_auth,node_onboarding toneAmber
class node_patterns,node_testservices,node_questions,node_teststate,node_session,node_timer,node_integrity toneMint
class node_dashboard,node_leaderboard,node_profile,node_admin,node_adminusers,node_bookmarks toneRose
class node_firebase,node_chatservice,node_aiservice,node_chatapi,node_explainapi,node_groq,node_firestore,node_storage,node_aspirant toneIndigo
```

## Components

### App experience

- [Route shell](https://github.com/amanrcy1/mocktest-app/blob/main/src/App.js): `src/App.js`
- [Landing and demo](https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/Landing.js): `src/pages/Landing.js`
- [AI chat widget](https://github.com/amanrcy1/mocktest-app/blob/main/src/components/ui/AiChatWidget.js): `src/components/ui/AiChatWidget.js`
- [Install banner](https://github.com/amanrcy1/mocktest-app/blob/main/src/components/ui/InstallBanner.js): `src/components/ui/InstallBanner.js`
- [PWA install hook](https://github.com/amanrcy1/mocktest-app/blob/main/src/hooks/usePWAInstall.js): `src/hooks/usePWAInstall.js`

### Identity and setup

- [Sign-in](https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/auth/Auth.js): `src/pages/auth/Auth.js`
- [Auth context](https://github.com/amanrcy1/mocktest-app/blob/main/src/context/AuthContext.js): `src/context/AuthContext.js`
- [Onboarding](https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/Onboarding.js): `src/pages/Onboarding.js`

### Test and learning

- [Exam patterns](https://github.com/amanrcy1/mocktest-app/blob/main/src/utils/examPatterns.js): `src/utils/examPatterns.js`
- [Test services](https://github.com/amanrcy1/mocktest-app/blob/main/src/services/testService.js): `src/services/testService.js`
- [Question service](https://github.com/amanrcy1/mocktest-app/blob/main/src/services/questionService.js): `src/services/questionService.js`
- [Test state](https://github.com/amanrcy1/mocktest-app/blob/main/src/hooks/useTestState.js): `src/hooks/useTestState.js`
- [Session persistence](https://github.com/amanrcy1/mocktest-app/blob/main/src/hooks/useTestSession.js): `src/hooks/useTestSession.js`
- [Test timer](https://github.com/amanrcy1/mocktest-app/blob/main/src/hooks/useTimer.js): `src/hooks/useTimer.js`
- [Anti-cheat](https://github.com/amanrcy1/mocktest-app/blob/main/src/hooks/useAntiCheat.js): `src/hooks/useAntiCheat.js`

### Progress and admin

- [User dashboard](https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/user/Dashboard.js): `src/pages/user/Dashboard.js`
- [Leaderboard](https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/user/Leaderboard.js): `src/pages/user/Leaderboard.js`
- [Profile](https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/user/Profile.js): `src/pages/user/Profile.js`
- [Admin management](https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/admin/ManageQuestions.js): `src/pages/admin/ManageQuestions.js`
- [User administration](https://github.com/amanrcy1/mocktest-app/blob/main/src/pages/admin/Users.js): `src/pages/admin/Users.js`
- [Bookmark service](https://github.com/amanrcy1/mocktest-app/blob/main/src/services/bookmarkService.js): `src/services/bookmarkService.js`

### Services and platform

- [Firebase client](https://github.com/amanrcy1/mocktest-app/blob/main/src/config/firebase.js): `src/config/firebase.js`
- [Chat service](https://github.com/amanrcy1/mocktest-app/blob/main/src/services/chatService.js): `src/services/chatService.js`
- [AI explanations](https://github.com/amanrcy1/mocktest-app/blob/main/src/services/aiService.js): `src/services/aiService.js`
- [Chat endpoint](https://github.com/amanrcy1/mocktest-app/blob/main/api/ai-chat.js): `api/ai-chat.js`
- [Explanation endpoint](https://github.com/amanrcy1/mocktest-app/blob/main/api/ai-explanation.js): `api/ai-explanation.js`
- **Groq LLM**
- **Cloud Firestore**
- **Firebase Storage**

### Other components

- **Aspirant**

## Connections

- Aspirant → Route shell: opens (evidence: `README.md`)
- Route shell → Sign-in: routes to (evidence: `src/App.js`)
- Sign-in → Auth context: signs in (evidence: `src/pages/auth/Auth.js`)
- Auth context → Firebase client: uses auth (evidence: `src/context/AuthContext.js`)
- Auth context → Cloud Firestore: reads and writes (evidence: `src/context/AuthContext.js`)
- Route shell → Onboarding: routes to (evidence: `src/App.js`)
- Onboarding → Exam patterns: uses exam choices (evidence: `src/pages/Onboarding.js`)
- Aspirant → Landing and demo: browses (evidence: `README.md`)
- Route shell → Landing and demo: routes to (evidence: `src/App.js`)
- Route shell → User dashboard: routes to (evidence: `src/App.js`)
- User dashboard → Cloud Firestore: reads results (evidence: `src/pages/user/Dashboard.js`)
- User dashboard → Session persistence: shows resumable session
- Route shell → Test services: routes test workflow
- Test services → Firebase client: uses Firebase (evidence: `src/services/testService.js`)
- Test services → Cloud Firestore: reads and writes
- Question service → Firebase client: uses Firebase (evidence: `src/services/questionService.js`)
- Question service → Cloud Firestore: reads questions
- Test state → Session persistence: persists session
- Test timer → Test state: tracks test time
- Anti-cheat → Test state: guards test
- User dashboard → Leaderboard: offers rankings
- User dashboard → Profile: links profile
- Admin management → Firebase client: uses Firebase (evidence: `src/pages/admin/ManageQuestions.js`)
- Admin management → Cloud Firestore: manages questions
- Route shell → Admin management: routes admin (evidence: `src/App.js`)
- Route shell → User administration: routes admin (evidence: `src/App.js`)
- Bookmark service → Cloud Firestore: stores bookmarks
- AI chat widget → Chat service: sends messages (evidence: `src/components/ui/AiChatWidget.js`)
- Chat service → Chat endpoint: requests chat (evidence: `README.md`)
- AI explanations → Explanation endpoint: requests explanation (evidence: `src/services/aiService.js`)
- Chat endpoint → Groq LLM: requests inference (evidence: `README.md`)
- Explanation endpoint → Groq LLM: requests inference (evidence: `README.md`)
- Chat endpoint → Firebase client: verifies token (evidence: `README.md`)
- Explanation endpoint → Firebase client: verifies token (evidence: `README.md`)
- Route shell → Install banner: shows install prompt (evidence: `src/App.js`)
- Install banner → PWA install hook: uses install hook (evidence: `src/components/ui/InstallBanner.js`)
