# ksksrbiz-arch/graph architecture

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

- Interactive diagram: https://gitdiagram.com/ksksrbiz-arch/graph
- Repository: https://github.com/ksksrbiz-arch/graph
- Video tour (about a minute): https://gitdiagram.com/ksksrbiz-arch/graph/video

## Overview

Graph is a personal knowledge-graph visualization system with three coexisting runtime tracks: the v1 static viewer and local ingest tools, a Cloudflare Worker API with cortex capabilities, and the v2 NestJS API with a React scaffold. The main user workflow is ingesting digital sources into graph data, persisting it, then exploring/searching it visually; the v2 API also exposes brain, reasoning, connector-sync, and OAuth capabilities. README statements and indexed source references support the main links; unsampled subsystem details are represented only at documented scope.

Main entry points: [`src/worker.js`](https://github.com/ksksrbiz-arch/graph/blob/main/src/worker.js) (Worker Entry), [`src/worker/cortex/router.js`](https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/cortex/router.js) (Cortex API), [`web/ingest-panel.js`](https://github.com/ksksrbiz-arch/graph/blob/main/web/ingest-panel.js) (Ingest UI), [`apps/api/src/public/public-ingest.service.ts`](https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/public/public-ingest.service.ts) (Public Ingest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_v1["v1 Static Product"]
  node_v1ingest["Source Ingesters"]
  node_v1server["Local Server<br/>[serve.mjs]"]
  node_v1viewer["Graph Viewer<br/>[app.js]"]
  node_v1data["Graph Data Client<br/>[data.js]"]
  node_v1ingestui["Ingest UI<br/>[ingest-panel.js]"]
  node_v1connectors["Connector Runs<br/>[connectors.js]"]
end

subgraph group_worker["Cloudflare Worker"]
  node_workerentry["Worker Entry<br/>[worker.js]"]
  node_workerparser["Text Parser<br/>[text-parser.js]"]
  node_workergraph[("Graph Persistence<br/>[worker.js]")]
  node_workerrouter["Cortex API<br/>[router.js]"]
  node_workerreason["Cortex Reasoning<br/>[reason.js]"]
  node_workervector[("Vector Recall<br/>[vector.js]")]
  node_workerfinance["Finance API<br/>[router.js]"]
end

subgraph group_v2api["v2 API"]
  node_apiingest["Public Ingest"]
  node_apigraph[("Knowledge Graph<br/>[graph.service.ts]")]
  node_apibrain["Brain Services<br/>[brain.service.ts]"]
  node_apireason["Reasoning API"]
  node_apioauth["OAuth Service<br/>[oauth.service.ts]"]
  node_apiconnectors["Connector Sync"]
end

subgraph group_clients["Web Clients &amp; Packages"]
  node_reactapp["React App<br/>[App.tsx]"]
  node_reactgraph["Interactive Graph<br/>[GraphView.tsx]"]
  node_cortexpkg["Cortex Runtime"]
  node_reasonpkg["Reasoning Library"]
end

node_person(("User"))

node_person -->|"selects sources"| node_v1ingest
node_v1ingest -.->|"produces graph"| node_v1data
node_person -->|"submits content"| node_v1ingestui
node_v1ingestui -->|"runs connector"| node_v1connectors
node_v1ingestui -->|"ingests text"| node_v1data
node_v1data -.->|"requests graph"| node_v1server
node_v1server -->|"serves viewer"| node_v1viewer
node_person -->|"explores graph"| node_v1viewer
node_person -->|"sends API requests"| node_workerentry
node_workerentry -->|"parses text"| node_workerparser
node_workerentry -->|"merges and persists"| node_workergraph
node_workerentry -->|"routes cortex requests"| node_workerrouter
node_workerrouter -->|"invokes reasoning"| node_workerreason
node_workerrouter -->|"updates vectors"| node_workervector
node_workerrouter -.->|"routes finance requests"| node_workerfinance
node_person -->|"uses scaffold"| node_reactapp
node_reactapp -->|"renders graph view"| node_reactgraph
node_person -->|"submits public ingest"| node_apiingest
node_apiingest -->|"persists parsed graph"| node_apigraph
node_apiingest -->|"stimulates and reloads"| node_apibrain
node_person -.->|"connects provider"| node_apioauth
node_apiconnectors -.->|"syncs graph sources"| node_apigraph
node_apibrain -->|"uses neural runtime"| node_cortexpkg
node_apireason -->|"uses reasoning algorithms"| node_reasonpkg

click node_v1ingest "https://github.com/ksksrbiz-arch/graph/tree/main/scripts"
click node_v1server "https://github.com/ksksrbiz-arch/graph/blob/main/scripts/serve.mjs"
click node_v1viewer "https://github.com/ksksrbiz-arch/graph/blob/main/web/app.js"
click node_v1data "https://github.com/ksksrbiz-arch/graph/blob/main/web/data.js"
click node_v1ingestui "https://github.com/ksksrbiz-arch/graph/blob/main/web/ingest-panel.js"
click node_v1connectors "https://github.com/ksksrbiz-arch/graph/blob/main/web/views/connectors.js"
click node_workerentry "https://github.com/ksksrbiz-arch/graph/blob/main/src/worker.js"
click node_workerparser "https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/text-parser.js"
click node_workergraph "https://github.com/ksksrbiz-arch/graph/blob/main/src/worker.js"
click node_workerrouter "https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/cortex/router.js"
click node_workerreason "https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/cortex/reason.js"
click node_workervector "https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/cortex/vector.js"
click node_workerfinance "https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/finance/router.js"
click node_apiingest "https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/public/public-ingest.service.ts"
click node_apigraph "https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/graph/graph.service.ts"
click node_apibrain "https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/brain/brain.service.ts"
click node_apireason "https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/reasoning/reasoning.service.ts"
click node_apioauth "https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/oauth/oauth.service.ts"
click node_apiconnectors "https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/sync/sync.orchestrator.ts"
click node_reactapp "https://github.com/ksksrbiz-arch/graph/blob/main/apps/web/src/App.tsx"
click node_reactgraph "https://github.com/ksksrbiz-arch/graph/blob/main/apps/web/src/graph/GraphView.tsx"
click node_cortexpkg "https://github.com/ksksrbiz-arch/graph/tree/main/packages/cortex/src/cortex"
click node_reasonpkg "https://github.com/ksksrbiz-arch/graph/tree/main/packages/reasoning/src"

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_v1ingest,node_v1server,node_v1viewer,node_v1data,node_v1ingestui,node_v1connectors,node_person toneBlue
class node_workerentry,node_workerparser,node_workergraph,node_workerrouter,node_workerreason,node_workervector,node_workerfinance toneAmber
class node_apiingest,node_apigraph,node_apibrain,node_apireason,node_apioauth,node_apiconnectors toneMint
class node_reactapp,node_reactgraph,node_cortexpkg,node_reasonpkg toneRose
```

## Components

### v1 Static Product

- [Source Ingesters](https://github.com/ksksrbiz-arch/graph/tree/main/scripts): `scripts`
- [Local Server](https://github.com/ksksrbiz-arch/graph/blob/main/scripts/serve.mjs): `scripts/serve.mjs`
- [Graph Viewer](https://github.com/ksksrbiz-arch/graph/blob/main/web/app.js): `web/app.js`
- [Graph Data Client](https://github.com/ksksrbiz-arch/graph/blob/main/web/data.js): `web/data.js`
- [Ingest UI](https://github.com/ksksrbiz-arch/graph/blob/main/web/ingest-panel.js): `web/ingest-panel.js`
- [Connector Runs](https://github.com/ksksrbiz-arch/graph/blob/main/web/views/connectors.js): `web/views/connectors.js`

### Cloudflare Worker

- [Worker Entry](https://github.com/ksksrbiz-arch/graph/blob/main/src/worker.js): `src/worker.js`
- [Text Parser](https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/text-parser.js): `src/worker/text-parser.js`
- [Graph Persistence](https://github.com/ksksrbiz-arch/graph/blob/main/src/worker.js): `src/worker.js`
- [Cortex API](https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/cortex/router.js): `src/worker/cortex/router.js`
- [Cortex Reasoning](https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/cortex/reason.js): `src/worker/cortex/reason.js`
- [Vector Recall](https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/cortex/vector.js): `src/worker/cortex/vector.js`
- [Finance API](https://github.com/ksksrbiz-arch/graph/blob/main/src/worker/finance/router.js): `src/worker/finance/router.js`

### v2 API

- [Public Ingest](https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/public/public-ingest.service.ts): `apps/api/src/public/public-ingest.service.ts`
- [Knowledge Graph](https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/graph/graph.service.ts): `apps/api/src/graph/graph.service.ts`
- [Brain Services](https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/brain/brain.service.ts): `apps/api/src/brain/brain.service.ts`
- [Reasoning API](https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/reasoning/reasoning.service.ts): `apps/api/src/reasoning/reasoning.service.ts`
- [OAuth Service](https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/oauth/oauth.service.ts): `apps/api/src/oauth/oauth.service.ts`
- [Connector Sync](https://github.com/ksksrbiz-arch/graph/blob/main/apps/api/src/sync/sync.orchestrator.ts): `apps/api/src/sync/sync.orchestrator.ts`

### Web Clients & Packages

- [React App](https://github.com/ksksrbiz-arch/graph/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Interactive Graph](https://github.com/ksksrbiz-arch/graph/blob/main/apps/web/src/graph/GraphView.tsx): `apps/web/src/graph/GraphView.tsx`
- [Cortex Runtime](https://github.com/ksksrbiz-arch/graph/tree/main/packages/cortex/src/cortex): `packages/cortex/src/cortex`
- [Reasoning Library](https://github.com/ksksrbiz-arch/graph/tree/main/packages/reasoning/src): `packages/reasoning/src`

### Other components

- **User**

## Connections

- User → Source Ingesters: selects sources (evidence: `README.md`)
- Source Ingesters → Graph Data Client: produces graph (evidence: `README.md`)
- User → Ingest UI: submits content (evidence: `README.md`)
- Ingest UI → Connector Runs: runs connector (evidence: `web/ingest-panel.js`)
- Ingest UI → Graph Data Client: ingests text (evidence: `web/ingest-panel.js`)
- Graph Data Client → Local Server: requests graph (evidence: `README.md`)
- Local Server → Graph Viewer: serves viewer (evidence: `README.md`)
- User → Graph Viewer: explores graph (evidence: `README.md`)
- User → Worker Entry: sends API requests (evidence: `README.md`)
- Worker Entry → Text Parser: parses text (evidence: `src/worker.js`)
- Worker Entry → Graph Persistence: merges and persists (evidence: `src/worker.js`)
- Worker Entry → Cortex API: routes cortex requests (evidence: `src/worker.js`)
- Cortex API → Cortex Reasoning: invokes reasoning (evidence: `src/worker/cortex/router.js`)
- Cortex API → Vector Recall: updates vectors (evidence: `src/worker/cortex/router.js`)
- Cortex API → Finance API: routes finance requests (evidence: `README.md`)
- User → React App: uses scaffold (evidence: `README.md`)
- React App → Interactive Graph: renders graph view (evidence: `apps/web/src/App.tsx`)
- User → Public Ingest: submits public ingest (evidence: `README.md`)
- Public Ingest → Knowledge Graph: persists parsed graph (evidence: `apps/api/src/public/public-ingest.service.ts`)
- Public Ingest → Brain Services: stimulates and reloads (evidence: `apps/api/src/public/public-ingest.service.ts`)
- User → OAuth Service: connects provider (evidence: `README.md`)
- Connector Sync → Knowledge Graph: syncs graph sources (evidence: `README.md`)
- Brain Services → Cortex Runtime: uses neural runtime (evidence: `apps/api/src/brain/brain.service.ts`)
- Reasoning API → Reasoning Library: uses reasoning algorithms
