# viha0509/learninghub architecture

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

- Interactive diagram: https://gitdiagram.com/viha0509/learninghub
- Repository: https://github.com/viha0509/learninghub

## Overview

Learning Hub is a personal learning web app: users organize imported research notes on role-based roadmaps, read or draft topic lessons, and ask an AI agent about their own material. The graph preserves the documented authentication, provider configuration, Knowledge Hub connection, news, practice, and data-transfer capabilities. Several feature modules are unsampled, so their internal call relationships are not asserted; edges use README statements or indexed source references where available.

Main entry points: [`backend/app/agent/tools.py`](https://github.com/viha0509/learninghub/blob/main/backend/app/agent/tools.py) (Learning tools), [`backend/app/routes/agent.py`](https://github.com/viha0509/learninghub/blob/main/backend/app/routes/agent.py) (Agent chat), [`backend/app/data_sync/backup.py`](https://github.com/viha0509/learninghub/blob/main/backend/app/data_sync/backup.py) (Backup and sync), [`backend/app/roadmaps.py`](https://github.com/viha0509/learninghub/blob/main/backend/app/roadmaps.py) (Role roadmaps)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_web_app["Web app<br/>[App.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_learning["Learning content"]
  node_roadmaps["Role roadmaps<br/>[roadmaps.py]"]
  node_topic_catalog["Topic catalog<br/>[topics.py]"]
  node_note_import["Research note import<br/>[notes.py]"]
  node_resource_sync["Reference sync<br/>[fetch.py]"]
  node_lesson_pages["Lessons<br/>[lessons.py]"]
  node_practice["Practice exams<br/>[practice.py]"]
  node_news["AI news<br/>[refresh.py]"]
end

subgraph group_assistant["AI assistant"]
  node_agent_routes["Agent chat<br/>[agent.py]"]
  node_agent_tools["Learning tools<br/>[tools.py]"]
  node_provider_factory["Model providers<br/>[factory.py]"]
  node_claude_code["Claude Code agent<br/>[claude_code.py]"]
end

subgraph group_identity["Identity and integrations"]
  node_auth_flow["Sign-in and accounts<br/>[auth.py]"]
  node_session_store[("Sessions and users<br/>[sessions.py]")]
  node_kh_connector["Knowledge Hub sign-in<br/>[service.py]"]
end

subgraph group_platform["Data and operations"]
  node_backend["Backend API<br/>[main.py]"]
  node_db[("Application database<br/>[db.py]")]
  node_file_storage[("File storage<br/>[storage.py]")]
  node_data_sync["Backup and sync<br/>[backup.py]"]
end

node_learner(("Learner"))

node_learner -->|"uses"| node_web_app
node_web_app -->|"requests data"| node_api_client
node_api_client -->|"calls API"| node_backend
node_backend -.->|"serves routes"| node_auth_flow
node_auth_flow -->|"manages sessions"| node_session_store
node_learner -->|"organizes learning"| node_roadmaps
node_roadmaps -->|"defines topics"| node_topic_catalog
node_learner -->|"imports research"| node_note_import
node_learner -->|"reads and drafts"| node_lesson_pages
node_learner -->|"practices"| node_practice
node_learner -.->|"reads news"| node_news
node_learner -.->|"syncs references"| node_resource_sync
node_learner -->|"chats with"| node_agent_routes
node_agent_routes -.->|"dispatches tools"| node_agent_tools
node_agent_tools -->|"reads roadmaps"| node_roadmaps
node_agent_tools -->|"reads topics"| node_topic_catalog
node_agent_routes -.->|"selects model"| node_provider_factory
node_provider_factory -->|"creates agent"| node_claude_code
node_agent_tools -->|"stores notes"| node_file_storage
node_agent_tools -->|"reads and writes"| node_db
node_learner -->|"connects account"| node_kh_connector
node_learner -->|"backs up data"| node_data_sync
node_data_sync -->|"backs up records"| node_db
node_data_sync -->|"backs up files"| node_file_storage

click node_web_app "https://github.com/viha0509/learninghub/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/viha0509/learninghub/blob/main/frontend/src/api.ts"
click node_backend "https://github.com/viha0509/learninghub/blob/main/backend/app/main.py"
click node_auth_flow "https://github.com/viha0509/learninghub/blob/main/backend/app/routes/auth.py"
click node_session_store "https://github.com/viha0509/learninghub/blob/main/backend/app/auth/sessions.py"
click node_roadmaps "https://github.com/viha0509/learninghub/blob/main/backend/app/roadmaps.py"
click node_topic_catalog "https://github.com/viha0509/learninghub/blob/main/backend/app/learning/topics.py"
click node_note_import "https://github.com/viha0509/learninghub/blob/main/backend/app/routes/notes.py"
click node_resource_sync "https://github.com/viha0509/learninghub/blob/main/backend/app/resources/fetch.py"
click node_lesson_pages "https://github.com/viha0509/learninghub/blob/main/backend/app/routes/lessons.py"
click node_practice "https://github.com/viha0509/learninghub/blob/main/backend/app/routes/practice.py"
click node_news "https://github.com/viha0509/learninghub/blob/main/backend/app/news/refresh.py"
click node_agent_routes "https://github.com/viha0509/learninghub/blob/main/backend/app/routes/agent.py"
click node_agent_tools "https://github.com/viha0509/learninghub/blob/main/backend/app/agent/tools.py"
click node_provider_factory "https://github.com/viha0509/learninghub/blob/main/backend/app/agent/llm/factory.py"
click node_claude_code "https://github.com/viha0509/learninghub/blob/main/backend/app/agent/llm/claude_code.py"
click node_kh_connector "https://github.com/viha0509/learninghub/blob/main/backend/app/kh/service.py"
click node_db "https://github.com/viha0509/learninghub/blob/main/backend/app/db.py"
click node_file_storage "https://github.com/viha0509/learninghub/blob/main/backend/app/storage.py"
click node_data_sync "https://github.com/viha0509/learninghub/blob/main/backend/app/data_sync/backup.py"

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_web_app,node_api_client toneBlue
class node_roadmaps,node_topic_catalog,node_note_import,node_resource_sync,node_lesson_pages,node_practice,node_news toneAmber
class node_agent_routes,node_agent_tools,node_provider_factory,node_claude_code toneMint
class node_auth_flow,node_session_store,node_kh_connector toneRose
class node_backend,node_db,node_file_storage,node_data_sync,node_learner toneIndigo
```

## Components

### Web experience

- [Web app](https://github.com/viha0509/learninghub/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/viha0509/learninghub/blob/main/frontend/src/api.ts): `frontend/src/api.ts`

### Learning content

- [Role roadmaps](https://github.com/viha0509/learninghub/blob/main/backend/app/roadmaps.py): `backend/app/roadmaps.py`
- [Topic catalog](https://github.com/viha0509/learninghub/blob/main/backend/app/learning/topics.py): `backend/app/learning/topics.py`
- [Research note import](https://github.com/viha0509/learninghub/blob/main/backend/app/routes/notes.py): `backend/app/routes/notes.py`
- [Reference sync](https://github.com/viha0509/learninghub/blob/main/backend/app/resources/fetch.py): `backend/app/resources/fetch.py`
- [Lessons](https://github.com/viha0509/learninghub/blob/main/backend/app/routes/lessons.py): `backend/app/routes/lessons.py`
- [Practice exams](https://github.com/viha0509/learninghub/blob/main/backend/app/routes/practice.py): `backend/app/routes/practice.py`
- [AI news](https://github.com/viha0509/learninghub/blob/main/backend/app/news/refresh.py): `backend/app/news/refresh.py`

### AI assistant

- [Agent chat](https://github.com/viha0509/learninghub/blob/main/backend/app/routes/agent.py): `backend/app/routes/agent.py`
- [Learning tools](https://github.com/viha0509/learninghub/blob/main/backend/app/agent/tools.py): `backend/app/agent/tools.py`
- [Model providers](https://github.com/viha0509/learninghub/blob/main/backend/app/agent/llm/factory.py): `backend/app/agent/llm/factory.py`
- [Claude Code agent](https://github.com/viha0509/learninghub/blob/main/backend/app/agent/llm/claude_code.py): `backend/app/agent/llm/claude_code.py`

### Identity and integrations

- [Sign-in and accounts](https://github.com/viha0509/learninghub/blob/main/backend/app/routes/auth.py): `backend/app/routes/auth.py`
- [Sessions and users](https://github.com/viha0509/learninghub/blob/main/backend/app/auth/sessions.py): `backend/app/auth/sessions.py`
- [Knowledge Hub sign-in](https://github.com/viha0509/learninghub/blob/main/backend/app/kh/service.py): `backend/app/kh/service.py`

### Data and operations

- [Backend API](https://github.com/viha0509/learninghub/blob/main/backend/app/main.py): `backend/app/main.py`
- [Application database](https://github.com/viha0509/learninghub/blob/main/backend/app/db.py): `backend/app/db.py`
- [File storage](https://github.com/viha0509/learninghub/blob/main/backend/app/storage.py): `backend/app/storage.py`
- [Backup and sync](https://github.com/viha0509/learninghub/blob/main/backend/app/data_sync/backup.py): `backend/app/data_sync/backup.py`

### Other components

- **Learner**

## Connections

- Learner → Web app: uses (evidence: `README.md`)
- Web app → API client: requests data (evidence: `frontend/src/App.tsx`)
- API client → Backend API: calls API (evidence: `README.md`)
- Backend API → Sign-in and accounts: serves routes (evidence: `backend/app/main.py`)
- Sign-in and accounts → Sessions and users: manages sessions (evidence: `backend/app/routes/auth.py`)
- Learner → Role roadmaps: organizes learning (evidence: `README.md`)
- Role roadmaps → Topic catalog: defines topics (evidence: `backend/app/learning/topics.py`)
- Learner → Research note import: imports research (evidence: `README.md`)
- Learner → Lessons: reads and drafts (evidence: `README.md`)
- Learner → Practice exams: practices (evidence: `README.md`)
- Learner → AI news: reads news
- Learner → Reference sync: syncs references
- Learner → Agent chat: chats with (evidence: `README.md`)
- Agent chat → Learning tools: dispatches tools
- Learning tools → Role roadmaps: reads roadmaps (evidence: `backend/app/agent/tools.py`)
- Learning tools → Topic catalog: reads topics (evidence: `backend/app/agent/tools.py`)
- Agent chat → Model providers: selects model
- Model providers → Claude Code agent: creates agent (evidence: `backend/app/agent/llm/factory.py`)
- Learning tools → File storage: stores notes (evidence: `backend/app/agent/tools.py`)
- Learning tools → Application database: reads and writes (evidence: `backend/app/agent/tools.py`)
- Learner → Knowledge Hub sign-in: connects account (evidence: `README.md`)
- Learner → Backup and sync: backs up data (evidence: `README.md`)
- Backup and sync → Application database: backs up records (evidence: `backend/app/data_sync/backup.py`)
- Backup and sync → File storage: backs up files (evidence: `backend/app/data_sync/backup.py`)
