# vishakhahegde/brainnuggets architecture

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

- Interactive diagram: https://gitdiagram.com/vishakhahegde/brainnuggets
- Repository: https://github.com/vishakhahegde/brainnuggets

## Overview

Brain Nuggets turns lecture PDFs into bite-sized study material and assignments into scheduled, manageable tasks. Students sign in, upload or describe their work, then study chunks or complete a daily task plan. The browser coordinates these flows, calls the Express/Gemini service for AI processing, and persists user data through Firebase. README documentation establishes the server endpoints, streaming and figure workflow; some implementation details for unsampled components are therefore represented only at the documented level.

Main entry points: [`brain-nuggets/src/App.jsx`](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/App.jsx) (App routing), [`brain-nuggets/src/components/Study.jsx`](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/Study.jsx) (Chunk study), [`brain-nuggets/src/data.js`](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/data.js) (Data selector), [`brain-nuggets/src/components/Library.jsx`](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/Library.jsx) (Lecture library)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Student app"]
  node_app["App routing<br/>[App.jsx]"]
  node_signin["Google sign-in<br/>[SignIn.jsx]"]
  node_comfort["Comfort controls<br/>[ComfortPanel.jsx]"]
end

subgraph group_lecture["Lecture learning"]
  node_library["Lecture library<br/>[Library.jsx]"]
  node_study["Chunk study<br/>[Study.jsx]"]
  node_simple["Simple view<br/>[SimpleView.jsx]"]
  node_original["Original text<br/>[OriginalView.jsx]"]
  node_mindmap["Mind map<br/>[MindMap.jsx]"]
  node_quiz["Chunk quiz<br/>[Quiz.jsx]"]
  node_ask["Chunk questions<br/>[AskBox.jsx]"]
  node_figures["Figure cropping<br/>[figures.js]"]
  node_figurecard["Figure display<br/>[FigureCard.jsx]"]
end

subgraph group_assignments["Assignment planning"]
  node_assignments["Assignment intake<br/>[Assignments.jsx]"]
  node_work["Task workspace<br/>[AssignmentWork.jsx]"]
  node_schedule["Daily schedule<br/>[schedule.js]"]
end

subgraph group_services["AI and persistence"]
  node_api["Browser API<br/>[api.js]"]
  node_lectureproc["Lecture processing<br/>[index.js]"]
  node_gemini["Gemini prompts<br/>[gemini.js]"]
  node_breakdown["Task breakdown<br/>[index.js]"]
  node_data["Data selector<br/>[data.js]"]
  node_firestore["Firestore adapter<br/>[data-firestore.js]"]
  node_localdata["Local data adapter<br/>[data-local.js]"]
  node_firebase["Firebase auth<br/>[firebase.js]"]
end

node_student(("Student"))
node_googleai{{"Google Gemini"}}
node_firestoredb[("Cloud Firestore")]

node_student -->|"signs in"| node_signin
node_app -->|"watches user"| node_firebase
node_app -->|"routes signed-out"| node_signin
node_app -->|"routes lectures"| node_library
node_app -->|"routes chunks"| node_study
node_app -->|"routes assignments"| node_assignments
node_app -->|"routes task"| node_work
node_app -->|"opens panel"| node_comfort
node_library -->|"uploads PDF"| node_api
node_api -->|"streams events"| node_lectureproc
node_lectureproc -->|"uses prompts"| node_gemini
node_gemini -->|"generates chunks"| node_googleai
node_library -->|"crops PDF figures"| node_figures
node_library -->|"saves lecture"| node_data
node_study -->|"renders view"| node_simple
node_study -->|"renders view"| node_original
node_study -->|"renders map"| node_mindmap
node_study -->|"renders quiz"| node_quiz
node_study -->|"renders questions"| node_ask
node_study -->|"reads and updates"| node_data
node_figurecard -->|"loads figure"| node_data
node_original -->|"displays figures"| node_figurecard
node_student -->|"submits brief"| node_assignments
node_assignments -->|"requests breakdown"| node_api
node_api -->|"sends brief"| node_breakdown
node_breakdown -.->|"requests tasks"| node_gemini
node_assignments -->|"saves assignment"| node_data
node_work -->|"reads and patches"| node_data
node_work -->|"plans daily tasks"| node_schedule
node_data -->|"selects default"| node_firestore
node_data -->|"selects local mode"| node_localdata
node_firestore -->|"uses Firestore SDK"| node_firebase
node_firestore -->|"reads and writes"| node_firestoredb
node_student -.->|"asks questions"| node_googleai

