# sarraayed1809-max/ai-study-buddy-v1 architecture

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

- Interactive diagram: https://gitdiagram.com/sarraayed1809-max/ai-study-buddy-v1
- Repository: https://github.com/sarraayed1809-max/ai-study-buddy-v1

## Overview

StudyBuddy AI is a signed-in study companion: learners use a focus timer and study tools, build AI-generated plans and quizzes, and earn progress for a customizable virtual pet. The React app also provides a pet shop, streaks, and study history; account data is synchronized through Firebase, while AI generation is served by the Express backend using Gemini with fallback content. The principal UI responsibilities mostly live together in `src/App.tsx`. The excerpts do not show its API request code, so those backend links are marked unverified.

Main entry points: [`src/App.tsx`](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx) (Study dashboard), [`src/contexts/AuthContext.tsx`](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/contexts/AuthContext.tsx) (Authentication), [`src/hooks/useCloudSync.ts`](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/hooks/useCloudSync.ts) (Cloud synchronization), [`server.ts`](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/server.ts) (Study API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Study experience"]
  node_app["Study dashboard<br/>[App.tsx]"]
  node_focus["Focus timer<br/>[App.tsx]"]
  node_planner["AI study planner<br/>[App.tsx]"]
  node_quiz["Quiz workflow<br/>[App.tsx]"]
  node_pet["Pet progression<br/>[App.tsx]"]
  node_shop["Pet shop<br/>[App.tsx]"]
  node_petvisual["Pet renderer<br/>[PetVisual.tsx]"]
  node_types["Study data types<br/>[types.ts]"]
end

subgraph group_identity["Identity and data"]
  node_login["Sign-in form<br/>[Login.tsx]"]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
  node_firebase["Firebase setup<br/>[firebase.ts]"]
  node_cloudsync["Cloud synchronization<br/>[useCloudSync.ts]"]
  node_firestore[("Firestore")]
  node_browserstorage[("Browser local storage")]
end

subgraph group_ai["AI services"]
  node_api["Study API<br/>[server.ts]"]
  node_planapi["Plan generation<br/>[server.ts]"]
  node_quizapi["Quiz generation<br/>[server.ts]"]
  node_gemini["Gemini"]
end

subgraph group_presentation["App presentation"]
  node_entry["React entry<br/>[main.tsx]"]
end

node_learner(("Learner"))

node_learner -->|"opens app"| node_entry
node_entry -->|"renders"| node_app
node_entry -->|"provides context"| node_auth
node_app -->|"presents"| node_focus
node_app -->|"presents"| node_planner
node_app -->|"presents"| node_quiz
node_app -->|"manages"| node_pet
node_app -->|"presents"| node_shop
node_app -->|"renders"| node_petvisual
node_app -->|"renders"| node_login
node_login -->|"calls sign-in"| node_auth
node_auth -->|"uses services"| node_firebase
node_app -->|"uses sync hooks"| node_cloudsync
node_cloudsync -->|"uses database"| node_firebase
node_cloudsync -->|"loads and saves"| node_firestore
node_auth -.->|"uses Firebase services"| node_firestore
node_app -->|"writes user data"| node_firestore
node_app -->|"reads and writes"| node_browserstorage
node_app -.->|"requests AI results"| node_api
node_api -->|"routes plan requests"| node_planapi
node_api -->|"routes quiz requests"| node_quizapi
node_planapi -->|"generates plan"| node_gemini
node_quizapi -->|"generates quiz"| node_gemini
node_app -->|"uses data shapes"| node_types
node_petvisual -->|"uses pet type"| node_types

click node_entry "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/main.tsx"
click node_app "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx"
click node_focus "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx"
click node_planner "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx"
click node_quiz "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx"
click node_pet "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx"
click node_shop "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx"
click node_petvisual "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/components/PetVisual.tsx"
click node_login "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/components/Login.tsx"
click node_auth "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/contexts/AuthContext.tsx"
click node_firebase "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/firebase.ts"
click node_cloudsync "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/hooks/useCloudSync.ts"
click node_api "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/server.ts"
click node_planapi "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/server.ts"
click node_quizapi "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/server.ts"
click node_types "https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/types.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_app,node_focus,node_planner,node_quiz,node_pet,node_shop,node_petvisual,node_types toneBlue
class node_login,node_auth,node_firebase,node_cloudsync,node_firestore,node_browserstorage toneAmber
class node_api,node_planapi,node_quizapi,node_gemini toneMint
class node_entry toneRose
class node_learner toneIndigo
```

## Components

### Study experience

- [Study dashboard](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx): `src/App.tsx`
- [Focus timer](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx): `src/App.tsx`
- [AI study planner](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx): `src/App.tsx`
- [Quiz workflow](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx): `src/App.tsx`
- [Pet progression](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx): `src/App.tsx`
- [Pet shop](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/App.tsx): `src/App.tsx`
- [Pet renderer](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/components/PetVisual.tsx): `src/components/PetVisual.tsx`
- [Study data types](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/types.ts): `src/types.ts`

### Identity and data

- [Sign-in form](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/components/Login.tsx): `src/components/Login.tsx`
- [Authentication](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/contexts/AuthContext.tsx): `src/contexts/AuthContext.tsx`
- [Firebase setup](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/firebase.ts): `src/firebase.ts`
- [Cloud synchronization](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/hooks/useCloudSync.ts): `src/hooks/useCloudSync.ts`
- **Firestore**
- **Browser local storage**

### AI services

- [Study API](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/server.ts): `server.ts`
- [Plan generation](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/server.ts): `server.ts`
- [Quiz generation](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/server.ts): `server.ts`
- **Gemini**

### App presentation

- [React entry](https://github.com/sarraayed1809-max/ai-study-buddy-v1/blob/main/src/main.tsx): `src/main.tsx`

### Other components

- **Learner**

## Connections

- Learner → React entry: opens app
- React entry → Study dashboard: renders (evidence: `src/main.tsx`)
- React entry → Authentication: provides context (evidence: `src/main.tsx`)
- Study dashboard → Focus timer: presents (evidence: `src/App.tsx`)
- Study dashboard → AI study planner: presents (evidence: `src/App.tsx`)
- Study dashboard → Quiz workflow: presents (evidence: `src/App.tsx`)
- Study dashboard → Pet progression: manages (evidence: `src/App.tsx`)
- Study dashboard → Pet shop: presents (evidence: `src/App.tsx`)
- Study dashboard → Pet renderer: renders (evidence: `src/App.tsx`)
- Study dashboard → Sign-in form: renders (evidence: `src/App.tsx`)
- Sign-in form → Authentication: calls sign-in (evidence: `src/components/Login.tsx`)
- Authentication → Firebase setup: uses services (evidence: `src/contexts/AuthContext.tsx`)
- Study dashboard → Cloud synchronization: uses sync hooks (evidence: `src/App.tsx`)
- Cloud synchronization → Firebase setup: uses database (evidence: `src/hooks/useCloudSync.ts`)
- Cloud synchronization → Firestore: loads and saves (evidence: `src/hooks/useCloudSync.ts`)
- Authentication → Firestore: uses Firebase services
- Study dashboard → Firestore: writes user data (evidence: `src/App.tsx`)
- Study dashboard → Browser local storage: reads and writes (evidence: `src/App.tsx`)
- Study dashboard → Study API: requests AI results
- Study API → Plan generation: routes plan requests (evidence: `server.ts`)
- Study API → Quiz generation: routes quiz requests (evidence: `server.ts`)
- Plan generation → Gemini: generates plan (evidence: `server.ts`)
- Quiz generation → Gemini: generates quiz (evidence: `server.ts`)
- Study dashboard → Study data types: uses data shapes (evidence: `src/App.tsx`)
- Pet renderer → Study data types: uses pet type (evidence: `src/components/PetVisual.tsx`)
