# icyss999/algorithm-visualizer architecture

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

- Interactive diagram: https://gitdiagram.com/icyss999/algorithm-visualizer
- Repository: https://github.com/icyss999/algorithm-visualizer

## Overview

Icyrhythm turns a plain-language algorithm request into stored, stepwise visualization data, then presents it through visual, code, and explanation views. The main flow is grounded in the home client and agent API excerpts; the README documents the broader visualization and learning capabilities. Authenticated history and detail routes are represented from the indexed references. Some UI and route internals were not sampled, so those connections are omitted where the evidence does not establish a call.

Main entry points: [`src/app/api/agent/route.ts`](https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/api/agent/route.ts) (Agent API), [`src/components/web-component/AppSidebar.tsx`](https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/AppSidebar.tsx) (History and navigation), [`src/db/index.ts`](https://github.com/icyss999/algorithm-visualizer/blob/main/src/db/index.ts) (Postgres database), [`src/app/(users)/algorithm/[id]/[section]/page.tsx`](https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/(users)/algorithm/%5Bid%5D/%5Bsection%5D/page.tsx) (Code and explanation routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_request["Request and generation"]
  node_home["Algorithm search<br/>[HomeClient.tsx]"]
  node_agent_api["Agent API<br/>[route.ts]"]
  node_prompt["Prompt builder<br/>[prompt.ts]"]
  node_deepseek["DeepSeek API"]
  node_rate_limit["Rate limiting<br/>[ratelimit.ts]"]
end

subgraph group_experience["Learning experience"]
  node_home_route["Home route<br/>[page.tsx]"]
  node_algorithm_route["Visualization route<br/>[page.tsx]"]
  node_section_route["Code and explanation routes<br/>[page.tsx]"]
  node_visualizer["Step visualizer<br/>[Visualizer.tsx]"]
  node_templates["Visualization templates"]
  node_tree_template["Tree template<br/>[TreeTemplate.tsx]"]
  node_code_view["Code panel<br/>[CodePage.tsx]"]
  node_explanation_view["Explanation panel<br/>[Explaination.tsx]"]
  node_sidebar["History and navigation<br/>[AppSidebar.tsx]"]
end

subgraph group_identity["Identity and persistence"]
  node_auth_pages["Sign-in and sign-up<br/>[page.tsx]"]
  node_auth_client["Auth client<br/>[authClient.ts]"]
  node_auth_service["Auth service<br/>[auth.ts]"]
  node_auth_route["Auth API route<br/>[route.ts]"]
  node_algorithm_detail_api["Algorithm detail API<br/>[route.ts]"]
  node_database[("Postgres database<br/>[index.ts]")]
  node_db_schema["Tables and relations<br/>[schema.ts]"]
end

subgraph group_contracts["Shared contracts"]
  node_contracts["Algorithm and form types<br/>[schema.ts]"]
  node_validator["Agent validator<br/>[validator.ts]"]
end

node_learner(("Learner"))

node_learner -->|"enters request"| node_home
node_home -->|"submits query"| node_agent_api
node_agent_api -->|"checks limit"| node_rate_limit
node_agent_api -->|"looks up and saves"| node_database
node_agent_api -->|"builds prompt"| node_prompt
node_agent_api -->|"requests generation"| node_deepseek
node_home_route -->|"renders"| node_sidebar
node_home_route -->|"renders"| node_home
node_algorithm_route -->|"renders"| node_sidebar
node_algorithm_route -->|"renders"| node_visualizer
node_section_route -->|"renders"| node_sidebar
node_section_route -->|"renders"| node_code_view
node_section_route -->|"renders"| node_explanation_view
node_visualizer -->|"selects template"| node_templates
node_visualizer -->|"renders tree"| node_tree_template
node_auth_pages -->|"uses client"| node_auth_client
node_sidebar -->|"signs out"| node_auth_client
node_auth_route -->|"dispatches auth"| node_auth_service
node_auth_service -->|"uses adapter"| node_database
node_algorithm_detail_api -->|"reads algorithm"| node_database
node_database -->|"loads schema"| node_db_schema
node_db_schema -->|"types steps"| node_contracts
node_validator -->|"validates against"| node_contracts

click node_home "https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/HomeClient.tsx"
click node_agent_api "https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/api/agent/route.ts"
click node_prompt "https://github.com/icyss999/algorithm-visualizer/blob/main/src/agent/prompt.ts"
click node_rate_limit "https://github.com/icyss999/algorithm-visualizer/blob/main/src/lib/ratelimit.ts"
click node_home_route "https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/(users)/home/page.tsx"
click node_algorithm_route "https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/(users)/algorithm/%5Bid%5D/page.tsx"
click node_section_route "https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/(users)/algorithm/%5Bid%5D/%5Bsection%5D/page.tsx"
click node_visualizer "https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/Visualizer.tsx"
click node_templates "https://github.com/icyss999/algorithm-visualizer/tree/main/src/components/templates"
click node_tree_template "https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/templates/TreeTemplate.tsx"
click node_code_view "https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/CodePage.tsx"
click node_explanation_view "https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/Explaination.tsx"
click node_sidebar "https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/AppSidebar.tsx"
click node_auth_pages "https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/(auth)/signin/page.tsx"
click node_auth_client "https://github.com/icyss999/algorithm-visualizer/blob/main/src/lib/authClient.ts"
click node_auth_service "https://github.com/icyss999/algorithm-visualizer/blob/main/src/lib/auth.ts"
click node_auth_route "https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/api/auth/%5B...all%5D/route.ts"
click node_algorithm_detail_api "https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/api/agent/%5Bid%5D/route.ts"
click node_database "https://github.com/icyss999/algorithm-visualizer/blob/main/src/db/index.ts"
click node_db_schema "https://github.com/icyss999/algorithm-visualizer/blob/main/src/db/schema.ts"
click node_contracts "https://github.com/icyss999/algorithm-visualizer/blob/main/src/types/schema.ts"
click node_validator "https://github.com/icyss999/algorithm-visualizer/blob/main/src/agent/validator.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_agent_api,node_prompt,node_deepseek,node_rate_limit toneBlue
class node_home_route,node_algorithm_route,node_section_route,node_visualizer,node_templates,node_tree_template,node_code_view,node_explanation_view,node_sidebar toneAmber
class node_auth_pages,node_auth_client,node_auth_service,node_auth_route,node_algorithm_detail_api,node_database,node_db_schema toneMint
class node_contracts,node_validator toneRose
class node_learner toneIndigo
```

## Components

### Request and generation

- [Algorithm search](https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/HomeClient.tsx): `src/components/web-component/HomeClient.tsx`
- [Agent API](https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/api/agent/route.ts): `src/app/api/agent/route.ts`
- [Prompt builder](https://github.com/icyss999/algorithm-visualizer/blob/main/src/agent/prompt.ts): `src/agent/prompt.ts`
- **DeepSeek API**
- [Rate limiting](https://github.com/icyss999/algorithm-visualizer/blob/main/src/lib/ratelimit.ts): `src/lib/ratelimit.ts`

### Learning experience

- [Home route](https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/(users)/home/page.tsx): `src/app/(users)/home/page.tsx`
- [Visualization route](https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/(users)/algorithm/%5Bid%5D/page.tsx): `src/app/(users)/algorithm/[id]/page.tsx`
- [Code and explanation routes](https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/(users)/algorithm/%5Bid%5D/%5Bsection%5D/page.tsx): `src/app/(users)/algorithm/[id]/[section]/page.tsx`
- [Step visualizer](https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/Visualizer.tsx): `src/components/web-component/Visualizer.tsx`
- [Visualization templates](https://github.com/icyss999/algorithm-visualizer/tree/main/src/components/templates): `src/components/templates`
- [Tree template](https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/templates/TreeTemplate.tsx): `src/components/templates/TreeTemplate.tsx`
- [Code panel](https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/CodePage.tsx): `src/components/web-component/CodePage.tsx`
- [Explanation panel](https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/Explaination.tsx): `src/components/web-component/Explaination.tsx`
- [History and navigation](https://github.com/icyss999/algorithm-visualizer/blob/main/src/components/web-component/AppSidebar.tsx): `src/components/web-component/AppSidebar.tsx`

### Identity and persistence

- [Sign-in and sign-up](https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/(auth)/signin/page.tsx): `src/app/(auth)/signin/page.tsx`
- [Auth client](https://github.com/icyss999/algorithm-visualizer/blob/main/src/lib/authClient.ts): `src/lib/authClient.ts`
- [Auth service](https://github.com/icyss999/algorithm-visualizer/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Auth API route](https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/api/auth/%5B...all%5D/route.ts): `src/app/api/auth/[...all]/route.ts`
- [Algorithm detail API](https://github.com/icyss999/algorithm-visualizer/blob/main/src/app/api/agent/%5Bid%5D/route.ts): `src/app/api/agent/[id]/route.ts`
- [Postgres database](https://github.com/icyss999/algorithm-visualizer/blob/main/src/db/index.ts): `src/db/index.ts`
- [Tables and relations](https://github.com/icyss999/algorithm-visualizer/blob/main/src/db/schema.ts): `src/db/schema.ts`

### Shared contracts

- [Algorithm and form types](https://github.com/icyss999/algorithm-visualizer/blob/main/src/types/schema.ts): `src/types/schema.ts`
- [Agent validator](https://github.com/icyss999/algorithm-visualizer/blob/main/src/agent/validator.ts): `src/agent/validator.ts`

### Other components

- **Learner**

## Connections

- Learner → Algorithm search: enters request (evidence: `src/components/web-component/HomeClient.tsx`)
- Algorithm search → Agent API: submits query (evidence: `src/components/web-component/HomeClient.tsx`)
- Agent API → Rate limiting: checks limit (evidence: `src/app/api/agent/route.ts`)
- Agent API → Postgres database: looks up and saves (evidence: `src/app/api/agent/route.ts`)
- Agent API → Prompt builder: builds prompt (evidence: `src/app/api/agent/route.ts`)
- Agent API → DeepSeek API: requests generation (evidence: `src/app/api/agent/route.ts`)
- Home route → History and navigation: renders (evidence: `src/app/(users)/home/page.tsx`)
- Home route → Algorithm search: renders (evidence: `src/app/(users)/home/page.tsx`)
- Visualization route → History and navigation: renders (evidence: `src/app/(users)/algorithm/[id]/page.tsx`)
- Visualization route → Step visualizer: renders (evidence: `src/app/(users)/algorithm/[id]/page.tsx`)
- Code and explanation routes → History and navigation: renders (evidence: `src/app/(users)/algorithm/[id]/[section]/page.tsx`)
- Code and explanation routes → Code panel: renders (evidence: `src/app/(users)/algorithm/[id]/[section]/page.tsx`)
- Code and explanation routes → Explanation panel: renders (evidence: `src/app/(users)/algorithm/[id]/[section]/page.tsx`)
- Step visualizer → Visualization templates: selects template (evidence: `src/components/web-component/Visualizer.tsx`)
- Step visualizer → Tree template: renders tree (evidence: `src/components/web-component/Visualizer.tsx`)
- Sign-in and sign-up → Auth client: uses client (evidence: `src/app/(auth)/signin/page.tsx`)
- History and navigation → Auth client: signs out (evidence: `src/components/web-component/AppSidebar.tsx`)
- Auth API route → Auth service: dispatches auth (evidence: `src/app/api/auth/[...all]/route.ts`)
- Auth service → Postgres database: uses adapter (evidence: `src/lib/auth.ts`)
- Algorithm detail API → Postgres database: reads algorithm (evidence: `src/app/api/agent/[id]/route.ts`)
- Postgres database → Tables and relations: loads schema (evidence: `src/db/index.ts`)
- Tables and relations → Algorithm and form types: types steps (evidence: `src/db/schema.ts`)
- Agent validator → Algorithm and form types: validates against (evidence: `src/agent/validator.ts`)
