# ssyht/mcd-k-12-portal-sourcecode architecture

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

- Interactive diagram: https://gitdiagram.com/ssyht/mcd-k-12-portal-sourcecode
- Repository: https://github.com/ssyht/mcd-k-12-portal-sourcecode

## Overview

MCD K–12 Portal is an interactive AI-literacy and cyber-defense curriculum for grades 6–12. The main learner path is account creation or invitation, email verification and reviewer approval, entry to the learning portal, then interactive module work with progress saved through an authenticated API. Educators also have a cohort and review cockpit; administrators manage access and invitations. The README documents eight module previews, while sampled source gives detail on auth, registration, progress, and the safety-academy experience. Several feature links remain undocumented in sampled source and are therefore omitted.

Main entry points: [`src/lib/supabase/server.ts`](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/supabase/server.ts) (Server Supabase client), [`src/app/auth/sign-up/route.ts`](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/auth/sign-up/route.ts) (Create account), [`src/app/learn/modules/[slug]/page.tsx`](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/learn/modules/%5Bslug%5D/page.tsx) (Module player route), [`src/app/api/module-progress/route.ts`](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/api/module-progress/route.ts) (Progress API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity &amp; access"]
  node_signup["Create account<br/>[route.ts]"]
  node_authflow["Auth flow helpers<br/>[auth-flow.ts]"]
  node_verify["Verify email<br/>[route.ts]"]
  node_invite["Invitation sign-in<br/>[route.ts]"]
  node_serverclient["Server Supabase client<br/>[server.ts]"]
end

subgraph group_learning["Learning experience"]
  node_learn["Student command center<br/>[page.tsx]"]
  node_modulepage["Module player route<br/>[page.tsx]"]
  node_catalog["Module catalog<br/>[modules.ts]"]
  node_progressapi["Progress API<br/>[route.ts]"]
  node_progressdata["Progress records<br/>[module-progress.ts]"]
  node_teach["Educator cockpit<br/>[page.tsx]"]
  node_modulecontent["Module content delivery<br/>[module-content.ts]"]
end

subgraph group_operations["Portal operations"]
  node_review["Access review<br/>[page.tsx]"]
  node_admin["Admin management<br/>[page.tsx]"]
  node_registration["Curriculum registration<br/>[route.ts]"]
  node_workshop["Workshop updates<br/>[workshop-emails.ts]"]
end

subgraph group_worlds["Interactive curriculum"]
  node_academydata["Safety academy story<br/>[safety-academy.ts]"]
  node_academylogic["Academy state logic<br/>[safety-academy.ts]"]
  node_academyscene["Academy 3D scene"]
  node_modelstage["3D model stage<br/>[model-stage.ts]"]
  node_freightdata["Freight journey data<br/>[freight-journey.ts]"]
  node_freightlogic["Freight journey logic<br/>[freight-journey.ts]"]
  node_freightscene["Freight 3D scene"]
  node_neural["Neural network scene"]
  node_ocean["Oceanwatch mission"]
  node_blenderbuilder["Blender mesh builder<br/>[portal_builder.py]"]
  node_blenderhelpers["Blender world helpers<br/>[portal_helpers.py]"]
  node_nycworld["NYC defense world<br/>[nyc-world.py]"]
end

node_visitor(("Learner / educator"))
node_supabase[("Supabase services")]

node_visitor -->|"submits account"| node_signup
node_signup -->|"validates with"| node_authflow
node_signup -->|"creates account via"| node_serverclient
node_verify -->|"checks code with"| node_authflow
node_verify -->|"verifies through"| node_serverclient
node_invite -->|"signs in through"| node_serverclient
node_invite -->|"accepts invitation"| node_supabase
node_signup -->|"registers identity"| node_supabase
node_verify -->|"verifies identity"| node_supabase
node_review -.->|"reviews access"| node_supabase
node_visitor -->|"opens invitation"| node_invite
node_visitor -.->|"enters learning"| node_learn
node_learn -.->|"opens modules"| node_modulepage
node_modulepage -.->|"uses catalog"| node_catalog
node_modulepage -.->|"loads content"| node_modulecontent
node_modulepage -.->|"submits progress"| node_progressapi
node_progressapi -->|"authenticates with"| node_serverclient
node_progressapi -->|"types progress as"| node_progressdata
node_progressapi -->|"saves progress"| node_supabase
node_visitor -.->|"opens educator cockpit"| node_teach
node_visitor -.->|"manages portal"| node_admin
node_visitor -->|"submits registration"| node_registration
node_registration -->|"creates client"| node_serverclient
node_registration -->|"stores registration"| node_supabase
node_registration -->|"uses consent text"| node_workshop
node_academylogic -->|"resolves cues"| node_academydata
node_academyscene -->|"uses state logic"| node_academylogic
node_academyscene -->|"reads story data"| node_academydata
node_academyscene -->|"uses stage"| node_modelstage
node_freightlogic -->|"reads journey data"| node_freightdata
node_freightlogic -->|"drives scene"| node_freightscene
node_visitor -.->|"explores missions"| node_academyscene
node_visitor -.->|"explores journey"| node_freightscene
node_blenderhelpers -.->|"builds shared geometry"| node_blenderbuilder
node_nycworld -->|"uses builder"| node_blenderbuilder
node_nycworld -->|"uses helpers"| node_blenderhelpers

click node_signup "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/auth/sign-up/route.ts"
click node_authflow "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/auth-flow.ts"
click node_verify "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/auth/verify-email/route.ts"
click node_invite "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/auth/invite/route.ts"
click node_serverclient "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/supabase/server.ts"
click node_review "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/admin/access/page.tsx"
click node_learn "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/learn/page.tsx"
click node_modulepage "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/learn/modules/%5Bslug%5D/page.tsx"
click node_catalog "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/data/modules.ts"
click node_progressapi "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/api/module-progress/route.ts"
click node_progressdata "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/data/module-progress.ts"
click node_teach "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/teach/page.tsx"
click node_admin "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/admin/invitations/page.tsx"
click node_registration "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/api/registrations/route.ts"
click node_workshop "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/data/workshop-emails.ts"
click node_modulecontent "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/module-content.ts"
click node_academydata "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/data/safety-academy.ts"
click node_academylogic "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/safety-academy.ts"
click node_academyscene "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/three/safety-academy-scene.ts"
click node_modelstage "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/three/model-stage.ts"
click node_freightdata "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/data/freight-journey.ts"
click node_freightlogic "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/freight-journey.ts"
click node_freightscene "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/three/freight-journey-scene.ts"
click node_neural "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/three/neural-network-scene.ts"
click node_ocean "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/three/oceanwatch-mission-scene.ts"
click node_blenderbuilder "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/blender/portal_builder.py"
click node_blenderhelpers "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/blender/portal_helpers.py"
click node_nycworld "https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/blender/module-04/nyc-world.py"

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_signup,node_authflow,node_verify,node_invite,node_serverclient toneBlue
class node_learn,node_modulepage,node_catalog,node_progressapi,node_progressdata,node_teach,node_modulecontent,node_supabase toneAmber
class node_review,node_admin,node_registration,node_workshop toneMint
class node_academydata,node_academylogic,node_academyscene,node_modelstage,node_freightdata,node_freightlogic,node_freightscene,node_neural,node_ocean,node_blenderbuilder,node_blenderhelpers,node_nycworld toneRose
class node_visitor toneIndigo
```

## Components

### Identity & access

- [Create account](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/auth/sign-up/route.ts): `src/app/auth/sign-up/route.ts`
- [Auth flow helpers](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/auth-flow.ts): `src/lib/auth-flow.ts`
- [Verify email](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/auth/verify-email/route.ts): `src/app/auth/verify-email/route.ts`
- [Invitation sign-in](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/auth/invite/route.ts): `src/app/auth/invite/route.ts`
- [Server Supabase client](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`

### Learning experience

- [Student command center](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/learn/page.tsx): `src/app/learn/page.tsx`
- [Module player route](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/learn/modules/%5Bslug%5D/page.tsx): `src/app/learn/modules/[slug]/page.tsx`
- [Module catalog](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/data/modules.ts): `src/data/modules.ts`
- [Progress API](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/api/module-progress/route.ts): `src/app/api/module-progress/route.ts`
- [Progress records](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/data/module-progress.ts): `src/data/module-progress.ts`
- [Educator cockpit](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/teach/page.tsx): `src/app/teach/page.tsx`
- [Module content delivery](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/module-content.ts): `src/lib/module-content.ts`

### Portal operations

- [Access review](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/admin/access/page.tsx): `src/app/admin/access/page.tsx`
- [Admin management](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/admin/invitations/page.tsx): `src/app/admin/invitations/page.tsx`
- [Curriculum registration](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/app/api/registrations/route.ts): `src/app/api/registrations/route.ts`
- [Workshop updates](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/data/workshop-emails.ts): `src/data/workshop-emails.ts`

### Interactive curriculum

- [Safety academy story](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/data/safety-academy.ts): `src/data/safety-academy.ts`
- [Academy state logic](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/safety-academy.ts): `src/lib/safety-academy.ts`
- [Academy 3D scene](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/three/safety-academy-scene.ts): `src/lib/three/safety-academy-scene.ts`
- [3D model stage](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/three/model-stage.ts): `src/lib/three/model-stage.ts`
- [Freight journey data](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/data/freight-journey.ts): `src/data/freight-journey.ts`
- [Freight journey logic](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/freight-journey.ts): `src/lib/freight-journey.ts`
- [Freight 3D scene](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/three/freight-journey-scene.ts): `src/lib/three/freight-journey-scene.ts`
- [Neural network scene](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/three/neural-network-scene.ts): `src/lib/three/neural-network-scene.ts`
- [Oceanwatch mission](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/src/lib/three/oceanwatch-mission-scene.ts): `src/lib/three/oceanwatch-mission-scene.ts`
- [Blender mesh builder](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/blender/portal_builder.py): `blender/portal_builder.py`
- [Blender world helpers](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/blender/portal_helpers.py): `blender/portal_helpers.py`
- [NYC defense world](https://github.com/ssyht/mcd-k-12-portal-sourcecode/blob/main/blender/module-04/nyc-world.py): `blender/module-04/nyc-world.py`

### Other components

- **Learner / educator**
- **Supabase services**

## Connections

- Learner / educator → Create account: submits account (evidence: `src/app/auth/sign-up/route.ts`)
- Create account → Auth flow helpers: validates with (evidence: `src/app/auth/sign-up/route.ts`)
- Create account → Server Supabase client: creates account via (evidence: `src/app/auth/sign-up/route.ts`)
- Verify email → Auth flow helpers: checks code with (evidence: `src/app/auth/verify-email/route.ts`)
- Verify email → Server Supabase client: verifies through (evidence: `src/app/auth/verify-email/route.ts`)
- Invitation sign-in → Server Supabase client: signs in through (evidence: `src/app/auth/invite/route.ts`)
- Invitation sign-in → Supabase services: accepts invitation (evidence: `src/app/auth/invite/route.ts`)
- Create account → Supabase services: registers identity (evidence: `src/app/auth/sign-up/route.ts`)
- Verify email → Supabase services: verifies identity (evidence: `src/app/auth/verify-email/route.ts`)
- Access review → Supabase services: reviews access
- Learner / educator → Invitation sign-in: opens invitation (evidence: `src/app/auth/invite/route.ts`)
- Learner / educator → Student command center: enters learning
- Student command center → Module player route: opens modules
- Module player route → Module catalog: uses catalog
- Module player route → Module content delivery: loads content
- Module player route → Progress API: submits progress
- Progress API → Server Supabase client: authenticates with (evidence: `src/app/api/module-progress/route.ts`)
- Progress API → Progress records: types progress as (evidence: `src/app/api/module-progress/route.ts`)
- Progress API → Supabase services: saves progress (evidence: `src/app/api/module-progress/route.ts`)
- Learner / educator → Educator cockpit: opens educator cockpit
- Learner / educator → Admin management: manages portal
- Learner / educator → Curriculum registration: submits registration (evidence: `src/app/api/registrations/route.ts`)
- Curriculum registration → Server Supabase client: creates client (evidence: `src/app/api/registrations/route.ts`)
- Curriculum registration → Supabase services: stores registration (evidence: `src/app/api/registrations/route.ts`)
- Curriculum registration → Workshop updates: uses consent text (evidence: `src/app/api/registrations/route.ts`)
- Academy state logic → Safety academy story: resolves cues (evidence: `AI Portal Ad 30s/source/ad-reel-page.tsx`)
- Academy 3D scene → Academy state logic: uses state logic (evidence: `src/lib/three/safety-academy-scene.ts`)
- Academy 3D scene → Safety academy story: reads story data (evidence: `src/lib/three/safety-academy-scene.ts`)
- Academy 3D scene → 3D model stage: uses stage (evidence: `src/lib/three/safety-academy-scene.ts`)
- Freight journey logic → Freight journey data: reads journey data (evidence: `src/lib/freight-journey.ts`)
- Freight journey logic → Freight 3D scene: drives scene (evidence: `AI Portal Ad 30s/source/ad-reel-page.tsx`)
- Learner / educator → Academy 3D scene: explores missions
- Learner / educator → Freight 3D scene: explores journey
- Blender world helpers → Blender mesh builder: builds shared geometry
- NYC defense world → Blender mesh builder: uses builder (evidence: `blender/module-04/nyc-world.py`)
- NYC defense world → Blender world helpers: uses helpers (evidence: `blender/module-04/nyc-world.py`)
