# thecompilerbro/ai_playground-kids-learning-platform architecture

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

- Interactive diagram: https://gitdiagram.com/thecompilerbro/ai_playground-kids-learning-platform
- Repository: https://github.com/thecompilerbro/ai_playground-kids-learning-platform

## Overview

AI Playground combines child-focused lessons, an interactive classifier lab, local progress/profile features, and parent-facing safety/settings with a session-based authentication service. The main learner flow is routed through learning pages and activities, with progress recorded locally; login and OTP requests travel through the auth client and backend routes to session and email delivery. Backend relationships follow the supplied excerpts and README; frontend branches not sampled are included where documented, with uncertain links omitted.

Main entry points: [`backend/src/services/auth.service.ts`](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/auth.service.ts) (OTP and account service), [`src/components/lab/LabView.tsx`](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/components/lab/LabView.tsx) (AI classifier lab), [`backend/src/services/email.service.ts`](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/email.service.ts) (Email provider selection), [`backend/src/workers/email-outbox.worker.ts`](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/workers/email-outbox.worker.ts) (Outbox delivery worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Learning experience"]
  node_router["Page routing<br/>[router.tsx]"]
  node_lesson_pages["Lessons and dashboard"]
  node_lesson_content["Lesson activities"]
  node_lesson_data["Bands and lessons"]
  node_lab_view["AI classifier lab<br/>[LabView.tsx]"]
  node_lab_engine["Classifier demo<br/>[classifierDemo.ts]"]
  node_lab_samples["Lab samples<br/>[labData.ts]"]
end

subgraph group_progress["Progress and profiles"]
  node_profile["Profile and parent settings<br/>[ProfilePage.tsx]"]
  node_progress_hook["Progress state<br/>[useProgress.ts]"]
  node_progress_service["Progress rules<br/>[progressService.ts]"]
  node_local_storage[("Local progress storage<br/>[storage.ts]")]
end

subgraph group_frontend_auth["Frontend authentication"]
  node_login["Login and signup<br/>[LoginPage.tsx]"]
  node_auth_context["Session context<br/>[AuthContext.tsx]"]
  node_auth_api["Auth API client<br/>[authApi.ts]"]
end

subgraph group_backend_auth["Authentication backend"]
  node_auth_gateway["Auth routes and middleware<br/>[auth.routes.ts]"]
  node_auth_controller["Auth controller<br/>[auth.controller.ts]"]
  node_auth_service["OTP and account service<br/>[auth.service.ts]"]
  node_user_store[("User records<br/>[user.model.ts]")]
  node_challenge_store[("OTP challenges")]
  node_idempotency[("Idempotency records")]
  node_crypto["Cryptographic utilities<br/>[crypto.ts]"]
end

subgraph group_delivery["Email delivery"]
  node_email_outbox[("Encrypted email outbox")]
  node_outbox_worker["Outbox delivery worker"]
  node_email_service["Email provider selection<br/>[email.service.ts]"]
  node_resend["Resend provider<br/>[resend.adapter.ts]"]
  node_smtp["SMTP provider<br/>[smtp.adapter.ts]"]
end

node_learner(("Learner / parent"))
node_email_user(("Email recipient"))

node_learner -->|"opens pages"| node_router
node_router -->|"routes to"| node_lesson_pages
node_lesson_pages -.->|"presents activities"| node_lesson_content
node_lesson_pages -.->|"uses lesson content"| node_lesson_data
node_learner -.->|"uses lab"| node_lab_view
node_lab_view -->|"runs classifier"| node_lab_engine
node_lab_view -->|"loads samples"| node_lab_samples
node_lab_view -->|"records trials"| node_progress_hook
node_profile -->|"reads and updates"| node_progress_hook
node_progress_hook -->|"delegates progress"| node_progress_service
node_progress_service -->|"persists progress"| node_local_storage
node_learner -->|"signs in"| node_login
node_login -->|"uses auth actions"| node_auth_context
node_auth_context -->|"calls"| node_auth_api
node_auth_api -.->|"sends auth requests"| node_auth_gateway
node_auth_gateway -->|"routes requests"| node_auth_controller
node_auth_controller -->|"invokes auth actions"| node_auth_service
node_auth_service -->|"reads and writes"| node_user_store
node_auth_service -->|"creates and verifies"| node_challenge_store
node_auth_gateway -.->|"guards mutations"| node_idempotency
node_auth_service -->|"hashes and encrypts"| node_crypto
node_auth_service -->|"stages email job"| node_email_outbox
node_outbox_worker -->|"polls and updates"| node_email_outbox
node_outbox_worker -->|"decrypts payload"| node_crypto
node_outbox_worker -->|"dispatches email"| node_email_service
node_email_service -->|"selects provider"| node_resend
node_email_service -->|"selects provider"| node_smtp
node_email_service -.->|"sends message"| node_email_user

click node_router "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/app/router.tsx"
click node_lesson_pages "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/tree/main/src/pages"
click node_lesson_content "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/tree/main/src/components/lesson"
click node_lesson_data "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/tree/main/src/data"
click node_lab_view "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/components/lab/LabView.tsx"
click node_lab_engine "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/services/classifierDemo.ts"
click node_lab_samples "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/data/labData.ts"
click node_profile "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/pages/ProfilePage.tsx"
click node_progress_hook "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/hooks/useProgress.ts"
click node_progress_service "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/services/progressService.ts"
click node_local_storage "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/services/storage.ts"
click node_login "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/pages/LoginPage.tsx"
click node_auth_context "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/context/AuthContext.tsx"
click node_auth_api "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/services/authApi.ts"
click node_auth_gateway "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/routes/auth.routes.ts"
click node_auth_controller "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/controllers/auth.controller.ts"
click node_auth_service "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/auth.service.ts"
click node_user_store "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/models/user.model.ts"
click node_challenge_store "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/models/otp-challenge.model.ts"
click node_idempotency "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/idempotency.service.ts"
click node_crypto "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/utils/crypto.ts"
click node_email_outbox "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/models/email-outbox.model.ts"
click node_outbox_worker "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/workers/email-outbox.worker.ts"
click node_email_service "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/email.service.ts"
click node_resend "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/email-adapters/resend.adapter.ts"
click node_smtp "https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/email-adapters/smtp.adapter.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_router,node_lesson_pages,node_lesson_content,node_lesson_data,node_lab_view,node_lab_engine,node_lab_samples toneBlue
class node_profile,node_progress_hook,node_progress_service,node_local_storage toneAmber
class node_login,node_auth_context,node_auth_api toneMint
class node_auth_gateway,node_auth_controller,node_auth_service,node_user_store,node_challenge_store,node_idempotency,node_crypto toneRose
class node_email_outbox,node_outbox_worker,node_email_service,node_resend,node_smtp,node_learner,node_email_user toneIndigo
```

## Components

### Learning experience

- [Page routing](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/app/router.tsx): `src/app/router.tsx`
- [Lessons and dashboard](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/tree/main/src/pages): `src/pages`
- [Lesson activities](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/tree/main/src/components/lesson): `src/components/lesson`
- [Bands and lessons](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/tree/main/src/data): `src/data`
- [AI classifier lab](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/components/lab/LabView.tsx): `src/components/lab/LabView.tsx`
- [Classifier demo](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/services/classifierDemo.ts): `src/services/classifierDemo.ts`
- [Lab samples](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/data/labData.ts): `src/data/labData.ts`

### Progress and profiles

- [Profile and parent settings](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/pages/ProfilePage.tsx): `src/pages/ProfilePage.tsx`
- [Progress state](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/hooks/useProgress.ts): `src/hooks/useProgress.ts`
- [Progress rules](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/services/progressService.ts): `src/services/progressService.ts`
- [Local progress storage](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/services/storage.ts): `src/services/storage.ts`

### Frontend authentication

- [Login and signup](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/pages/LoginPage.tsx): `src/pages/LoginPage.tsx`
- [Session context](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Auth API client](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/src/services/authApi.ts): `src/services/authApi.ts`

### Authentication backend

- [Auth routes and middleware](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/routes/auth.routes.ts): `backend/src/routes/auth.routes.ts`
- [Auth controller](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/controllers/auth.controller.ts): `backend/src/controllers/auth.controller.ts`
- [OTP and account service](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/auth.service.ts): `backend/src/services/auth.service.ts`
- [User records](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/models/user.model.ts): `backend/src/models/user.model.ts`
- [OTP challenges](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/models/otp-challenge.model.ts): `backend/src/models/otp-challenge.model.ts`
- [Idempotency records](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/idempotency.service.ts): `backend/src/services/idempotency.service.ts`
- [Cryptographic utilities](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/utils/crypto.ts): `backend/src/utils/crypto.ts`

### Email delivery

- [Encrypted email outbox](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/models/email-outbox.model.ts): `backend/src/models/email-outbox.model.ts`
- [Outbox delivery worker](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/workers/email-outbox.worker.ts): `backend/src/workers/email-outbox.worker.ts`
- [Email provider selection](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/email.service.ts): `backend/src/services/email.service.ts`
- [Resend provider](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/email-adapters/resend.adapter.ts): `backend/src/services/email-adapters/resend.adapter.ts`
- [SMTP provider](https://github.com/thecompilerbro/ai_playground-kids-learning-platform/blob/main/backend/src/services/email-adapters/smtp.adapter.ts): `backend/src/services/email-adapters/smtp.adapter.ts`

### Other components

- **Learner / parent**
- **Email recipient**

## Connections

- Learner / parent → Page routing: opens pages (evidence: `src/app/router.tsx`)
- Page routing → Lessons and dashboard: routes to (evidence: `src/app/router.tsx`)
- Lessons and dashboard → Lesson activities: presents activities
- Lessons and dashboard → Bands and lessons: uses lesson content (evidence: `src/pages/ProfilePage.tsx`)
- Learner / parent → AI classifier lab: uses lab
- AI classifier lab → Classifier demo: runs classifier (evidence: `src/components/lab/LabView.tsx`)
- AI classifier lab → Lab samples: loads samples (evidence: `src/components/lab/LabView.tsx`)
- AI classifier lab → Progress state: records trials (evidence: `src/components/lab/LabView.tsx`)
- Profile and parent settings → Progress state: reads and updates (evidence: `src/pages/ProfilePage.tsx`)
- Progress state → Progress rules: delegates progress (evidence: `src/hooks/useProgress.ts`)
- Progress rules → Local progress storage: persists progress (evidence: `src/services/progressService.ts`)
- Learner / parent → Login and signup: signs in
- Login and signup → Session context: uses auth actions (evidence: `src/pages/LoginPage.tsx`)
- Session context → Auth API client: calls (evidence: `src/context/AuthContext.tsx`)
- Auth API client → Auth routes and middleware: sends auth requests
- Auth routes and middleware → Auth controller: routes requests (evidence: `backend/src/routes/auth.routes.ts`)
- Auth controller → OTP and account service: invokes auth actions (evidence: `backend/src/controllers/auth.controller.ts`)
- OTP and account service → User records: reads and writes (evidence: `backend/src/services/auth.service.ts`)
- OTP and account service → OTP challenges: creates and verifies (evidence: `backend/src/services/auth.service.ts`)
- Auth routes and middleware → Idempotency records: guards mutations
- OTP and account service → Cryptographic utilities: hashes and encrypts (evidence: `backend/src/services/auth.service.ts`)
- OTP and account service → Encrypted email outbox: stages email job (evidence: `backend/src/services/auth.service.ts`)
- Outbox delivery worker → Encrypted email outbox: polls and updates (evidence: `backend/src/workers/email-outbox.worker.ts`)
- Outbox delivery worker → Cryptographic utilities: decrypts payload (evidence: `backend/src/workers/email-outbox.worker.ts`)
- Outbox delivery worker → Email provider selection: dispatches email (evidence: `backend/src/workers/email-outbox.worker.ts`)
- Email provider selection → Resend provider: selects provider (evidence: `backend/src/services/email.service.ts`)
- Email provider selection → SMTP provider: selects provider (evidence: `backend/src/services/email.service.ts`)
- Email provider selection → Email recipient: sends message
