# bobdon/katha architecture

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

- Interactive diagram: https://gitdiagram.com/bobdon/katha
- Repository: https://github.com/bobdon/katha

## Overview

Katha is a bilingual English/Bengali story-reading and authoring application. Readers browse stories and topics, open a story, and can bookmark or react; authors sign in, draft or publish stories, and use AI writing tools. The sampled editor code loads and manages stories through the stories API, which persists them in Cloudflare KV. The tree and excerpts support these workflows, but the README is empty and some client code is unsampled; uncertain wiring is omitted. The Netlify AI function appears to be an alternative deployment endpoint.

Main entry points: [`editor.js`](https://github.com/bobdon/katha/blob/main/editor.js) (Editor workflow), [`app.js`](https://github.com/bobdon/katha/blob/main/app.js) (Reader interactions), [`index.html`](https://github.com/bobdon/katha/blob/main/index.html) (Story site), [`editor.html`](https://github.com/bobdon/katha/blob/main/editor.html) (Editor page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_reader["Story Reading"]
  node_site["Story site<br/>[index.html]"]
  node_reader_ui["Reader interactions<br/>[app.js]"]
  node_story_content["Story content<br/>[index.html]"]
end

subgraph group_editor["Story Authoring"]
  node_editor_page["Editor page<br/>[editor.html]"]
  node_editor_logic["Editor workflow<br/>[editor.js]"]
  node_browser_storage[("Browser storage")]
  node_ai_client["AI tool client<br/>[editor.js]"]
end

subgraph group_services["Application Services"]
  node_stories_api["Stories API<br/>[stories.js]"]
  node_story_kv[("Story KV<br/>[stories.js]")]
  node_cloudflare_ai["Cloudflare AI endpoint<br/>[ai.js]"]
  node_netlify_ai["Netlify AI endpoint<br/>[ai.js]"]
end

subgraph group_integrations["External Integrations"]
  node_auth["Google sign-in<br/>[editor.js]"]
  node_gemini["Gemini API"]
end

node_reader(("Reader"))
node_editor_user(("Author"))

node_reader -->|"opens"| node_site
node_site -->|"loads"| node_reader_ui
node_reader_ui -->|"renders"| node_story_content
node_reader -->|"browses and reacts"| node_reader_ui
node_editor_user -->|"opens"| node_editor_page
node_editor_page -->|"loads"| node_editor_logic
node_editor_logic -->|"initializes sign-in"| node_auth
node_auth -->|"returns identity"| node_editor_logic
node_editor_logic -->|"stores session"| node_browser_storage
node_editor_logic -->|"loads and syncs stories"| node_stories_api
node_stories_api -->|"reads and writes"| node_story_kv
node_editor_logic -->|"invokes AI tools"| node_ai_client
node_ai_client -->|"posts requests"| node_cloudflare_ai
node_cloudflare_ai -->|"generates content"| node_gemini
node_ai_client -.->|"posts requests"| node_netlify_ai
node_netlify_ai -.->|"generates content"| node_gemini

click node_site "https://github.com/bobdon/katha/blob/main/index.html"
click node_reader_ui "https://github.com/bobdon/katha/blob/main/app.js"
click node_story_content "https://github.com/bobdon/katha/blob/main/index.html"
click node_editor_page "https://github.com/bobdon/katha/blob/main/editor.html"
click node_editor_logic "https://github.com/bobdon/katha/blob/main/editor.js"
click node_auth "https://github.com/bobdon/katha/blob/main/editor.js"
click node_stories_api "https://github.com/bobdon/katha/blob/main/functions/api/stories.js"
click node_story_kv "https://github.com/bobdon/katha/blob/main/functions/api/stories.js"
click node_ai_client "https://github.com/bobdon/katha/blob/main/editor.js"
click node_cloudflare_ai "https://github.com/bobdon/katha/blob/main/functions/api/ai.js"
click node_netlify_ai "https://github.com/bobdon/katha/blob/main/netlify/functions/ai.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_site,node_reader_ui,node_story_content toneBlue
class node_editor_page,node_editor_logic,node_browser_storage,node_ai_client toneAmber
class node_stories_api,node_story_kv,node_cloudflare_ai,node_netlify_ai toneMint
class node_auth,node_gemini toneRose
class node_reader,node_editor_user toneIndigo
```

## Components

### Story Reading

- [Story site](https://github.com/bobdon/katha/blob/main/index.html): `index.html`
- [Reader interactions](https://github.com/bobdon/katha/blob/main/app.js): `app.js`
- [Story content](https://github.com/bobdon/katha/blob/main/index.html): `index.html`

### Story Authoring

- [Editor page](https://github.com/bobdon/katha/blob/main/editor.html): `editor.html`
- [Editor workflow](https://github.com/bobdon/katha/blob/main/editor.js): `editor.js`
- **Browser storage**
- [AI tool client](https://github.com/bobdon/katha/blob/main/editor.js): `editor.js`

### Application Services

- [Stories API](https://github.com/bobdon/katha/blob/main/functions/api/stories.js): `functions/api/stories.js`
- [Story KV](https://github.com/bobdon/katha/blob/main/functions/api/stories.js): `functions/api/stories.js`
- [Cloudflare AI endpoint](https://github.com/bobdon/katha/blob/main/functions/api/ai.js): `functions/api/ai.js`
- [Netlify AI endpoint](https://github.com/bobdon/katha/blob/main/netlify/functions/ai.js): `netlify/functions/ai.js`

### External Integrations

- [Google sign-in](https://github.com/bobdon/katha/blob/main/editor.js): `editor.js`
- **Gemini API**

### Other components

- **Reader**
- **Author**

## Connections

- Reader → Story site: opens
- Story site → Reader interactions: loads
- Reader interactions → Story content: renders
- Reader → Reader interactions: browses and reacts
- Author → Editor page: opens
- Editor page → Editor workflow: loads
- Editor workflow → Google sign-in: initializes sign-in
- Google sign-in → Editor workflow: returns identity
- Editor workflow → Browser storage: stores session
- Editor workflow → Stories API: loads and syncs stories
- Stories API → Story KV: reads and writes
- Editor workflow → AI tool client: invokes AI tools
- AI tool client → Cloudflare AI endpoint: posts requests
- Cloudflare AI endpoint → Gemini API: generates content
- AI tool client → Netlify AI endpoint: posts requests
- Netlify AI endpoint → Gemini API: generates content