click node_app "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/App.jsx"
click node_signin "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/SignIn.jsx"
click node_comfort "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/ComfortPanel.jsx"
click node_library "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/Library.jsx"
click node_api "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/api.js"
click node_lectureproc "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/server/index.js"
click node_gemini "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/server/gemini.js"
click node_study "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/Study.jsx"
click node_simple "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/SimpleView.jsx"
click node_original "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/OriginalView.jsx"
click node_mindmap "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/MindMap.jsx"
click node_quiz "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/Quiz.jsx"
click node_ask "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/AskBox.jsx"
click node_figures "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/figures.js"
click node_figurecard "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/FigureCard.jsx"
click node_assignments "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/Assignments.jsx"
click node_breakdown "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/server/index.js"
click node_work "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/AssignmentWork.jsx"
click node_schedule "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/schedule.js"
click node_data "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/data.js"
click node_firestore "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/data-firestore.js"
click node_localdata "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/data-local.js"
click node_firebase "https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/firebase.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_signin,node_comfort toneBlue
class node_library,node_study,node_simple,node_original,node_mindmap,node_quiz,node_ask,node_figures,node_figurecard,node_firestoredb toneAmber
class node_assignments,node_work,node_schedule toneMint
class node_api,node_lectureproc,node_gemini,node_breakdown,node_data,node_firestore,node_localdata,node_firebase toneRose
class node_student,node_googleai toneIndigo
```

## Components

### Student app

- [App routing](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/App.jsx): `brain-nuggets/src/App.jsx`
- [Google sign-in](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/SignIn.jsx): `brain-nuggets/src/components/SignIn.jsx`
- [Comfort controls](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/ComfortPanel.jsx): `brain-nuggets/src/components/ComfortPanel.jsx`

### Lecture learning

- [Lecture library](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/Library.jsx): `brain-nuggets/src/components/Library.jsx`
- [Chunk study](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/Study.jsx): `brain-nuggets/src/components/Study.jsx`
- [Simple view](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/SimpleView.jsx): `brain-nuggets/src/components/SimpleView.jsx`
- [Original text](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/OriginalView.jsx): `brain-nuggets/src/components/OriginalView.jsx`
- [Mind map](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/MindMap.jsx): `brain-nuggets/src/components/MindMap.jsx`
- [Chunk quiz](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/Quiz.jsx): `brain-nuggets/src/components/Quiz.jsx`
- [Chunk questions](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/AskBox.jsx): `brain-nuggets/src/components/AskBox.jsx`
- [Figure cropping](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/figures.js): `brain-nuggets/src/figures.js`
- [Figure display](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/FigureCard.jsx): `brain-nuggets/src/components/FigureCard.jsx`

### Assignment planning

- [Assignment intake](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/Assignments.jsx): `brain-nuggets/src/components/Assignments.jsx`
- [Task workspace](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/components/AssignmentWork.jsx): `brain-nuggets/src/components/AssignmentWork.jsx`
- [Daily schedule](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/schedule.js): `brain-nuggets/src/schedule.js`

### AI and persistence

- [Browser API](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/api.js): `brain-nuggets/src/api.js`
- [Lecture processing](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/server/index.js): `brain-nuggets/server/index.js`
- [Gemini prompts](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/server/gemini.js): `brain-nuggets/server/gemini.js`
- [Task breakdown](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/server/index.js): `brain-nuggets/server/index.js`
- [Data selector](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/data.js): `brain-nuggets/src/data.js`
- [Firestore adapter](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/data-firestore.js): `brain-nuggets/src/data-firestore.js`
- [Local data adapter](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/data-local.js): `brain-nuggets/src/data-local.js`
- [Firebase auth](https://github.com/vishakhahegde/brainnuggets/blob/main/brain-nuggets/src/firebase.js): `brain-nuggets/src/firebase.js`

### Other components

- **Student**
- **Google Gemini**
- **Cloud Firestore**

## Connections

- Student → Google sign-in: signs in (evidence: `brain-nuggets/src/components/SignIn.jsx`)
- App routing → Firebase auth: watches user (evidence: `brain-nuggets/src/App.jsx`)
- App routing → Google sign-in: routes signed-out (evidence: `brain-nuggets/src/App.jsx`)
- App routing → Lecture library: routes lectures (evidence: `brain-nuggets/src/App.jsx`)
- App routing → Chunk study: routes chunks (evidence: `brain-nuggets/src/App.jsx`)
- App routing → Assignment intake: routes assignments (evidence: `brain-nuggets/src/App.jsx`)
- App routing → Task workspace: routes task (evidence: `brain-nuggets/src/App.jsx`)
- App routing → Comfort controls: opens panel (evidence: `brain-nuggets/src/App.jsx`)
- Lecture library → Browser API: uploads PDF (evidence: `brain-nuggets/src/components/Library.jsx`)
- Browser API → Lecture processing: streams events (evidence: `README.md`)
- Lecture processing → Gemini prompts: uses prompts (evidence: `brain-nuggets/server/index.js`)
- Gemini prompts → Google Gemini: generates chunks (evidence: `README.md`)
- Lecture library → Figure cropping: crops PDF figures (evidence: `brain-nuggets/src/components/Library.jsx`)
- Lecture library → Data selector: saves lecture (evidence: `brain-nuggets/src/components/Library.jsx`)
- Chunk study → Simple view: renders view (evidence: `brain-nuggets/src/components/Study.jsx`)
- Chunk study → Original text: renders view (evidence: `brain-nuggets/src/components/Study.jsx`)
- Chunk study → Mind map: renders map (evidence: `brain-nuggets/src/components/Study.jsx`)
- Chunk study → Chunk quiz: renders quiz (evidence: `brain-nuggets/src/components/Study.jsx`)
- Chunk study → Chunk questions: renders questions (evidence: `brain-nuggets/src/components/Study.jsx`)
- Chunk study → Data selector: reads and updates (evidence: `brain-nuggets/src/components/Study.jsx`)
- Figure display → Data selector: loads figure (evidence: `brain-nuggets/src/components/FigureCard.jsx`)
- Original text → Figure display: displays figures (evidence: `brain-nuggets/src/components/OriginalView.jsx`)
- Student → Assignment intake: submits brief (evidence: `brain-nuggets/src/components/Assignments.jsx`)
- Assignment intake → Browser API: requests breakdown (evidence: `brain-nuggets/src/components/Assignments.jsx`)
- Browser API → Task breakdown: sends brief (evidence: `README.md`)
- Task breakdown → Gemini prompts: requests tasks (evidence: `brain-nuggets/server/index.js`)
- Assignment intake → Data selector: saves assignment (evidence: `brain-nuggets/src/components/Assignments.jsx`)
- Task workspace → Data selector: reads and patches (evidence: `brain-nuggets/src/components/AssignmentWork.jsx`)
- Task workspace → Daily schedule: plans daily tasks (evidence: `brain-nuggets/src/components/AssignmentWork.jsx`)
- Data selector → Firestore adapter: selects default (evidence: `brain-nuggets/src/data.js`)
- Data selector → Local data adapter: selects local mode (evidence: `brain-nuggets/src/data.js`)
- Firestore adapter → Firebase auth: uses Firestore SDK (evidence: `brain-nuggets/src/data-firestore.js`)
- Firestore adapter → Cloud Firestore: reads and writes (evidence: `README.md`)
- Student → Google Gemini: asks questions
