# golfzaptw/anesthesia-form architecture

> Architecture diagram of the GitHub repository golfzaptw/anesthesia-form, 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/golfzaptw/anesthesia-form
- Repository: https://github.com/golfzaptw/anesthesia-form

## Overview

The platform supports anonymous, batch-aware satisfaction surveys for anesthesia-nursing students and an admin workflow for managing batches, schedules and form definitions, then reviewing and exporting results. The graph follows documented product capabilities and sampled calls; unsampled implementation details are represented only where the README/tree supports them.

Main entry points: [`lib/firestore.ts`](https://github.com/golfzaptw/anesthesia-form/blob/main/lib/firestore.ts) (Firestore operations), [`app/admin/page.tsx`](https://github.com/golfzaptw/anesthesia-form/blob/main/app/admin/page.tsx) (Admin dashboard), [`contexts/AuthContext.tsx`](https://github.com/golfzaptw/anesthesia-form/blob/main/contexts/AuthContext.tsx) (Auth context), [`app/hub/page.tsx`](https://github.com/golfzaptw/anesthesia-form/blob/main/app/hub/page.tsx) (Survey hub)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access &amp; Hub"]
  node_login["Login page<br/>[page.tsx]"]
  node_loginform["Login / guest form<br/>[LoginForm.tsx]"]
  node_auth["Auth context<br/>[AuthContext.tsx]"]
  node_hub["Survey hub<br/>[page.tsx]"]
end

subgraph group_surveys["Survey Workflow"]
  node_form1route["Form 1 route<br/>[page.tsx]"]
  node_form2route["Form 2 route<br/>[page.tsx]"]
  node_form3route["Form 3 route<br/>[page.tsx]"]
  node_form1["Teaching evaluation<br/>[Form1.tsx]"]
  node_form2["Faculty evaluation<br/>[Form2.tsx]"]
  node_form3["Staff evaluation<br/>[Form3.tsx]"]
  node_drafts["Draft autosave"]
end

subgraph group_data["Persistence"]
  node_firestorelib["Firestore operations<br/>[firestore.ts]"]
  node_mockstore[("Mock store<br/>[mockStore.ts]")]
end

subgraph group_admin["Administration &amp; Reporting"]
  node_adminpage["Admin dashboard<br/>[page.tsx]"]
  node_editor["Form and batch editor<br/>[FormEditor.tsx]"]
  node_analytics["Analytics calculations<br/>[analytics.ts]"]
  node_overview["Overview reporting<br/>[OverviewTab.tsx]"]
  node_csv["CSV export<br/>[csv.ts]"]
  node_pdf["PDF export<br/>[pdfExport.ts]"]
end

node_student(("Student"))
node_administrator(("Administrator"))
node_localstorage[("Browser local storage")]
node_firebase[("Firebase Auth / Firestore")]

node_student -->|"opens"| node_login
node_administrator -->|"opens"| node_login
node_login -->|"renders"| node_loginform
node_loginform -->|"signs in / registers"| node_auth
node_auth -->|"reads / creates profile"| node_firestorelib
node_auth -->|"authenticates"| node_firebase
node_auth -.->|"uses in mock mode"| node_mockstore
node_auth -->|"redirects after login"| node_hub
node_hub -->|"loads config and progress"| node_firestorelib
node_hub -->|"links to"| node_form1route
node_hub -->|"links to"| node_form2route
node_hub -->|"links to"| node_form3route
node_form1route -->|"renders"| node_form1
node_form2route -->|"renders"| node_form2
node_form3route -->|"renders"| node_form3
node_form1 -->|"submits response"| node_firestorelib
node_form2 -->|"submits response"| node_firestorelib
node_form3 -->|"submits response"| node_firestorelib
node_form2 -->|"autosaves draft"| node_drafts
node_drafts -->|"reads / writes"| node_localstorage
node_firestorelib -->|"reads / writes"| node_firebase
node_firestorelib -.->|"uses in mock mode"| node_mockstore
node_administrator -->|"opens"| node_adminpage
node_adminpage -->|"checks current user"| node_auth
node_adminpage -->|"loads results and manages batches"| node_firestorelib
node_adminpage -->|"renders editor"| node_editor
node_editor -->|"saves config"| node_firestorelib
node_adminpage -->|"calculates statistics"| node_analytics
node_adminpage -->|"renders reporting tab"| node_overview
node_overview -->|"exports reports"| node_csv
node_adminpage -->|"generates PDF report"| node_pdf

click node_login "https://github.com/golfzaptw/anesthesia-form/blob/main/app/login/page.tsx"
click node_loginform "https://github.com/golfzaptw/anesthesia-form/blob/main/components/auth/LoginForm.tsx"
click node_auth "https://github.com/golfzaptw/anesthesia-form/blob/main/contexts/AuthContext.tsx"
click node_hub "https://github.com/golfzaptw/anesthesia-form/blob/main/app/hub/page.tsx"
click node_form1route "https://github.com/golfzaptw/anesthesia-form/blob/main/app/forms/1/page.tsx"
click node_form2route "https://github.com/golfzaptw/anesthesia-form/blob/main/app/forms/2/page.tsx"
click node_form3route "https://github.com/golfzaptw/anesthesia-form/blob/main/app/forms/3/page.tsx"
click node_form1 "https://github.com/golfzaptw/anesthesia-form/blob/main/components/forms/Form1.tsx"
click node_form2 "https://github.com/golfzaptw/anesthesia-form/blob/main/components/forms/Form2.tsx"
click node_form3 "https://github.com/golfzaptw/anesthesia-form/blob/main/components/forms/Form3.tsx"
click node_drafts "https://github.com/golfzaptw/anesthesia-form/blob/main/lib/useDraftAutoSave.ts"
click node_firestorelib "https://github.com/golfzaptw/anesthesia-form/blob/main/lib/firestore.ts"
click node_mockstore "https://github.com/golfzaptw/anesthesia-form/blob/main/lib/mockStore.ts"
click node_adminpage "https://github.com/golfzaptw/anesthesia-form/blob/main/app/admin/page.tsx"
click node_editor "https://github.com/golfzaptw/anesthesia-form/blob/main/components/admin/FormEditor.tsx"
click node_analytics "https://github.com/golfzaptw/anesthesia-form/blob/main/lib/analytics.ts"
click node_overview "https://github.com/golfzaptw/anesthesia-form/blob/main/components/admin/tabs/OverviewTab.tsx"
click node_csv "https://github.com/golfzaptw/anesthesia-form/blob/main/lib/csv.ts"
click node_pdf "https://github.com/golfzaptw/anesthesia-form/blob/main/lib/pdfExport.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_login,node_loginform,node_auth,node_hub toneBlue
class node_form1route,node_form2route,node_form3route,node_form1,node_form2,node_form3,node_drafts,node_localstorage,node_firebase toneAmber
class node_firestorelib,node_mockstore toneMint
class node_adminpage,node_editor,node_analytics,node_overview,node_csv,node_pdf toneRose
class node_student,node_administrator toneIndigo
```

## Components

### Access & Hub

- [Login page](https://github.com/golfzaptw/anesthesia-form/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Login / guest form](https://github.com/golfzaptw/anesthesia-form/blob/main/components/auth/LoginForm.tsx): `components/auth/LoginForm.tsx`
- [Auth context](https://github.com/golfzaptw/anesthesia-form/blob/main/contexts/AuthContext.tsx): `contexts/AuthContext.tsx`
- [Survey hub](https://github.com/golfzaptw/anesthesia-form/blob/main/app/hub/page.tsx): `app/hub/page.tsx`

### Survey Workflow

- [Form 1 route](https://github.com/golfzaptw/anesthesia-form/blob/main/app/forms/1/page.tsx): `app/forms/1/page.tsx`
- [Form 2 route](https://github.com/golfzaptw/anesthesia-form/blob/main/app/forms/2/page.tsx): `app/forms/2/page.tsx`
- [Form 3 route](https://github.com/golfzaptw/anesthesia-form/blob/main/app/forms/3/page.tsx): `app/forms/3/page.tsx`
- [Teaching evaluation](https://github.com/golfzaptw/anesthesia-form/blob/main/components/forms/Form1.tsx): `components/forms/Form1.tsx`
- [Faculty evaluation](https://github.com/golfzaptw/anesthesia-form/blob/main/components/forms/Form2.tsx): `components/forms/Form2.tsx`
- [Staff evaluation](https://github.com/golfzaptw/anesthesia-form/blob/main/components/forms/Form3.tsx): `components/forms/Form3.tsx`
- [Draft autosave](https://github.com/golfzaptw/anesthesia-form/blob/main/lib/useDraftAutoSave.ts): `lib/useDraftAutoSave.ts`

### Persistence

- [Firestore operations](https://github.com/golfzaptw/anesthesia-form/blob/main/lib/firestore.ts): `lib/firestore.ts`
- [Mock store](https://github.com/golfzaptw/anesthesia-form/blob/main/lib/mockStore.ts): `lib/mockStore.ts`

### Administration & Reporting

- [Admin dashboard](https://github.com/golfzaptw/anesthesia-form/blob/main/app/admin/page.tsx): `app/admin/page.tsx`
- [Form and batch editor](https://github.com/golfzaptw/anesthesia-form/blob/main/components/admin/FormEditor.tsx): `components/admin/FormEditor.tsx`
- [Analytics calculations](https://github.com/golfzaptw/anesthesia-form/blob/main/lib/analytics.ts): `lib/analytics.ts`
- [Overview reporting](https://github.com/golfzaptw/anesthesia-form/blob/main/components/admin/tabs/OverviewTab.tsx): `components/admin/tabs/OverviewTab.tsx`
- [CSV export](https://github.com/golfzaptw/anesthesia-form/blob/main/lib/csv.ts): `lib/csv.ts`
- [PDF export](https://github.com/golfzaptw/anesthesia-form/blob/main/lib/pdfExport.ts): `lib/pdfExport.ts`

### Other components

- **Student**
- **Administrator**
- **Browser local storage**
- **Firebase Auth / Firestore**

## Connections

- Student → Login page: opens
- Administrator → Login page: opens
- Login page → Login / guest form: renders
- Login / guest form → Auth context: signs in / registers
- Auth context → Firestore operations: reads / creates profile
- Auth context → Firebase Auth / Firestore: authenticates
- Auth context → Mock store: uses in mock mode
- Auth context → Survey hub: redirects after login
- Survey hub → Firestore operations: loads config and progress
- Survey hub → Form 1 route: links to
- Survey hub → Form 2 route: links to
- Survey hub → Form 3 route: links to
- Form 1 route → Teaching evaluation: renders
- Form 2 route → Faculty evaluation: renders
- Form 3 route → Staff evaluation: renders
- Teaching evaluation → Firestore operations: submits response
- Faculty evaluation → Firestore operations: submits response
- Staff evaluation → Firestore operations: submits response
- Faculty evaluation → Draft autosave: autosaves draft
- Draft autosave → Browser local storage: reads / writes
- Firestore operations → Firebase Auth / Firestore: reads / writes
- Firestore operations → Mock store: uses in mock mode
- Administrator → Admin dashboard: opens
- Admin dashboard → Auth context: checks current user
- Admin dashboard → Firestore operations: loads results and manages batches
- Admin dashboard → Form and batch editor: renders editor
- Form and batch editor → Firestore operations: saves config
- Admin dashboard → Analytics calculations: calculates statistics
- Admin dashboard → Overview reporting: renders reporting tab
- Overview reporting → CSV export: exports reports
- Admin dashboard → PDF export: generates PDF report
