# devsecobie/cyberjudah-telegram architecture

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

- Interactive diagram: https://gitdiagram.com/devsecobie/cyberjudah-telegram
- Repository: https://github.com/devsecobie/cyberjudah-telegram

## Overview

CyberJudah for Telegram combines a React Mini App with a Cloudflare Worker bot/API. Readers enter through the app, search teachings or read the Bible, and open results in their source; Ask retrieves library material and streams cited answers. Separate branches cover recordings, account sync, billing, and admin note editing. The README documents most product flows; source excerpts confirm app routing/bootstrap and webhook/API wiring, but much bot and feature implementation was not sampled.

Main entry points: [`bot/src/index.ts`](https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/index.ts) (Worker routes), [`app/src/App.tsx`](https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/App.tsx) (App router), [`bot/src/agent.ts`](https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/agent.ts) (Ask retrieval and agent), [`app/src/screens/Search.tsx`](https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/screens/Search.tsx) (Teaching search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Telegram Mini App"]
  node_app["App router<br/>[App.tsx]"]
  node_tg["Telegram bridge<br/>[sdk.ts]"]
  node_personal[("Personal store<br/>[store.ts]")]
end

subgraph group_library["Library Experience"]
  node_searchui["Teaching search<br/>[Search.tsx]"]
  node_bibleui["Bible reader<br/>[BibleTab.tsx]"]
  node_askui["Ask interface<br/>[Ask.tsx]"]
  node_adminui["Note editor<br/>[ResourceAdmin.tsx]"]
end

subgraph group_worker["Worker API"]
  node_worker["Worker routes<br/>[index.ts]"]
  node_searchapi["Teaching search API<br/>[teachings.ts]"]
  node_ask["Ask retrieval and agent<br/>[agent.ts]"]
  node_billing["Ask billing<br/>[credits.ts]"]
  node_cms["Repository note edits<br/>[cms-github.ts]"]
end

subgraph group_services["Data and Integrations"]
  node_siteindex[("Teaching corpus")]
  node_vectors[("Vectorize index")]
  node_models{{"AI models"}}
  node_telegram{{"Telegram platform"}}
  node_github["CyberJudah repository"]
end

node_reader(("Reader"))

node_reader -->|"opens"| node_app
node_app -->|"boots through"| node_tg
node_app -->|"routes to"| node_searchui
node_app -.->|"routes to"| node_bibleui
node_app -->|"routes to"| node_askui
node_app -.->|"provides editing"| node_adminui
node_searchui -->|"requests results"| node_worker
node_worker -->|"dispatches search"| node_searchapi
node_searchapi -->|"queries passages"| node_siteindex
node_searchui -->|"opens reference"| node_bibleui
node_askui -->|"calls Ask API"| node_worker
node_worker -.->|"dispatches Ask"| node_ask
node_ask -->|"retrieves passages"| node_siteindex
node_ask -->|"retrieves by meaning"| node_vectors
node_ask -->|"generates answer"| node_models
node_worker -.->|"accounts charges"| node_billing
node_billing -->|"sells Stars top-ups"| node_telegram
node_adminui -->|"submits edits"| node_worker
node_worker -->|"dispatches edit"| node_cms
node_cms -->|"commits note"| node_github
node_tg -->|"stores account data"| node_personal
node_worker -->|"handles bot updates"| node_telegram

click node_app "https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/App.tsx"
click node_tg "https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/tg/sdk.ts"
click node_personal "https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/tg/store.ts"
click node_searchui "https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/screens/Search.tsx"
click node_bibleui "https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/bible/BibleTab.tsx"
click node_askui "https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/screens/Ask.tsx"
click node_adminui "https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/admin/ResourceAdmin.tsx"
click node_worker "https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/index.ts"
click node_searchapi "https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/teachings.ts"
click node_ask "https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/agent.ts"
click node_billing "https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/credits.ts"
click node_cms "https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/cms-github.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_app,node_tg,node_personal toneBlue
class node_searchui,node_bibleui,node_askui,node_adminui toneAmber
class node_worker,node_searchapi,node_ask,node_billing,node_cms toneMint
class node_siteindex,node_vectors,node_models,node_telegram,node_github toneRose
class node_reader toneIndigo
```

## Components

### Telegram Mini App

- [App router](https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/App.tsx): `app/src/App.tsx`
- [Telegram bridge](https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/tg/sdk.ts): `app/src/tg/sdk.ts`
- [Personal store](https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/tg/store.ts): `app/src/tg/store.ts`

### Library Experience

- [Teaching search](https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/screens/Search.tsx): `app/src/screens/Search.tsx`
- [Bible reader](https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/bible/BibleTab.tsx): `app/src/bible/BibleTab.tsx`
- [Ask interface](https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/screens/Ask.tsx): `app/src/screens/Ask.tsx`
- [Note editor](https://github.com/devsecobie/cyberjudah-telegram/blob/main/app/src/admin/ResourceAdmin.tsx): `app/src/admin/ResourceAdmin.tsx`

### Worker API

- [Worker routes](https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/index.ts): `bot/src/index.ts`
- [Teaching search API](https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/teachings.ts): `bot/src/teachings.ts`
- [Ask retrieval and agent](https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/agent.ts): `bot/src/agent.ts`
- [Ask billing](https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/credits.ts): `bot/src/credits.ts`
- [Repository note edits](https://github.com/devsecobie/cyberjudah-telegram/blob/main/bot/src/cms-github.ts): `bot/src/cms-github.ts`

### Data and Integrations

- **Teaching corpus**
- **Vectorize index**
- **AI models**
- **Telegram platform**
- **CyberJudah repository**

### Other components

- **Reader**

## Connections

- Reader → App router: opens
- App router → Telegram bridge: boots through (evidence: `app/src/main.tsx`)
- App router → Teaching search: routes to (evidence: `app/src/App.tsx`)
- App router → Bible reader: routes to
- App router → Ask interface: routes to (evidence: `app/src/App.tsx`)
- App router → Note editor: provides editing
- Teaching search → Worker routes: requests results
- Worker routes → Teaching search API: dispatches search (evidence: `bot/src/index.ts`)
- Teaching search API → Teaching corpus: queries passages
- Teaching search → Bible reader: opens reference
- Ask interface → Worker routes: calls Ask API
- Worker routes → Ask retrieval and agent: dispatches Ask
- Ask retrieval and agent → Teaching corpus: retrieves passages
- Ask retrieval and agent → Vectorize index: retrieves by meaning
- Ask retrieval and agent → AI models: generates answer
- Worker routes → Ask billing: accounts charges (evidence: `bot/src/index.ts`)
- Ask billing → Telegram platform: sells Stars top-ups
- Note editor → Worker routes: submits edits
- Worker routes → Repository note edits: dispatches edit (evidence: `bot/src/index.ts`)
- Repository note edits → CyberJudah repository: commits note
- Telegram bridge → Personal store: stores account data (evidence: `app/src/tg/store.ts`)
- Worker routes → Telegram platform: handles bot updates
