# kxm1908/wehack26 architecture

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

- Interactive diagram: https://gitdiagram.com/kxm1908/wehack26
- Repository: https://github.com/kxm1908/wehack26

## Overview

BackTrack turns patient memory-gallery visits into speech metrics and image-based observations, then presents session history and longitudinal summaries to clinicians. The main path runs from authentication and profile setup through a prompted recording, backend analysis, persistence, and clinician review. The excerpts show those routes and the analysis/storage calls; the clinician dashboard’s detailed data-fetch behavior was not shown, so its API relationship is documented by the README rather than asserted from source.

Main entry points: [`frontend/src/App.jsx`](https://github.com/kxm1908/wehack26/blob/main/frontend/src/App.jsx) (App routing), [`backend/src/index.js`](https://github.com/kxm1908/wehack26/blob/main/backend/src/index.js) (Express API), [`frontend/src/MemorySession.jsx`](https://github.com/kxm1908/wehack26/blob/main/frontend/src/MemorySession.jsx) (Memory session), [`frontend/src/AuthContext.jsx`](https://github.com/kxm1908/wehack26/blob/main/frontend/src/AuthContext.jsx) (Auth and profile)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient_ui["Patient experience"]
  node_app["App routing<br/>[App.jsx]"]
  node_landing["Museum entrance<br/>[Landing.jsx]"]
  node_onboarding["Profile onboarding<br/>[Onboarding.jsx]"]
  node_museum["Memory galleries<br/>[MuseumHome.jsx]"]
  node_memory_session["Memory session<br/>[MemorySession.jsx]"]
  node_audio_capture["Audio capture"]
end

subgraph group_identity["Identity and profile"]
  node_login["Google sign-in<br/>[Login.jsx]"]
  node_auth["Auth and profile<br/>[AuthContext.jsx]"]
  node_firebase_client["Firebase client<br/>[firebaseClient.js]"]
end

subgraph group_api["Analysis API"]
  node_api_server["Express API<br/>[index.js]"]
  node_analysis_route["Analyze endpoint<br/>[analyze.js]"]
  node_voice_route["Voice endpoint<br/>[voice.js]"]
  node_sessions_route["Session endpoints<br/>[sessions.js]"]
end

subgraph group_services["Analysis services"]
  node_speech_metrics["Speech metrics<br/>[audioAnalysis.js]"]
  node_gemini["Gemini observations<br/>[gemini.js]"]
  node_elevenlabs["ElevenLabs voice<br/>[elevenlabs.js]"]
end

subgraph group_records["Session records"]
  node_firebase_admin[("Firestore access<br/>[firebase.js]")]
end

subgraph group_clinical_ui["Clinician review"]
  node_dashboard["Clinician dashboard"]
  node_clinician_login["Clinician access<br/>[ClinicianLogin.jsx]"]
end

node_patient(("Patient"))
node_clinician(("Clinician"))

node_patient -->|"opens"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_login
node_app -->|"protects route"| node_onboarding
node_app -->|"protects route"| node_museum
node_app -->|"protects route"| node_memory_session
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_clinician_login
node_login -->|"signs in through"| node_auth
node_auth -->|"uses"| node_firebase_client
node_onboarding -->|"saves profile"| node_auth
node_museum -->|"reads identity"| node_auth
node_memory_session -->|"reads profile"| node_auth
node_memory_session -->|"records through"| node_audio_capture
node_memory_session -->|"posts analysis"| node_api_server
node_memory_session -->|"requests voice"| node_api_server
node_api_server -->|"mounts"| node_analysis_route
node_api_server -->|"mounts"| node_voice_route
node_api_server -->|"mounts"| node_sessions_route
node_analysis_route -->|"computes metrics"| node_speech_metrics
node_analysis_route -->|"requests insight"| node_gemini
node_analysis_route -->|"reads and writes"| node_firebase_admin
node_voice_route -->|"requests speech"| node_elevenlabs
node_sessions_route -->|"reads and writes"| node_firebase_admin
node_sessions_route -->|"requests summary"| node_gemini
node_clinician -->|"reviews trends"| node_dashboard
node_dashboard -.->|"loads session analytics"| node_api_server
node_clinician -->|"opens"| node_clinician_login

click node_app "https://github.com/kxm1908/wehack26/blob/main/frontend/src/App.jsx"
click node_landing "https://github.com/kxm1908/wehack26/blob/main/frontend/src/Landing.jsx"
click node_login "https://github.com/kxm1908/wehack26/blob/main/frontend/src/Login.jsx"
click node_auth "https://github.com/kxm1908/wehack26/blob/main/frontend/src/AuthContext.jsx"
click node_firebase_client "https://github.com/kxm1908/wehack26/blob/main/frontend/src/firebaseClient.js"
click node_onboarding "https://github.com/kxm1908/wehack26/blob/main/frontend/src/Onboarding.jsx"
click node_museum "https://github.com/kxm1908/wehack26/blob/main/frontend/src/MuseumHome.jsx"
click node_memory_session "https://github.com/kxm1908/wehack26/blob/main/frontend/src/MemorySession.jsx"
click node_audio_capture "https://github.com/kxm1908/wehack26/blob/main/frontend/src/useAudioAnalysis.js"
click node_api_server "https://github.com/kxm1908/wehack26/blob/main/backend/src/index.js"
click node_analysis_route "https://github.com/kxm1908/wehack26/blob/main/backend/src/routes/analyze.js"
click node_voice_route "https://github.com/kxm1908/wehack26/blob/main/backend/src/routes/voice.js"
click node_sessions_route "https://github.com/kxm1908/wehack26/blob/main/backend/src/routes/sessions.js"
click node_speech_metrics "https://github.com/kxm1908/wehack26/blob/main/backend/src/services/audioAnalysis.js"
click node_gemini "https://github.com/kxm1908/wehack26/blob/main/backend/src/services/gemini.js"
click node_elevenlabs "https://github.com/kxm1908/wehack26/blob/main/backend/src/services/elevenlabs.js"
click node_firebase_admin "https://github.com/kxm1908/wehack26/blob/main/backend/src/firebase.js"
click node_dashboard "https://github.com/kxm1908/wehack26/blob/main/frontend/src/ClinicianDashboard.jsx"
click node_clinician_login "https://github.com/kxm1908/wehack26/blob/main/frontend/src/ClinicianLogin.jsx"

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_onboarding,node_museum,node_memory_session,node_audio_capture toneBlue
class node_login,node_auth,node_firebase_client toneAmber
class node_api_server,node_analysis_route,node_voice_route,node_sessions_route toneMint
class node_speech_metrics,node_gemini,node_elevenlabs toneRose
class node_firebase_admin,node_patient,node_clinician toneIndigo
class node_dashboard,node_clinician_login toneTeal
```

## Components

### Patient experience

- [App routing](https://github.com/kxm1908/wehack26/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Museum entrance](https://github.com/kxm1908/wehack26/blob/main/frontend/src/Landing.jsx): `frontend/src/Landing.jsx`
- [Profile onboarding](https://github.com/kxm1908/wehack26/blob/main/frontend/src/Onboarding.jsx): `frontend/src/Onboarding.jsx`
- [Memory galleries](https://github.com/kxm1908/wehack26/blob/main/frontend/src/MuseumHome.jsx): `frontend/src/MuseumHome.jsx`
- [Memory session](https://github.com/kxm1908/wehack26/blob/main/frontend/src/MemorySession.jsx): `frontend/src/MemorySession.jsx`
- [Audio capture](https://github.com/kxm1908/wehack26/blob/main/frontend/src/useAudioAnalysis.js): `frontend/src/useAudioAnalysis.js`

### Identity and profile

- [Google sign-in](https://github.com/kxm1908/wehack26/blob/main/frontend/src/Login.jsx): `frontend/src/Login.jsx`
- [Auth and profile](https://github.com/kxm1908/wehack26/blob/main/frontend/src/AuthContext.jsx): `frontend/src/AuthContext.jsx`
- [Firebase client](https://github.com/kxm1908/wehack26/blob/main/frontend/src/firebaseClient.js): `frontend/src/firebaseClient.js`

### Analysis API

- [Express API](https://github.com/kxm1908/wehack26/blob/main/backend/src/index.js): `backend/src/index.js`
- [Analyze endpoint](https://github.com/kxm1908/wehack26/blob/main/backend/src/routes/analyze.js): `backend/src/routes/analyze.js`
- [Voice endpoint](https://github.com/kxm1908/wehack26/blob/main/backend/src/routes/voice.js): `backend/src/routes/voice.js`
- [Session endpoints](https://github.com/kxm1908/wehack26/blob/main/backend/src/routes/sessions.js): `backend/src/routes/sessions.js`

### Analysis services

- [Speech metrics](https://github.com/kxm1908/wehack26/blob/main/backend/src/services/audioAnalysis.js): `backend/src/services/audioAnalysis.js`
- [Gemini observations](https://github.com/kxm1908/wehack26/blob/main/backend/src/services/gemini.js): `backend/src/services/gemini.js`
- [ElevenLabs voice](https://github.com/kxm1908/wehack26/blob/main/backend/src/services/elevenlabs.js): `backend/src/services/elevenlabs.js`

### Session records

- [Firestore access](https://github.com/kxm1908/wehack26/blob/main/backend/src/firebase.js): `backend/src/firebase.js`

### Clinician review

- [Clinician dashboard](https://github.com/kxm1908/wehack26/blob/main/frontend/src/ClinicianDashboard.jsx): `frontend/src/ClinicianDashboard.jsx`
- [Clinician access](https://github.com/kxm1908/wehack26/blob/main/frontend/src/ClinicianLogin.jsx): `frontend/src/ClinicianLogin.jsx`

### Other components

- **Patient**
- **Clinician**

## Connections

- Patient → App routing: opens (evidence: `README.md`)
- App routing → Museum entrance: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Google sign-in: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Profile onboarding: protects route (evidence: `frontend/src/App.jsx`)
- App routing → Memory galleries: protects route (evidence: `frontend/src/App.jsx`)
- App routing → Memory session: protects route (evidence: `frontend/src/App.jsx`)
- App routing → Clinician dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Clinician access: routes to (evidence: `frontend/src/App.jsx`)
- Google sign-in → Auth and profile: signs in through (evidence: `frontend/src/Login.jsx`)
- Auth and profile → Firebase client: uses (evidence: `frontend/src/AuthContext.jsx`)
- Profile onboarding → Auth and profile: saves profile (evidence: `frontend/src/Onboarding.jsx`)
- Memory galleries → Auth and profile: reads identity (evidence: `frontend/src/MuseumHome.jsx`)
- Memory session → Auth and profile: reads profile (evidence: `frontend/src/MemorySession.jsx`)
- Memory session → Audio capture: records through (evidence: `frontend/src/MemorySession.jsx`)
- Memory session → Express API: posts analysis (evidence: `frontend/src/MemorySession.jsx`)
- Memory session → Express API: requests voice (evidence: `frontend/src/MemorySession.jsx`)
- Express API → Analyze endpoint: mounts (evidence: `backend/src/index.js`)
- Express API → Voice endpoint: mounts (evidence: `backend/src/index.js`)
- Express API → Session endpoints: mounts (evidence: `backend/src/index.js`)
- Analyze endpoint → Speech metrics: computes metrics (evidence: `backend/src/routes/analyze.js`)
- Analyze endpoint → Gemini observations: requests insight (evidence: `backend/src/routes/analyze.js`)
- Analyze endpoint → Firestore access: reads and writes (evidence: `backend/src/routes/analyze.js`)
- Voice endpoint → ElevenLabs voice: requests speech (evidence: `backend/src/routes/voice.js`)
- Session endpoints → Firestore access: reads and writes (evidence: `backend/src/routes/sessions.js`)
- Session endpoints → Gemini observations: requests summary (evidence: `backend/src/routes/sessions.js`)
- Clinician → Clinician dashboard: reviews trends (evidence: `README.md`)
- Clinician dashboard → Express API: loads session analytics
- Clinician → Clinician access: opens (evidence: `README.md`)
