# kaviprince/anonymous-doubt-system architecture

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

- Interactive diagram: https://gitdiagram.com/kaviprince/anonymous-doubt-system
- Repository: https://github.com/kaviprince/anonymous-doubt-system

## Overview

This is a Firebase-backed anonymous classroom doubt portal. Students verify an account, create a profile, request access to a class, then post and follow anonymous doubts on its live board. Teachers create classes and approve requests; the Class Incharge links to a class and can investigate reported doubts. The board also supports replies, moderation, subject tagging, streaks, and edit/delete controls. The tree and sampled JavaScript support these flows; some documented features are represented at their enclosing page or script without assuming unsampled implementation details.

Main entry points: [`student.js`](https://github.com/kaviprince/anonymous-doubt-system/blob/main/student.js) (Student Account & Join), [`teacher.js`](https://github.com/kaviprince/anonymous-doubt-system/blob/main/teacher.js) (Teacher Account & Groups), [`incharge.js`](https://github.com/kaviprince/anonymous-doubt-system/blob/main/incharge.js) (Incharge Account & Linking), [`group.js`](https://github.com/kaviprince/anonymous-doubt-system/blob/main/group.js) (Live Doubt Board)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_accounts["Accounts &amp; Roles"]
  node_student_portal["Student Portal<br/>[student.html]"]
  node_student_logic["Student Account &amp; Join<br/>[student.js]"]
  node_teacher_portal["Teacher Portal<br/>[teacher.html]"]
  node_teacher_logic["Teacher Account &amp; Groups<br/>[teacher.js]"]
  node_incharge_portal["Incharge Portal<br/>[incharge.html]"]
  node_incharge_logic["Incharge Account &amp; Linking<br/>[incharge.js]"]
end

subgraph group_classes["Class Access"]
  node_join_flow["Join Requests &amp; Roster<br/>[group.js]"]
end

subgraph group_doubts["Doubt Board"]
  node_live_board["Live Doubt Board<br/>[group.js]"]
  node_moderation["Text Moderation<br/>[moderation.js]"]
  node_classification["Subject Classification<br/>[classify.js]"]
end

subgraph group_services["Platform Services"]
  node_auth{{"Firebase Authentication"}}
  node_firestore_init["Firebase Client Setup<br/>[firebase-config.js]"]
  node_firestore[("Firestore")]
  node_gemini{{"Google Gemini API"}}
  node_perspective{{"Perspective API"}}
end

node_student(("Student"))
node_teacher(("Teacher"))
node_incharge(("Class Incharge"))

node_student -->|"uses"| node_student_portal
node_teacher -->|"uses"| node_teacher_portal
node_incharge -->|"uses"| node_incharge_portal
node_student_portal -->|"runs"| node_student_logic
node_teacher_portal -->|"runs"| node_teacher_logic
node_incharge_portal -->|"runs"| node_incharge_logic
node_student_logic -->|"authenticates"| node_auth
node_teacher_logic -->|"authenticates"| node_auth
node_incharge_logic -->|"authenticates"| node_auth
node_firestore_init -->|"initializes"| node_firestore
node_student_logic -->|"reads/writes"| node_firestore
node_teacher_logic -->|"reads/writes"| node_firestore
node_incharge_logic -->|"reads/writes"| node_firestore
node_student_logic -->|"opens class board"| node_join_flow
node_teacher_logic -->|"opens requests"| node_join_flow
node_incharge_logic -->|"opens linked class"| node_live_board
node_join_flow -->|"reads/updates requests"| node_firestore
node_live_board -->|"listens/updates doubts"| node_firestore
node_live_board -->|"checks text"| node_moderation
node_live_board -->|"classifies doubt"| node_classification
node_classification -.->|"requests subject"| node_gemini
node_moderation -.->|"checks toxicity"| node_perspective

click node_student_portal "https://github.com/kaviprince/anonymous-doubt-system/blob/main/student.html"
click node_student_logic "https://github.com/kaviprince/anonymous-doubt-system/blob/main/student.js"
click node_teacher_portal "https://github.com/kaviprince/anonymous-doubt-system/blob/main/teacher.html"
click node_teacher_logic "https://github.com/kaviprince/anonymous-doubt-system/blob/main/teacher.js"
click node_incharge_portal "https://github.com/kaviprince/anonymous-doubt-system/blob/main/incharge.html"
click node_incharge_logic "https://github.com/kaviprince/anonymous-doubt-system/blob/main/incharge.js"
click node_join_flow "https://github.com/kaviprince/anonymous-doubt-system/blob/main/group.js"
click node_live_board "https://github.com/kaviprince/anonymous-doubt-system/blob/main/group.js"
click node_moderation "https://github.com/kaviprince/anonymous-doubt-system/blob/main/moderation.js"
click node_classification "https://github.com/kaviprince/anonymous-doubt-system/blob/main/classify.js"
click node_firestore_init "https://github.com/kaviprince/anonymous-doubt-system/blob/main/firebase-config.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_student_portal,node_student_logic,node_teacher_portal,node_teacher_logic,node_incharge_portal,node_incharge_logic toneBlue
class node_join_flow toneAmber
class node_live_board,node_moderation,node_classification toneMint
class node_auth,node_firestore_init,node_firestore,node_gemini,node_perspective toneRose
class node_student,node_teacher,node_incharge toneIndigo
```

## Components

### Accounts & Roles

- [Student Portal](https://github.com/kaviprince/anonymous-doubt-system/blob/main/student.html): `student.html`
- [Student Account & Join](https://github.com/kaviprince/anonymous-doubt-system/blob/main/student.js): `student.js`
- [Teacher Portal](https://github.com/kaviprince/anonymous-doubt-system/blob/main/teacher.html): `teacher.html`
- [Teacher Account & Groups](https://github.com/kaviprince/anonymous-doubt-system/blob/main/teacher.js): `teacher.js`
- [Incharge Portal](https://github.com/kaviprince/anonymous-doubt-system/blob/main/incharge.html): `incharge.html`
- [Incharge Account & Linking](https://github.com/kaviprince/anonymous-doubt-system/blob/main/incharge.js): `incharge.js`

### Class Access

- [Join Requests & Roster](https://github.com/kaviprince/anonymous-doubt-system/blob/main/group.js): `group.js`

### Doubt Board

- [Live Doubt Board](https://github.com/kaviprince/anonymous-doubt-system/blob/main/group.js): `group.js`
- [Text Moderation](https://github.com/kaviprince/anonymous-doubt-system/blob/main/moderation.js): `moderation.js`
- [Subject Classification](https://github.com/kaviprince/anonymous-doubt-system/blob/main/classify.js): `classify.js`

### Platform Services

- **Firebase Authentication**
- [Firebase Client Setup](https://github.com/kaviprince/anonymous-doubt-system/blob/main/firebase-config.js): `firebase-config.js`
- **Firestore**
- **Google Gemini API**
- **Perspective API**

### Other components

- **Student**
- **Teacher**
- **Class Incharge**

## Connections

- Student → Student Portal: uses
- Teacher → Teacher Portal: uses
- Class Incharge → Incharge Portal: uses
- Student Portal → Student Account & Join: runs
- Teacher Portal → Teacher Account & Groups: runs
- Incharge Portal → Incharge Account & Linking: runs
- Student Account & Join → Firebase Authentication: authenticates
- Teacher Account & Groups → Firebase Authentication: authenticates
- Incharge Account & Linking → Firebase Authentication: authenticates
- Firebase Client Setup → Firestore: initializes
- Student Account & Join → Firestore: reads/writes
- Teacher Account & Groups → Firestore: reads/writes
- Incharge Account & Linking → Firestore: reads/writes
- Student Account & Join → Join Requests & Roster: opens class board
- Teacher Account & Groups → Join Requests & Roster: opens requests
- Incharge Account & Linking → Live Doubt Board: opens linked class
- Join Requests & Roster → Firestore: reads/updates requests
- Live Doubt Board → Firestore: listens/updates doubts
- Live Doubt Board → Text Moderation: checks text
- Live Doubt Board → Subject Classification: classifies doubt
- Subject Classification → Google Gemini API: requests subject
- Text Moderation → Perspective API: checks toxicity
