# rudr-automates/horizon-prototype architecture

> Architecture diagram of the GitHub repository rudr-automates/horizon-prototype, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rudr-automates/horizon-prototype
- Repository: https://github.com/rudr-automates/horizon-prototype

## Overview

Horizon is a timestamp-aware learning assistant: a learner watches a lesson, pauses at a playhead, asks a question, and receives cited claims drawn only from eligible evidence—or a refusal. The learning studio also exposes transcript, materials, notes, progress, and system status; the home page offers course discovery and resume. The graph combines sampled source relationships with README-documented product behavior. Some subsystems, including retrieval backends and several studio panels, were not excerpted, so their internal wiring is not inferred.

Main entry points: [`src/components/learning-studio.tsx`](https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/learning-studio.tsx) (Learning studio), [`src/lib/answer/pipeline.ts`](https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/answer/pipeline.ts) (Answer pipeline), [`src/lib/retrieval/index.ts`](https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/retrieval/index.ts) (Evidence retrieval), [`src/app/api/v1/courses/[courseId]/questions/route.ts`](https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/courses/%5BcourseId%5D/questions/route.ts) (Question endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Learner experience"]
  node_home["Home and course entry"]
  node_studio["Learning studio"]
  node_assistant["Question assistant"]
  node_personal_ui["Notes and progress<br/>[notes-panel.tsx]"]
  node_status_ui["System status<br/>[status-panel.tsx]"]
end

subgraph group_lesson["Lesson and materials"]
  node_video["Lesson video<br/>[lesson-video.tsx]"]
  node_transcript_ui["Transcript pane"]
  node_materials_ui["Materials library"]
end

subgraph group_answer["Grounded answers"]
  node_pipeline["Answer pipeline<br/>[pipeline.ts]"]
  node_eligibility["Position eligibility<br/>[predicate.ts]"]
  node_retrieval["Evidence retrieval<br/>[index.ts]"]
  node_providers["Model providers<br/>[providers.ts]"]
end

subgraph group_api["Application APIs"]
  node_video_route["Video endpoint<br/>[route.ts]"]
  node_transcript_route["Transcript endpoint<br/>[route.ts]"]
  node_resources_route["Resource endpoints<br/>[route.ts]"]
  node_questions_route["Question endpoint<br/>[route.ts]"]
  node_health_route["Health endpoints<br/>[route.ts]"]
end

subgraph group_runtime["Runtime and storage"]
  node_server_context["Request context<br/>[context.ts]"]
  node_evidence_store[("Evidence database<br/>[supabase-store.ts]")]
  node_personal_store[("Learner local data<br/>[local-store.ts]")]
end

node_learner(("Learner"))
node_provider_services{{"AI provider services"}}
node_youtube{{"YouTube player"}}
node_supabase[("Supabase")]

node_learner -->|"opens"| node_home
node_learner -->|"studies in"| node_studio
node_home -->|"continues lesson"| node_studio
node_studio -->|"shows player"| node_video
node_studio -->|"shows assistant"| node_assistant
node_studio -->|"shows transcript"| node_transcript_ui
node_studio -->|"shows library"| node_materials_ui
node_studio -->|"shows panels"| node_personal_ui
node_studio -->|"shows status"| node_status_ui
node_assistant -->|"submits question"| node_questions_route
node_questions_route -->|"builds dependencies"| node_server_context
node_questions_route -->|"calls"| node_pipeline
node_pipeline -->|"filters by position"| node_eligibility
node_pipeline -->|"retrieves evidence"| node_retrieval
node_pipeline -->|"generates and verifies"| node_providers
node_providers -.->|"calls models"| node_provider_services
node_retrieval -.->|"reads evidence"| node_evidence_store
node_pipeline -->|"returns cited answer"| node_assistant
node_video -->|"requests local video"| node_video_route
node_video_route -->|"falls back to embed"| node_youtube
node_transcript_ui -->|"requests passages"| node_transcript_route
node_transcript_route -->|"reads eligible captions"| node_retrieval
node_materials_ui -->|"requests resources"| node_resources_route
node_personal_ui -->|"reads and writes"| node_personal_store
node_status_ui -->|"requests health"| node_health_route
node_health_route -.->|"probes database"| node_supabase
node_server_context -->|"creates providers"| node_providers
node_server_context -->|"resolves store"| node_retrieval
node_evidence_store -.->|"queries"| node_supabase

click node_home "https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/home/home-experience.tsx"
click node_studio "https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/learning-studio.tsx"
click node_assistant "https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/lesson/assistant-panel.tsx"
click node_personal_ui "https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/personal/notes-panel.tsx"
click node_status_ui "https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/status/status-panel.tsx"
click node_video "https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/lesson-video.tsx"
click node_transcript_ui "https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/lesson/transcript-panel.tsx"
click node_materials_ui "https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/materials/materials-panel.tsx"
click node_video_route "https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/lesson/video/route.ts"
click node_transcript_route "https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/courses/%5BcourseId%5D/transcript/route.ts"
click node_resources_route "https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/courses/%5BcourseId%5D/resources/route.ts"
click node_questions_route "https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/courses/%5BcourseId%5D/questions/route.ts"
click node_health_route "https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/health/route.ts"
click node_pipeline "https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/answer/pipeline.ts"
click node_eligibility "https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/eligibility/predicate.ts"
click node_retrieval "https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/retrieval/index.ts"
click node_providers "https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/answer/providers.ts"
click node_server_context "https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/server/context.ts"
click node_evidence_store "https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/retrieval/supabase-store.ts"
click node_personal_store "https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/personal/local-store.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_studio,node_assistant,node_personal_ui,node_status_ui toneBlue
class node_video,node_transcript_ui,node_materials_ui,node_supabase toneAmber
class node_pipeline,node_eligibility,node_retrieval,node_providers toneMint
class node_video_route,node_transcript_route,node_resources_route,node_questions_route,node_health_route toneRose
class node_server_context,node_evidence_store,node_personal_store,node_learner,node_provider_services,node_youtube toneIndigo
```

## Components

### Learner experience

- [Home and course entry](https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/home/home-experience.tsx): `src/components/home/home-experience.tsx`
- [Learning studio](https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/learning-studio.tsx): `src/components/learning-studio.tsx`
- [Question assistant](https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/lesson/assistant-panel.tsx): `src/components/lesson/assistant-panel.tsx`
- [Notes and progress](https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/personal/notes-panel.tsx): `src/components/personal/notes-panel.tsx`
- [System status](https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/status/status-panel.tsx): `src/components/status/status-panel.tsx`

### Lesson and materials

- [Lesson video](https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/lesson-video.tsx): `src/components/lesson-video.tsx`
- [Transcript pane](https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/lesson/transcript-panel.tsx): `src/components/lesson/transcript-panel.tsx`
- [Materials library](https://github.com/rudr-automates/horizon-prototype/blob/main/src/components/materials/materials-panel.tsx): `src/components/materials/materials-panel.tsx`

### Grounded answers

- [Answer pipeline](https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/answer/pipeline.ts): `src/lib/answer/pipeline.ts`
- [Position eligibility](https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/eligibility/predicate.ts): `src/lib/eligibility/predicate.ts`
- [Evidence retrieval](https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/retrieval/index.ts): `src/lib/retrieval/index.ts`
- [Model providers](https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/answer/providers.ts): `src/lib/answer/providers.ts`

### Application APIs

- [Video endpoint](https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/lesson/video/route.ts): `src/app/api/v1/lesson/video/route.ts`
- [Transcript endpoint](https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/courses/%5BcourseId%5D/transcript/route.ts): `src/app/api/v1/courses/[courseId]/transcript/route.ts`
- [Resource endpoints](https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/courses/%5BcourseId%5D/resources/route.ts): `src/app/api/v1/courses/[courseId]/resources/route.ts`
- [Question endpoint](https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/courses/%5BcourseId%5D/questions/route.ts): `src/app/api/v1/courses/[courseId]/questions/route.ts`
- [Health endpoints](https://github.com/rudr-automates/horizon-prototype/blob/main/src/app/api/v1/health/route.ts): `src/app/api/v1/health/route.ts`

### Runtime and storage

- [Request context](https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/server/context.ts): `src/lib/server/context.ts`
- [Evidence database](https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/retrieval/supabase-store.ts): `src/lib/retrieval/supabase-store.ts`
- [Learner local data](https://github.com/rudr-automates/horizon-prototype/blob/main/src/lib/personal/local-store.ts): `src/lib/personal/local-store.ts`

### Other components

- **Learner**
- **AI provider services**
- **YouTube player**
- **Supabase**

## Connections

- Learner → Home and course entry: opens
- Learner → Learning studio: studies in
- Home and course entry → Learning studio: continues lesson
- Learning studio → Lesson video: shows player (evidence: `src/components/learning-studio.tsx`)
- Learning studio → Question assistant: shows assistant (evidence: `src/components/learning-studio.tsx`)
- Learning studio → Transcript pane: shows transcript (evidence: `src/components/learning-studio.tsx`)
- Learning studio → Materials library: shows library (evidence: `src/components/learning-studio.tsx`)
- Learning studio → Notes and progress: shows panels (evidence: `src/components/learning-studio.tsx`)
- Learning studio → System status: shows status (evidence: `src/components/learning-studio.tsx`)
- Question assistant → Question endpoint: submits question
- Question endpoint → Request context: builds dependencies (evidence: `src/app/api/v1/courses/[courseId]/questions/route.ts`)
- Question endpoint → Answer pipeline: calls (evidence: `src/app/api/v1/courses/[courseId]/questions/route.ts`)
- Answer pipeline → Position eligibility: filters by position (evidence: `src/lib/answer/pipeline.ts`)
- Answer pipeline → Evidence retrieval: retrieves evidence (evidence: `src/lib/answer/pipeline.ts`)
- Answer pipeline → Model providers: generates and verifies (evidence: `src/lib/answer/pipeline.ts`)
- Model providers → AI provider services: calls models (evidence: `src/lib/answer/providers.ts`)
- Evidence retrieval → Evidence database: reads evidence
- Answer pipeline → Question assistant: returns cited answer
- Lesson video → Video endpoint: requests local video
- Video endpoint → YouTube player: falls back to embed
- Transcript pane → Transcript endpoint: requests passages
- Transcript endpoint → Evidence retrieval: reads eligible captions (evidence: `src/app/api/v1/courses/[courseId]/transcript/route.ts`)
- Materials library → Resource endpoints: requests resources
- Notes and progress → Learner local data: reads and writes
- System status → Health endpoints: requests health
- Health endpoints → Supabase: probes database
- Request context → Model providers: creates providers (evidence: `src/lib/server/context.ts`)
- Request context → Evidence retrieval: resolves store (evidence: `src/lib/server/context.ts`)
- Evidence database → Supabase: queries
