# josephmusiiwa06-eng/p2p-alpha-01 architecture

> Architecture diagram of the GitHub repository josephmusiiwa06-eng/p2p-alpha-01, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/josephmusiiwa06-eng/p2p-alpha-01
- Repository: https://github.com/josephmusiiwa06-eng/p2p-alpha-01

## Overview

Play2Perform Alpha is a coach-facing early-childhood motor assessment app. Coaches sign in, register or select a child, enter four motor-test measurements, review an age-banded score, and save an assessment; child profiles expose assessment history, while shareable reports are read by token. The main internal layer is `src/lib/data.ts`, which the pages use for child, assessment, and report operations. The sampled excerpts do not show that module’s implementation or the report-generation caller, so those internal database and generation links are left unspecified.

Main entry points: [`src/lib/data.ts`](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/lib/data.ts) (Data operations), [`src/lib/supabase.ts`](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/lib/supabase.ts) (Supabase client), [`src/app/assess/[childId]/page.tsx`](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/assess/%5BchildId%5D/page.tsx) (Enter test results), [`src/app/login/page.tsx`](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/login/page.tsx) (Coach login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_coach_access["Coach access"]
  node_login["Coach login<br/>[page.tsx]"]
  node_dashboard["Coach dashboard<br/>[page.tsx]"]
end

subgraph group_child_records["Child records"]
  node_children_list["Child roster<br/>[page.tsx]"]
  node_child_create["Register child<br/>[page.tsx]"]
  node_child_profile["Child profile<br/>[page.tsx]"]
end

subgraph group_assessment["Assessment workflow"]
  node_assessment_select["Select child<br/>[page.tsx]"]
  node_assessment_entry["Enter test results<br/>[page.tsx]"]
  node_scoring["Age-based scoring<br/>[scoring.ts]"]
end

subgraph group_reporting["Reports and storage"]
  node_data_access["Data operations<br/>[data.ts]"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
  node_database[("Application schema<br/>[schema.sql]")]
  node_report_reader["Shared report viewer<br/>[page.tsx]"]
end

node_coach(("Coach"))
node_supabase["Supabase service"]
node_report_consumer(("Report reader"))

node_coach -->|"signs in"| node_login
node_login -->|"authenticates"| node_supabase
node_login -->|"routes after sign-in"| node_dashboard
node_dashboard -->|"queries coach data"| node_supabase_client
node_dashboard -->|"loads today’s assessments"| node_data_access
node_children_list -->|"checks coach"| node_supabase_client
node_children_list -->|"loads children"| node_data_access
node_child_create -->|"checks coach"| node_supabase_client
node_child_create -->|"creates child"| node_data_access
node_assessment_select -->|"checks coach"| node_supabase_client
node_assessment_select -->|"loads children"| node_data_access
node_assessment_entry -->|"checks session"| node_supabase_client
node_assessment_entry -->|"loads child"| node_data_access
node_assessment_entry -->|"calculates scores"| node_scoring
node_assessment_entry -->|"saves assessment"| node_data_access
node_child_profile -->|"checks coach"| node_supabase_client
node_child_profile -->|"loads child history"| node_data_access
node_report_consumer -->|"opens shared report"| node_report_reader
node_report_reader -->|"looks up token"| node_data_access

click node_login "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/login/page.tsx"
click node_dashboard "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/dashboard/page.tsx"
click node_children_list "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/children/page.tsx"
click node_child_create "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/children/new/page.tsx"
click node_child_profile "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/children/%5Bid%5D/page.tsx"
click node_assessment_select "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/assess/page.tsx"
click node_assessment_entry "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/assess/%5BchildId%5D/page.tsx"
click node_scoring "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/lib/scoring.ts"
click node_data_access "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/lib/data.ts"
click node_supabase_client "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/lib/supabase.ts"
click node_database "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/supabase/schema.sql"
click node_report_reader "https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/report/%5Btoken%5D/page.tsx"

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_dashboard toneBlue
class node_children_list,node_child_create,node_child_profile toneAmber
class node_assessment_select,node_assessment_entry,node_scoring toneMint
class node_data_access,node_supabase_client,node_database,node_report_reader toneRose
class node_coach,node_supabase,node_report_consumer toneIndigo
```

## Components

### Coach access

- [Coach login](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Coach dashboard](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`

### Child records

- [Child roster](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/children/page.tsx): `src/app/children/page.tsx`
- [Register child](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/children/new/page.tsx): `src/app/children/new/page.tsx`
- [Child profile](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/children/%5Bid%5D/page.tsx): `src/app/children/[id]/page.tsx`

### Assessment workflow

- [Select child](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/assess/page.tsx): `src/app/assess/page.tsx`
- [Enter test results](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/assess/%5BchildId%5D/page.tsx): `src/app/assess/[childId]/page.tsx`
- [Age-based scoring](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/lib/scoring.ts): `src/lib/scoring.ts`

### Reports and storage

- [Data operations](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/lib/data.ts): `src/lib/data.ts`
- [Supabase client](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Application schema](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/supabase/schema.sql): `supabase/schema.sql`
- [Shared report viewer](https://github.com/josephmusiiwa06-eng/p2p-alpha-01/blob/main/src/app/report/%5Btoken%5D/page.tsx): `src/app/report/[token]/page.tsx`

### Other components

- **Coach**
- **Supabase service**
- **Report reader**

## Connections

- Coach → Coach login: signs in
- Coach login → Supabase service: authenticates
- Coach login → Coach dashboard: routes after sign-in
- Coach dashboard → Supabase client: queries coach data
- Coach dashboard → Data operations: loads today’s assessments
- Child roster → Supabase client: checks coach
- Child roster → Data operations: loads children
- Register child → Supabase client: checks coach
- Register child → Data operations: creates child
- Select child → Supabase client: checks coach
- Select child → Data operations: loads children
- Enter test results → Supabase client: checks session
- Enter test results → Data operations: loads child
- Enter test results → Age-based scoring: calculates scores
- Enter test results → Data operations: saves assessment
- Child profile → Supabase client: checks coach
- Child profile → Data operations: loads child history
- Report reader → Shared report viewer: opens shared report
- Shared report viewer → Data operations: looks up token
