# silentk15/learnloop architecture

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

- Interactive diagram: https://gitdiagram.com/silentk15/learnloop
- Repository: https://github.com/silentk15/learnloop

## Overview

LearnLoop is an adaptive learning web app: students choose a subject, review their curriculum and mastery, complete adaptive drills or randomized Stat Trials, submit answers that update mastery, and view a session debrief. The graph separates the documented learning stages and persistence/assessment layers. Sampled routes establish the attempt, profile, question-selection, and diagnostic behavior; unsampled UI and route details are represented only where the README or imports support them.

Main entry points: [`src/app/page.tsx`](https://github.com/silentk15/learnloop/blob/main/src/app/page.tsx) (Learning home), [`src/lib/prisma.ts`](https://github.com/silentk15/learnloop/blob/main/src/lib/prisma.ts) (Prisma client), [`src/lib/getDemoStudent.ts`](https://github.com/silentk15/learnloop/blob/main/src/lib/getDemoStudent.ts) (Student lookup), [`src/app/api/attempts/route.ts`](https://github.com/silentk15/learnloop/blob/main/src/app/api/attempts/route.ts) (Answer processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Student experience"]
  node_home["Learning home<br/>[page.tsx]"]
  node_auth["Access check<br/>[AuthCheck.tsx]"]
  node_login["Sign in<br/>[page.tsx]"]
  node_signup["Sign up<br/>[page.tsx]"]
  node_realm["Subject selector"]
  node_dashboard["Quest dashboard<br/>[DashboardView.tsx]"]
end

subgraph group_assessment["Assessment workflow"]
  node_drill["Adaptive drill"]
  node_adaptive_api["Question selection<br/>[route.ts]"]
  node_trial["Stat Trial<br/>[DiagnosticView.tsx]"]
  node_diagnostic_api["Trial sampling<br/>[route.ts]"]
  node_attempt_api["Answer processing<br/>[route.ts]"]
  node_mastery["Mastery calculation<br/>[mastery.ts]"]
end

subgraph group_insight["Progress and insight"]
  node_profile_api["Progress summary<br/>[route.ts]"]
  node_results["Session debrief"]
  node_summary_api["AI synthesis<br/>[route.ts]"]
end

subgraph group_data["Identity and persistence"]
  node_student_resolver["Student lookup<br/>[getDemoStudent.ts]"]
  node_subjects_api["Realm progress<br/>[route.ts]"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
  node_database[("PostgreSQL<br/>[schema.prisma]")]
  node_reset_api["Demo reset<br/>[route.ts]"]
end

node_student(("Student"))
node_gemini{{"Google Gemini"}}

node_student -->|"opens"| node_home
node_home -->|"checks access"| node_auth
node_student -->|"signs in"| node_login
node_student -->|"registers"| node_signup
node_home -->|"selects realm"| node_realm
node_home -->|"shows progress"| node_dashboard
node_home -->|"starts drill"| node_drill
node_home -->|"starts trial"| node_trial
node_drill -->|"requests questions"| node_adaptive_api
node_trial -->|"requests sample"| node_diagnostic_api
node_drill -->|"submits answer"| node_attempt_api
node_attempt_api -->|"computes update"| node_mastery
node_home -->|"loads profile"| node_profile_api
node_home -->|"loads realms"| node_subjects_api
node_home -->|"shows debrief"| node_results
node_results -->|"requests synthesis"| node_summary_api
node_summary_api -.->|"generates feedback"| node_gemini
node_profile_api -->|"recommends concept"| node_mastery
node_profile_api -->|"resolves student"| node_student_resolver
node_subjects_api -->|"resolves student"| node_student_resolver
node_diagnostic_api -->|"resolves student"| node_student_resolver
node_adaptive_api -->|"resolves student"| node_student_resolver
node_attempt_api -->|"resolves student"| node_student_resolver
node_profile_api -->|"reads progress"| node_prisma
node_subjects_api -->|"reads realms"| node_prisma
node_diagnostic_api -->|"reads questions"| node_prisma
node_adaptive_api -->|"selects questions"| node_prisma
node_attempt_api -->|"records attempt"| node_prisma
node_reset_api -->|"resets demo data"| node_database
node_prisma -->|"queries"| node_database

click node_home "https://github.com/silentk15/learnloop/blob/main/src/app/page.tsx"
click node_auth "https://github.com/silentk15/learnloop/blob/main/src/components/AuthCheck.tsx"
click node_login "https://github.com/silentk15/learnloop/blob/main/src/app/login/page.tsx"
click node_signup "https://github.com/silentk15/learnloop/blob/main/src/app/signup/page.tsx"
click node_realm "https://github.com/silentk15/learnloop/blob/main/src/components/SubjectSelector.tsx"
click node_dashboard "https://github.com/silentk15/learnloop/blob/main/src/components/DashboardView.tsx"
click node_drill "https://github.com/silentk15/learnloop/blob/main/src/components/AdaptiveQuizView.tsx"
click node_adaptive_api "https://github.com/silentk15/learnloop/blob/main/src/app/api/quiz/adaptive/route.ts"
click node_trial "https://github.com/silentk15/learnloop/blob/main/src/components/DiagnosticView.tsx"
click node_diagnostic_api "https://github.com/silentk15/learnloop/blob/main/src/app/api/diagnostic/route.ts"
click node_attempt_api "https://github.com/silentk15/learnloop/blob/main/src/app/api/attempts/route.ts"
click node_mastery "https://github.com/silentk15/learnloop/blob/main/src/lib/mastery.ts"
click node_profile_api "https://github.com/silentk15/learnloop/blob/main/src/app/api/profile/route.ts"
click node_results "https://github.com/silentk15/learnloop/blob/main/src/components/SessionResultsView.tsx"
click node_summary_api "https://github.com/silentk15/learnloop/blob/main/src/app/api/session/summary/route.ts"
click node_student_resolver "https://github.com/silentk15/learnloop/blob/main/src/lib/getDemoStudent.ts"
click node_subjects_api "https://github.com/silentk15/learnloop/blob/main/src/app/api/subjects/route.ts"
click node_prisma "https://github.com/silentk15/learnloop/blob/main/src/lib/prisma.ts"
click node_database "https://github.com/silentk15/learnloop/blob/main/prisma/schema.prisma"
click node_reset_api "https://github.com/silentk15/learnloop/blob/main/src/app/api/reset/route.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_home,node_auth,node_login,node_signup,node_realm,node_dashboard toneBlue
class node_drill,node_adaptive_api,node_trial,node_diagnostic_api,node_attempt_api,node_mastery toneAmber
class node_profile_api,node_results,node_summary_api toneMint
class node_student_resolver,node_subjects_api,node_prisma,node_database,node_reset_api toneRose
class node_student,node_gemini toneIndigo
```

## Components

### Student experience

- [Learning home](https://github.com/silentk15/learnloop/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Access check](https://github.com/silentk15/learnloop/blob/main/src/components/AuthCheck.tsx): `src/components/AuthCheck.tsx`
- [Sign in](https://github.com/silentk15/learnloop/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Sign up](https://github.com/silentk15/learnloop/blob/main/src/app/signup/page.tsx): `src/app/signup/page.tsx`
- [Subject selector](https://github.com/silentk15/learnloop/blob/main/src/components/SubjectSelector.tsx): `src/components/SubjectSelector.tsx`
- [Quest dashboard](https://github.com/silentk15/learnloop/blob/main/src/components/DashboardView.tsx): `src/components/DashboardView.tsx`

### Assessment workflow

- [Adaptive drill](https://github.com/silentk15/learnloop/blob/main/src/components/AdaptiveQuizView.tsx): `src/components/AdaptiveQuizView.tsx`
- [Question selection](https://github.com/silentk15/learnloop/blob/main/src/app/api/quiz/adaptive/route.ts): `src/app/api/quiz/adaptive/route.ts`
- [Stat Trial](https://github.com/silentk15/learnloop/blob/main/src/components/DiagnosticView.tsx): `src/components/DiagnosticView.tsx`
- [Trial sampling](https://github.com/silentk15/learnloop/blob/main/src/app/api/diagnostic/route.ts): `src/app/api/diagnostic/route.ts`
- [Answer processing](https://github.com/silentk15/learnloop/blob/main/src/app/api/attempts/route.ts): `src/app/api/attempts/route.ts`
- [Mastery calculation](https://github.com/silentk15/learnloop/blob/main/src/lib/mastery.ts): `src/lib/mastery.ts`

### Progress and insight

- [Progress summary](https://github.com/silentk15/learnloop/blob/main/src/app/api/profile/route.ts): `src/app/api/profile/route.ts`
- [Session debrief](https://github.com/silentk15/learnloop/blob/main/src/components/SessionResultsView.tsx): `src/components/SessionResultsView.tsx`
- [AI synthesis](https://github.com/silentk15/learnloop/blob/main/src/app/api/session/summary/route.ts): `src/app/api/session/summary/route.ts`

### Identity and persistence

- [Student lookup](https://github.com/silentk15/learnloop/blob/main/src/lib/getDemoStudent.ts): `src/lib/getDemoStudent.ts`
- [Realm progress](https://github.com/silentk15/learnloop/blob/main/src/app/api/subjects/route.ts): `src/app/api/subjects/route.ts`
- [Prisma client](https://github.com/silentk15/learnloop/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`
- [PostgreSQL](https://github.com/silentk15/learnloop/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- [Demo reset](https://github.com/silentk15/learnloop/blob/main/src/app/api/reset/route.ts): `src/app/api/reset/route.ts`

### Other components

- **Student**
- **Google Gemini**

## Connections

- Student → Learning home: opens
- Learning home → Access check: checks access
- Student → Sign in: signs in
- Student → Sign up: registers
- Learning home → Subject selector: selects realm
- Learning home → Quest dashboard: shows progress
- Learning home → Adaptive drill: starts drill
- Learning home → Stat Trial: starts trial
- Adaptive drill → Question selection: requests questions
- Stat Trial → Trial sampling: requests sample
- Adaptive drill → Answer processing: submits answer
- Answer processing → Mastery calculation: computes update
- Learning home → Progress summary: loads profile
- Learning home → Realm progress: loads realms
- Learning home → Session debrief: shows debrief
- Session debrief → AI synthesis: requests synthesis
- AI synthesis → Google Gemini: generates feedback
- Progress summary → Mastery calculation: recommends concept
- Progress summary → Student lookup: resolves student
- Realm progress → Student lookup: resolves student
- Trial sampling → Student lookup: resolves student
- Question selection → Student lookup: resolves student
- Answer processing → Student lookup: resolves student
- Progress summary → Prisma client: reads progress
- Realm progress → Prisma client: reads realms
- Trial sampling → Prisma client: reads questions
- Question selection → Prisma client: selects questions
- Answer processing → Prisma client: records attempt
- Demo reset → PostgreSQL: resets demo data
- Prisma client → PostgreSQL: queries
