# angus-sun/matcha-dance architecture

> Architecture diagram of the GitHub repository angus-sun/matcha-dance, 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/angus-sun/matcha-dance
- Repository: https://github.com/angus-sun/matcha-dance

## Overview

MatchA Dance is a dance-challenge app: users browse challenges, compare webcam poses with a reference, record and submit attempts, then review scores and leaderboards. Uploads create challenges; authentication and profiles support participation and social browsing. The graph includes the documented scoring, performance-points, profile, and leaderboard capabilities. Some connections come from the README or SOURCE INDEX rather than complete source excerpts, so uncertain wiring is omitted.

Main entry points: [`frontend/src/utils/supabaseClient.js`](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/utils/supabaseClient.js) (Supabase data and auth), [`frontend/src/App.jsx`](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/App.jsx) (App routing), [`frontend/src/pages/ChallengePage.jsx`](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/ChallengePage.jsx) (Challenge attempt), [`backend/server.js`](https://github.com/angus-sun/matcha-dance/blob/main/backend/server.js) (HTTP and socket server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Challenge experience"]
  node_app["App routing<br/>[App.jsx]"]
  node_home["Challenge browsing<br/>[Home.jsx]"]
  node_upload["Challenge uploads<br/>[UploadPage.jsx]"]
  node_reference["Video pose extraction"]
  node_challenge["Challenge attempt<br/>[ChallengePage.jsx]"]
  node_capture["Video recording<br/>[VideoFeed.jsx]"]
  node_pose["Webcam pose detection"]
  node_timedpose["Timed pose detection"]
  node_poseutil["Pose comparison<br/>[poseUtil.js]"]
end

subgraph group_identity["Identity and profiles"]
  node_auth["Authentication<br/>[Auth.jsx]"]
  node_userstate["User and profile state<br/>[useUser.jsx]"]
  node_profile["Profile and history<br/>[Profile.jsx]"]
  node_myuploads["My uploads<br/>[MyUploads.jsx]"]
  node_mymimics["Completed mimics<br/>[MyMimics.jsx]"]
end

subgraph group_results["Scoring and competition"]
  node_scoringapi["Score API client<br/>[scoringAPI.js]"]
  node_scoring["Score and PP rules<br/>[scoring.js]"]
  node_leaderboard["Challenge leaderboard<br/>[Leaderboard.jsx]"]
  node_globalboard["Global leaderboard"]
  node_leaderpage["Leaderboard page"]
end

subgraph group_services["Backend and data"]
  node_api["HTTP and socket server<br/>[server.js]"]
  node_supabase[("Supabase data and auth<br/>[supabaseClient.js]")]
  node_backenddb[("Backend Supabase client<br/>[supabase.js]")]
end

node_dancer(("Dancer"))
node_supabaseservice[("Supabase service")]
node_mediapipe["MediaPipe Pose"]

node_dancer -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_upload
node_app -->|"routes to"| node_challenge
node_app -->|"routes to"| node_auth
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_leaderpage
node_upload -->|"extracts poses"| node_reference
node_challenge -->|"records attempt"| node_capture
node_challenge -->|"starts detection"| node_pose
node_challenge -->|"calculates PP"| node_scoringapi
node_pose -->|"compares poses"| node_poseutil
node_timedpose -->|"compares poses"| node_poseutil
node_pose -->|"runs inference"| node_mediapipe
node_timedpose -->|"runs inference"| node_mediapipe
node_challenge -->|"submits score"| node_api
node_api -->|"calculates PP"| node_scoring
node_api -->|"reads and writes"| node_backenddb
node_auth -->|"authenticates"| node_supabase
node_userstate -->|"loads profile"| node_supabase
node_userstate -->|"provides state"| node_profile
node_profile -->|"loads stats"| node_scoringapi
node_profile -->|"reads and updates"| node_supabase
node_home -->|"loads challenges"| node_supabase
node_upload -->|"stores challenge"| node_supabase
node_leaderboard -->|"loads scores"| node_supabase
node_globalboard -->|"loads rankings"| node_supabase
node_leaderpage -->|"renders"| node_globalboard
node_scoringapi -.->|"requests stats"| node_api
node_api -->|"queries data"| node_supabaseservice
node_myuploads -.->|"loads uploads"| node_supabase
node_mymimics -.->|"loads attempts"| node_supabase

click node_app "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/Home.jsx"
click node_upload "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/UploadPage.jsx"
click node_reference "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/utils/videoToReference.js"
click node_challenge "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/ChallengePage.jsx"
click node_capture "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/components/VideoFeed.jsx"
click node_pose "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/hooks/usePoseDetection.js"
click node_timedpose "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/hooks/useVideoTimedPoseDetection.js"
click node_poseutil "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/utils/poseUtil.js"
click node_auth "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/Auth.jsx"
click node_userstate "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/hooks/useUser.jsx"
click node_profile "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/Profile.jsx"
click node_myuploads "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/MyUploads.jsx"
click node_mymimics "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/MyMimics.jsx"
click node_scoringapi "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/utils/scoringAPI.js"
click node_scoring "https://github.com/angus-sun/matcha-dance/blob/main/backend/utils/scoring.js"
click node_leaderboard "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/components/Leaderboard.jsx"
click node_globalboard "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/components/GlobalLeaderboard.jsx"
click node_leaderpage "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/LeaderboardPage.jsx"
click node_api "https://github.com/angus-sun/matcha-dance/blob/main/backend/server.js"
click node_supabase "https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/utils/supabaseClient.js"
click node_backenddb "https://github.com/angus-sun/matcha-dance/blob/main/backend/supabase.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_home,node_upload,node_reference,node_challenge,node_capture,node_pose,node_timedpose,node_poseutil toneBlue
class node_auth,node_userstate,node_profile,node_myuploads,node_mymimics,node_supabaseservice toneAmber
class node_scoringapi,node_scoring,node_leaderboard,node_globalboard,node_leaderpage,node_mediapipe toneMint
class node_api,node_supabase,node_backenddb toneRose
class node_dancer toneIndigo
```

## Components

### Challenge experience

- [App routing](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Challenge browsing](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Challenge uploads](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/UploadPage.jsx): `frontend/src/pages/UploadPage.jsx`
- [Video pose extraction](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/utils/videoToReference.js): `frontend/src/utils/videoToReference.js`
- [Challenge attempt](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/ChallengePage.jsx): `frontend/src/pages/ChallengePage.jsx`
- [Video recording](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/components/VideoFeed.jsx): `frontend/src/components/VideoFeed.jsx`
- [Webcam pose detection](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/hooks/usePoseDetection.js): `frontend/src/hooks/usePoseDetection.js`
- [Timed pose detection](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/hooks/useVideoTimedPoseDetection.js): `frontend/src/hooks/useVideoTimedPoseDetection.js`
- [Pose comparison](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/utils/poseUtil.js): `frontend/src/utils/poseUtil.js`

### Identity and profiles

- [Authentication](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/Auth.jsx): `frontend/src/pages/Auth.jsx`
- [User and profile state](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/hooks/useUser.jsx): `frontend/src/hooks/useUser.jsx`
- [Profile and history](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/Profile.jsx): `frontend/src/pages/Profile.jsx`
- [My uploads](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/MyUploads.jsx): `frontend/src/pages/MyUploads.jsx`
- [Completed mimics](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/MyMimics.jsx): `frontend/src/pages/MyMimics.jsx`

### Scoring and competition

- [Score API client](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/utils/scoringAPI.js): `frontend/src/utils/scoringAPI.js`
- [Score and PP rules](https://github.com/angus-sun/matcha-dance/blob/main/backend/utils/scoring.js): `backend/utils/scoring.js`
- [Challenge leaderboard](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/components/Leaderboard.jsx): `frontend/src/components/Leaderboard.jsx`
- [Global leaderboard](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/components/GlobalLeaderboard.jsx): `frontend/src/components/GlobalLeaderboard.jsx`
- [Leaderboard page](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/pages/LeaderboardPage.jsx): `frontend/src/pages/LeaderboardPage.jsx`

### Backend and data

- [HTTP and socket server](https://github.com/angus-sun/matcha-dance/blob/main/backend/server.js): `backend/server.js`
- [Supabase data and auth](https://github.com/angus-sun/matcha-dance/blob/main/frontend/src/utils/supabaseClient.js): `frontend/src/utils/supabaseClient.js`
- [Backend Supabase client](https://github.com/angus-sun/matcha-dance/blob/main/backend/supabase.js): `backend/supabase.js`

### Other components

- **Dancer**
- **Supabase service**
- **MediaPipe Pose**

## Connections

- Dancer → App routing: uses (evidence: `frontend/src/App.jsx`)
- App routing → Challenge browsing: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Challenge uploads: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Challenge attempt: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Authentication: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Profile and history: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Leaderboard page: routes to (evidence: `frontend/src/App.jsx`)
- Challenge uploads → Video pose extraction: extracts poses (evidence: `frontend/src/pages/UploadPage.jsx`)
- Challenge attempt → Video recording: records attempt
- Challenge attempt → Webcam pose detection: starts detection (evidence: `frontend/src/pages/ChallengePage.jsx`)
- Challenge attempt → Score API client: calculates PP (evidence: `frontend/src/pages/ChallengePage.jsx`)
- Webcam pose detection → Pose comparison: compares poses (evidence: `frontend/src/hooks/usePoseDetection.js`)
- Timed pose detection → Pose comparison: compares poses (evidence: `frontend/src/hooks/useVideoTimedPoseDetection.js`)
- Webcam pose detection → MediaPipe Pose: runs inference (evidence: `frontend/src/hooks/usePoseDetection.js`)
- Timed pose detection → MediaPipe Pose: runs inference (evidence: `frontend/src/hooks/useVideoTimedPoseDetection.js`)
- Challenge attempt → HTTP and socket server: submits score (evidence: `frontend/src/pages/ChallengePage.jsx`)
- HTTP and socket server → Score and PP rules: calculates PP (evidence: `backend/server.js`)
- HTTP and socket server → Backend Supabase client: reads and writes (evidence: `backend/server.js`)
- Authentication → Supabase data and auth: authenticates (evidence: `frontend/src/pages/Auth.jsx`)
- User and profile state → Supabase data and auth: loads profile (evidence: `frontend/src/hooks/useUser.jsx`)
- User and profile state → Profile and history: provides state (evidence: `frontend/src/App.jsx`)
- Profile and history → Score API client: loads stats (evidence: `frontend/src/pages/Profile.jsx`)
- Profile and history → Supabase data and auth: reads and updates (evidence: `frontend/src/pages/Profile.jsx`)
- Challenge browsing → Supabase data and auth: loads challenges (evidence: `frontend/src/pages/Home.jsx`)
- Challenge uploads → Supabase data and auth: stores challenge (evidence: `frontend/src/pages/UploadPage.jsx`)
- Challenge leaderboard → Supabase data and auth: loads scores (evidence: `frontend/src/components/Leaderboard.jsx`)
- Global leaderboard → Supabase data and auth: loads rankings (evidence: `frontend/src/components/GlobalLeaderboard.jsx`)
- Leaderboard page → Global leaderboard: renders (evidence: `frontend/src/pages/LeaderboardPage.jsx`)
- Score API client → HTTP and socket server: requests stats
- HTTP and socket server → Supabase service: queries data (evidence: `backend/server.js`)
- My uploads → Supabase data and auth: loads uploads (evidence: `frontend/src/pages/MyUploads.jsx`)
- Completed mimics → Supabase data and auth: loads attempts (evidence: `frontend/src/pages/MyMimics.jsx`)
