# shivatarunkumar/knowhub architecture

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

- Interactive diagram: https://gitdiagram.com/shivatarunkumar/knowhub
- Repository: https://github.com/shivatarunkumar/knowhub

## Overview

KnowHub is an internal video knowledge-sharing platform. Users browse topics and channels, watch videos, and engage through reactions and comments; signed-in users can upload and manage videos, attach resources, and use AI writing assistance. The web app communicates with a FastAPI API, which routes requests to domain services and adapters backed by Postgres and object storage. The README documents audit events and product capabilities; several implementation details were not sampled, so those relationships are shown only where documented or marked unverified.

Main entry points: [`backend/app/api/v1/router.py`](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/router.py) (API router), [`backend/app/api/v1/videos.py`](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/videos.py) (Video endpoints), [`backend/app/main.py`](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/main.py) (FastAPI application), [`backend/app/models`](https://github.com/shivatarunkumar/knowhub/tree/master/backend/app/models) (Domain records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["KnowHub web app"]
  node_webapi["Web API client<br/>[api.ts]"]
  node_uploadui["Upload workflow<br/>[UploadForm.tsx]"]
  node_watchui["Watch experience<br/>[page.tsx]"]
  node_manageui["Channel management"]
  node_engageui["Comments and sharing<br/>[Comments.tsx]"]
  node_aiui["AI writing assist<br/>[AiAssist.tsx]"]
end

subgraph group_api["API and domain"]
  node_apiapp["FastAPI application<br/>[main.py]"]
  node_routes["API router<br/>[router.py]"]
  node_authroutes["Authentication endpoints<br/>[auth.py]"]
  node_videoroutes["Video endpoints<br/>[videos.py]"]
  node_engageroutes["Engagement endpoints<br/>[engagement.py]"]
  node_topicsroutes["Topic and channel endpoints<br/>[topics.py]"]
  node_aiservice["AI assistance<br/>[ai_assist.py]"]
  node_authservice["Account and session service<br/>[auth.py]"]
  node_videoservice["Video domain service<br/>[video.py]"]
  node_engageservice["Engagement service<br/>[engagement.py]"]
  node_audit["Upload change audit"]
end

subgraph group_data["Persistence and media"]
  node_storageadapter["Object storage adapter<br/>[storage.py]"]
  node_db["Database session layer<br/>[db.py]"]
  node_models["Domain records"]
end

subgraph group_integrations["External services"]
  node_postgres[("PostgreSQL")]
  node_objectstore[("GCS or emulator")]
  node_llm["Configured AI provider"]
end

node_viewer(("Viewer or creator"))

node_viewer -->|"browses and manages"| node_webapp
node_webapp -.->|"requests data"| node_webapi
node_webapi -.->|"calls API"| node_apiapp
node_apiapp -->|"mounts routes"| node_routes
node_routes -->|"registers"| node_authroutes
node_routes -->|"registers"| node_videoroutes
node_routes -->|"registers"| node_engageroutes
node_routes -->|"registers"| node_topicsroutes
node_authroutes -->|"delegates"| node_authservice
node_videoroutes -->|"uses service"| node_videoservice
node_engageroutes -->|"delegates"| node_engageservice
node_authservice -->|"updates accounts"| node_models
node_videoservice -.->|"manages video data"| node_models
node_engageservice -.->|"stores engagement"| node_models
node_apiapp -->|"opens database engine"| node_db
node_db -->|"connects"| node_postgres
node_videoroutes -->|"uploads and streams"| node_storageadapter
node_storageadapter -->|"reads and writes objects"| node_objectstore
node_uploadui -->|"uploads chunks directly"| node_objectstore
node_watchui -->|"plays ranged media"| node_objectstore
node_aiui -.->|"requests rewrite"| node_aiservice
node_aiservice -.->|"generates suggestions"| node_llm
node_viewer -->|"uploads video"| node_uploadui
node_viewer -->|"watches video"| node_watchui
node_viewer -->|"comments and reacts"| node_engageui
node_viewer -->|"edits channel videos"| node_manageui
node_videoroutes -.->|"records changes"| node_audit

click node_webapp "https://github.com/shivatarunkumar/knowhub/tree/master/frontend/app"
click node_webapi "https://github.com/shivatarunkumar/knowhub/blob/master/frontend/lib/api.ts"
click node_uploadui "https://github.com/shivatarunkumar/knowhub/blob/master/frontend/components/UploadForm.tsx"
click node_watchui "https://github.com/shivatarunkumar/knowhub/blob/master/frontend/app/watch/%5Bid%5D/page.tsx"
click node_manageui "https://github.com/shivatarunkumar/knowhub/blob/master/frontend/components/VideoManageDialog.tsx"
click node_engageui "https://github.com/shivatarunkumar/knowhub/blob/master/frontend/components/Comments.tsx"
click node_aiui "https://github.com/shivatarunkumar/knowhub/blob/master/frontend/components/AiAssist.tsx"
click node_apiapp "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/main.py"
click node_routes "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/router.py"
click node_authroutes "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/auth.py"
click node_videoroutes "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/videos.py"
click node_engageroutes "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/engagement.py"
click node_topicsroutes "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/topics.py"
click node_aiservice "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/services/ai_assist.py"
click node_authservice "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/services/auth.py"
click node_videoservice "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/services/video.py"
click node_engageservice "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/services/engagement.py"
click node_storageadapter "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/adapters/storage.py"
click node_db "https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/core/db.py"
click node_models "https://github.com/shivatarunkumar/knowhub/tree/master/backend/app/models"
click node_audit "https://github.com/shivatarunkumar/knowhub/tree/master/backend/app"

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_webapp,node_webapi,node_uploadui,node_watchui,node_manageui,node_engageui,node_aiui,node_viewer toneBlue
class node_apiapp,node_routes,node_authroutes,node_videoroutes,node_engageroutes,node_topicsroutes,node_aiservice,node_authservice,node_videoservice,node_engageservice,node_audit toneAmber
class node_storageadapter,node_db,node_models toneMint
class node_postgres,node_objectstore,node_llm toneRose
```

## Components

### Web experience

- [KnowHub web app](https://github.com/shivatarunkumar/knowhub/tree/master/frontend/app): `frontend/app`
- [Web API client](https://github.com/shivatarunkumar/knowhub/blob/master/frontend/lib/api.ts): `frontend/lib/api.ts`
- [Upload workflow](https://github.com/shivatarunkumar/knowhub/blob/master/frontend/components/UploadForm.tsx): `frontend/components/UploadForm.tsx`
- [Watch experience](https://github.com/shivatarunkumar/knowhub/blob/master/frontend/app/watch/%5Bid%5D/page.tsx): `frontend/app/watch/[id]/page.tsx`
- [Channel management](https://github.com/shivatarunkumar/knowhub/blob/master/frontend/components/VideoManageDialog.tsx): `frontend/components/VideoManageDialog.tsx`
- [Comments and sharing](https://github.com/shivatarunkumar/knowhub/blob/master/frontend/components/Comments.tsx): `frontend/components/Comments.tsx`
- [AI writing assist](https://github.com/shivatarunkumar/knowhub/blob/master/frontend/components/AiAssist.tsx): `frontend/components/AiAssist.tsx`

### API and domain

- [FastAPI application](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/main.py): `backend/app/main.py`
- [API router](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`
- [Authentication endpoints](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/auth.py): `backend/app/api/v1/auth.py`
- [Video endpoints](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/videos.py): `backend/app/api/v1/videos.py`
- [Engagement endpoints](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/engagement.py): `backend/app/api/v1/engagement.py`
- [Topic and channel endpoints](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/api/v1/topics.py): `backend/app/api/v1/topics.py`
- [AI assistance](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/services/ai_assist.py): `backend/app/services/ai_assist.py`
- [Account and session service](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/services/auth.py): `backend/app/services/auth.py`
- [Video domain service](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/services/video.py): `backend/app/services/video.py`
- [Engagement service](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/services/engagement.py): `backend/app/services/engagement.py`
- [Upload change audit](https://github.com/shivatarunkumar/knowhub/tree/master/backend/app): `backend/app`

### Persistence and media

- [Object storage adapter](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/adapters/storage.py): `backend/app/adapters/storage.py`
- [Database session layer](https://github.com/shivatarunkumar/knowhub/blob/master/backend/app/core/db.py): `backend/app/core/db.py`
- [Domain records](https://github.com/shivatarunkumar/knowhub/tree/master/backend/app/models): `backend/app/models`

### External services

- **PostgreSQL**
- **GCS or emulator**
- **Configured AI provider**

### Other components

- **Viewer or creator**

## Connections

- Viewer or creator → KnowHub web app: browses and manages (evidence: `README.md`)
- KnowHub web app → Web API client: requests data
- Web API client → FastAPI application: calls API
- FastAPI application → API router: mounts routes (evidence: `backend/app/main.py`)
- API router → Authentication endpoints: registers (evidence: `backend/app/api/v1/router.py`)
- API router → Video endpoints: registers (evidence: `backend/app/api/v1/router.py`)
- API router → Engagement endpoints: registers (evidence: `backend/app/api/v1/router.py`)
- API router → Topic and channel endpoints: registers (evidence: `backend/app/api/v1/router.py`)
- Authentication endpoints → Account and session service: delegates (evidence: `backend/app/api/v1/auth.py`)
- Video endpoints → Video domain service: uses service (evidence: `backend/app/api/v1/videos.py`)
- Engagement endpoints → Engagement service: delegates (evidence: `backend/app/api/v1/engagement.py`)
- Account and session service → Domain records: updates accounts (evidence: `backend/app/services/auth.py`)
- Video domain service → Domain records: manages video data
- Engagement service → Domain records: stores engagement
- FastAPI application → Database session layer: opens database engine (evidence: `backend/app/main.py`)
- Database session layer → PostgreSQL: connects (evidence: `backend/app/core/db.py`)
- Video endpoints → Object storage adapter: uploads and streams (evidence: `backend/app/api/v1/videos.py`)
- Object storage adapter → GCS or emulator: reads and writes objects (evidence: `backend/app/adapters/storage.py`)
- Upload workflow → GCS or emulator: uploads chunks directly (evidence: `README.md`)
- Watch experience → GCS or emulator: plays ranged media (evidence: `README.md`)
- AI writing assist → AI assistance: requests rewrite
- AI assistance → Configured AI provider: generates suggestions
- Viewer or creator → Upload workflow: uploads video (evidence: `README.md`)
- Viewer or creator → Watch experience: watches video (evidence: `README.md`)
- Viewer or creator → Comments and sharing: comments and reacts (evidence: `README.md`)
- Viewer or creator → Channel management: edits channel videos (evidence: `README.md`)
- Video endpoints → Upload change audit: records changes (evidence: `backend/app/api/v1/videos.py`)
