# lixiny-code/echo architecture

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

- Interactive diagram: https://gitdiagram.com/lixiny-code/echo
- Repository: https://github.com/lixiny-code/echo
- Video tour (about a minute): https://gitdiagram.com/lixiny-code/echo/video

## Overview

Echo is an AI-companionship and reflection app for students. A user completes optional onboarding, chats with an AI, can inspect its reasoning or compare alternative replies, and may revisit sessions; separate flows support private journaling, weekly insights, reality quests, and a blindspot garden. The frontend API service switches between local mock behavior and backend requests. The backend route excerpts and README support the main API and persistence boundaries; wiring for several unsampled endpoints is therefore shown only at those boundaries.

Main entry points: [`src/services/api.ts`](https://github.com/lixiny-code/echo/blob/main/src/services/api.ts) (API service), [`lib/store.js`](https://github.com/lixiny-code/echo/blob/main/lib/store.js) (Data access), [`src/pages/ChatPage.tsx`](https://github.com/lixiny-code/echo/blob/main/src/pages/ChatPage.tsx) (Chat page), [`lib/prompts.js`](https://github.com/lixiny-code/echo/blob/main/lib/prompts.js) (AI prompts and logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["App experience"]
  node_app["App and routes<br/>[App.tsx]"]
  node_onboarding["Onboarding<br/>[Onboarding.tsx]"]
  node_chat["Chat page<br/>[ChatPage.tsx]"]
  node_journalpage["Journal page<br/>[JournalPage.tsx]"]
  node_insightspage["Insights page<br/>[InsightsPage.tsx]"]
  node_corner["Corner page<br/>[CornerPage.tsx]"]
  node_api_client["API service<br/>[api.ts]"]
end

subgraph group_reflection["Reflection features"]
  node_chatui["Chat panels"]
  node_garden["Blindspot garden"]
end

subgraph group_backend["Backend API"]
  node_chat_api["Chat endpoint<br/>[chat.js]"]
  node_lab_api["Conversation Lab<br/>[lab.js]"]
  node_sessions_api["Sessions and analysis<br/>[sessions.js]"]
  node_journal_api["Journal endpoint<br/>[journal.js]"]
  node_insights_api["Insights endpoint<br/>[insights.js]"]
  node_quest_api["Quest completion<br/>[complete.js]"]
  node_blindspot_api["Blindspot endpoints<br/>[&#91;action&#93;.js]"]
  node_glimmer_api["Glimmer endpoints<br/>[&#91;action&#93;.js]"]
end

subgraph group_services["AI and persistence"]
  node_ai_logic["AI prompts and logic<br/>[prompts.js]"]
  node_store["Data access<br/>[store.js]"]
  node_supabase["Supabase client<br/>[supabase.js]"]
end

node_user(("Student"))
node_deepseek{{"DeepSeek"}}
node_database[("Supabase data")]

node_user -->|"opens"| node_app
node_app -->|"shows first"| node_onboarding
node_onboarding -->|"saves profile"| node_api_client
node_app -->|"routes to"| node_chat
node_chat -->|"renders"| node_chatui
node_chat -->|"requests chat"| node_api_client
node_chat -->|"requests lab"| node_api_client
node_chat -->|"manages sessions"| node_api_client
node_user -->|"writes"| node_journalpage
node_journalpage -->|"loads and saves"| node_api_client
node_user -->|"views"| node_insightspage
node_insightspage -->|"requests report"| node_api_client
node_user -->|"tracks progress"| node_corner
node_corner -->|"loads quests"| node_api_client
node_user -->|"tends"| node_garden
node_garden -->|"manages seeds"| node_api_client
node_api_client -->|"calls"| node_chat_api
node_api_client -->|"calls"| node_lab_api
node_api_client -->|"calls"| node_sessions_api
node_api_client -->|"calls"| node_journal_api
node_api_client -->|"calls"| node_insights_api
node_api_client -->|"calls"| node_quest_api
node_api_client -->|"calls"| node_blindspot_api
node_api_client -->|"calls"| node_glimmer_api
node_chat_api -->|"uses prompts"| node_ai_logic
node_lab_api -->|"uses prompts"| node_ai_logic
node_sessions_api -->|"generates analysis"| node_ai_logic
node_ai_logic -->|"requests generation"| node_deepseek
node_chat_api -->|"reads and writes"| node_store
node_sessions_api -->|"reads and writes"| node_store
node_journal_api -->|"reads and writes"| node_store
node_insights_api -->|"reads"| node_store
node_quest_api -->|"records completion"| node_store
node_blindspot_api -->|"reads and writes"| node_store
node_glimmer_api -->|"reads and writes"| node_store
node_store -->|"uses client"| node_supabase
node_supabase -->|"queries"| node_database

click node_app "https://github.com/lixiny-code/echo/blob/main/src/App.tsx"
click node_onboarding "https://github.com/lixiny-code/echo/blob/main/src/components/Onboarding.tsx"
click node_chat "https://github.com/lixiny-code/echo/blob/main/src/pages/ChatPage.tsx"
click node_chatui "https://github.com/lixiny-code/echo/tree/main/src/features/chat"
click node_journalpage "https://github.com/lixiny-code/echo/blob/main/src/pages/JournalPage.tsx"
click node_insightspage "https://github.com/lixiny-code/echo/blob/main/src/pages/InsightsPage.tsx"
click node_corner "https://github.com/lixiny-code/echo/blob/main/src/pages/CornerPage.tsx"
click node_garden "https://github.com/lixiny-code/echo/blob/main/src/pages/BlindspotGardenPage.tsx"
click node_api_client "https://github.com/lixiny-code/echo/blob/main/src/services/api.ts"
click node_chat_api "https://github.com/lixiny-code/echo/blob/main/api/chat.js"
click node_lab_api "https://github.com/lixiny-code/echo/blob/main/api/lab.js"
click node_sessions_api "https://github.com/lixiny-code/echo/blob/main/api/sessions.js"
click node_journal_api "https://github.com/lixiny-code/echo/blob/main/api/journal.js"
click node_insights_api "https://github.com/lixiny-code/echo/blob/main/api/insights.js"
click node_quest_api "https://github.com/lixiny-code/echo/blob/main/api/quest/complete.js"
click node_blindspot_api "https://github.com/lixiny-code/echo/blob/main/api/blindspot/%5Baction%5D.js"
click node_glimmer_api "https://github.com/lixiny-code/echo/blob/main/api/glimmer/%5Baction%5D.js"
click node_ai_logic "https://github.com/lixiny-code/echo/blob/main/lib/prompts.js"
click node_store "https://github.com/lixiny-code/echo/blob/main/lib/store.js"
click node_supabase "https://github.com/lixiny-code/echo/blob/main/lib/supabase.js"

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_app,node_onboarding,node_chat,node_journalpage,node_insightspage,node_corner,node_api_client toneBlue
class node_chatui,node_garden,node_database toneAmber
class node_chat_api,node_lab_api,node_sessions_api,node_journal_api,node_insights_api,node_quest_api,node_blindspot_api,node_glimmer_api toneMint
class node_ai_logic,node_store,node_supabase toneRose
class node_user,node_deepseek toneIndigo
```

## Components

### App experience

- [App and routes](https://github.com/lixiny-code/echo/blob/main/src/App.tsx): `src/App.tsx`
- [Onboarding](https://github.com/lixiny-code/echo/blob/main/src/components/Onboarding.tsx): `src/components/Onboarding.tsx`
- [Chat page](https://github.com/lixiny-code/echo/blob/main/src/pages/ChatPage.tsx): `src/pages/ChatPage.tsx`
- [Journal page](https://github.com/lixiny-code/echo/blob/main/src/pages/JournalPage.tsx): `src/pages/JournalPage.tsx`
- [Insights page](https://github.com/lixiny-code/echo/blob/main/src/pages/InsightsPage.tsx): `src/pages/InsightsPage.tsx`
- [Corner page](https://github.com/lixiny-code/echo/blob/main/src/pages/CornerPage.tsx): `src/pages/CornerPage.tsx`
- [API service](https://github.com/lixiny-code/echo/blob/main/src/services/api.ts): `src/services/api.ts`

### Reflection features

- [Chat panels](https://github.com/lixiny-code/echo/tree/main/src/features/chat): `src/features/chat`
- [Blindspot garden](https://github.com/lixiny-code/echo/blob/main/src/pages/BlindspotGardenPage.tsx): `src/pages/BlindspotGardenPage.tsx`

### Backend API

- [Chat endpoint](https://github.com/lixiny-code/echo/blob/main/api/chat.js): `api/chat.js`
- [Conversation Lab](https://github.com/lixiny-code/echo/blob/main/api/lab.js): `api/lab.js`
- [Sessions and analysis](https://github.com/lixiny-code/echo/blob/main/api/sessions.js): `api/sessions.js`
- [Journal endpoint](https://github.com/lixiny-code/echo/blob/main/api/journal.js): `api/journal.js`
- [Insights endpoint](https://github.com/lixiny-code/echo/blob/main/api/insights.js): `api/insights.js`
- [Quest completion](https://github.com/lixiny-code/echo/blob/main/api/quest/complete.js): `api/quest/complete.js`
- [Blindspot endpoints](https://github.com/lixiny-code/echo/blob/main/api/blindspot/%5Baction%5D.js): `api/blindspot/[action].js`
- [Glimmer endpoints](https://github.com/lixiny-code/echo/blob/main/api/glimmer/%5Baction%5D.js): `api/glimmer/[action].js`

### AI and persistence

- [AI prompts and logic](https://github.com/lixiny-code/echo/blob/main/lib/prompts.js): `lib/prompts.js`
- [Data access](https://github.com/lixiny-code/echo/blob/main/lib/store.js): `lib/store.js`
- [Supabase client](https://github.com/lixiny-code/echo/blob/main/lib/supabase.js): `lib/supabase.js`

### Other components

- **Student**
- **DeepSeek**
- **Supabase data**

## Connections

- Student → App and routes: opens
- App and routes → Onboarding: shows first
- Onboarding → API service: saves profile
- App and routes → Chat page: routes to
- Chat page → Chat panels: renders
- Chat page → API service: requests chat
- Chat page → API service: requests lab
- Chat page → API service: manages sessions
- Student → Journal page: writes
- Journal page → API service: loads and saves
- Student → Insights page: views
- Insights page → API service: requests report
- Student → Corner page: tracks progress
- Corner page → API service: loads quests
- Student → Blindspot garden: tends
- Blindspot garden → API service: manages seeds
- API service → Chat endpoint: calls
- API service → Conversation Lab: calls
- API service → Sessions and analysis: calls
- API service → Journal endpoint: calls
- API service → Insights endpoint: calls
- API service → Quest completion: calls
- API service → Blindspot endpoints: calls
- API service → Glimmer endpoints: calls
- Chat endpoint → AI prompts and logic: uses prompts
- Conversation Lab → AI prompts and logic: uses prompts
- Sessions and analysis → AI prompts and logic: generates analysis
- AI prompts and logic → DeepSeek: requests generation
- Chat endpoint → Data access: reads and writes
- Sessions and analysis → Data access: reads and writes
- Journal endpoint → Data access: reads and writes
- Insights endpoint → Data access: reads
- Quest completion → Data access: records completion
- Blindspot endpoints → Data access: reads and writes
- Glimmer endpoints → Data access: reads and writes
- Data access → Supabase client: uses client
- Supabase client → Supabase data: queries
