# jikongabc/cogdoc architecture

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

- Interactive diagram: https://gitdiagram.com/jikongabc/cogdoc
- Repository: https://github.com/jikongabc/cogdoc

## Overview

CogDoc is a RAG knowledge-base platform for teams and individuals. Its main workflow is to ingest documents into a knowledge base, retrieve scoped evidence for a question, generate a grounded response, and validate citations before presenting results. The graph also preserves documented branches for Deep Research, connectors, derived-knowledge review, enterprise access control, and optional high-availability storage. Several relationships come from the README or source-index import references; unsampled implementation details are not inferred.

Main entry points: [`src/cogdoc/api/app.py`](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/api/app.py) (HTTP API), [`src/cogdoc/service/chat_service.py`](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/chat_service.py) (Chat service), [`src/cogdoc/graph/workflow.py`](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/graph/workflow.py) (Agent workflow), [`src/cogdoc/service/retrieval_pipeline.py`](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/retrieval_pipeline.py) (Hybrid retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["User workspace"]
  node_web["Next.js workspace<br/>[page.tsx]"]
  node_frontend["Compatibility console<br/>[app.py]"]
end

subgraph group_api["API and governance"]
  node_api_app["HTTP API<br/>[app.py]"]
  node_auth[("Accounts and access<br/>[auth_store.py]")]
  node_derived[("Derived knowledge review")]
end

subgraph group_knowledge["Knowledge lifecycle"]
  node_ingest_api["Ingestion jobs<br/>[ingest.py]"]
  node_ingest["Index generation<br/>[ingest_service.py]"]
  node_connectors["Connector sync<br/>[manager.py]"]
  node_sync_store[("Sync state<br/>[sync_store.py]")]
end

subgraph group_answers["Retrieval and answers"]
  node_chat["Chat service<br/>[chat_service.py]"]
  node_workflow["Agent workflow<br/>[workflow.py]"]
  node_retrieval["Hybrid retrieval"]
  node_evidence["Evidence assembly"]
  node_citations["Citation ledger<br/>[citation_ledger.py]"]
  node_memory["Conversation memory<br/>[manager.py]"]
  node_native["Rust retrieval core<br/>[lib.rs]"]
end

subgraph group_extensions["Platform extensions"]
  node_research["Deep Research"]
  node_ha["Distributed control plane<br/>[runtime.py]"]
  node_config["Runtime settings<br/>[settings.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_web
node_user -->|"uses"| node_frontend
node_web -->|"calls"| node_api_app
node_frontend -->|"calls"| node_api_app
node_api_app -->|"uses"| node_auth
node_api_app -->|"routes"| node_ingest_api
node_api_app -->|"uses"| node_derived
node_ingest_api -->|"delegates"| node_ingest
node_connectors -->|"persists sync"| node_sync_store
node_user -->|"asks question"| node_chat
node_api_app -->|"serves chat"| node_chat
node_chat -.->|"orchestrates"| node_workflow
node_workflow -->|"retrieves evidence"| node_retrieval
node_retrieval -->|"assembles context"| node_evidence
node_evidence -->|"binds citations"| node_citations
node_workflow -->|"validates citations"| node_native
node_chat -->|"uses memory"| node_memory
node_user -->|"starts research"| node_research
node_research -->|"uses retrieval"| node_retrieval
node_api_app -->|"manages sources"| node_connectors
node_api_app -.->|"optional coordination"| node_ha
node_config -->|"configures"| node_ha

click node_web "https://github.com/jikongabc/cogdoc/blob/main/web/app/(workspace)/chat/page.tsx"
click node_frontend "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/frontend/app.py"
click node_api_app "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/api/app.py"
click node_auth "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/api/auth_store.py"
click node_derived "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/api/derived_knowledge_store.py"
click node_ingest_api "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/api/ingest.py"
click node_ingest "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/ingest_service.py"
click node_connectors "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/connectors/manager.py"
click node_sync_store "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/connectors/sync_store.py"
click node_chat "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/chat_service.py"
click node_workflow "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/graph/workflow.py"
click node_retrieval "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/retrieval_pipeline.py"
click node_evidence "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/evidence_unit_pipeline.py"
click node_citations "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/tools/citation_ledger.py"
click node_memory "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/memory/manager.py"
click node_native "https://github.com/jikongabc/cogdoc/blob/main/rust_core/src/lib.rs"
click node_research "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/research_execution.py"
click node_ha "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/ha/runtime.py"
click node_config "https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/config/settings.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,node_frontend,node_user toneBlue
class node_api_app,node_auth,node_derived toneAmber
class node_ingest_api,node_ingest,node_connectors,node_sync_store toneMint
class node_chat,node_workflow,node_retrieval,node_evidence,node_citations,node_memory,node_native toneRose
class node_research,node_ha,node_config toneIndigo
```

## Components

### User workspace

- [Next.js workspace](https://github.com/jikongabc/cogdoc/blob/main/web/app/(workspace)/chat/page.tsx): `web/app/(workspace)/chat/page.tsx`
- [Compatibility console](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/frontend/app.py): `src/cogdoc/frontend/app.py`

### API and governance

- [HTTP API](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/api/app.py): `src/cogdoc/api/app.py`
- [Accounts and access](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/api/auth_store.py): `src/cogdoc/api/auth_store.py`
- [Derived knowledge review](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/api/derived_knowledge_store.py): `src/cogdoc/api/derived_knowledge_store.py`

### Knowledge lifecycle

- [Ingestion jobs](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/api/ingest.py): `src/cogdoc/api/ingest.py`
- [Index generation](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/ingest_service.py): `src/cogdoc/service/ingest_service.py`
- [Connector sync](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/connectors/manager.py): `src/cogdoc/connectors/manager.py`
- [Sync state](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/connectors/sync_store.py): `src/cogdoc/connectors/sync_store.py`

### Retrieval and answers

- [Chat service](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/chat_service.py): `src/cogdoc/service/chat_service.py`
- [Agent workflow](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/graph/workflow.py): `src/cogdoc/graph/workflow.py`
- [Hybrid retrieval](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/retrieval_pipeline.py): `src/cogdoc/service/retrieval_pipeline.py`
- [Evidence assembly](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/evidence_unit_pipeline.py): `src/cogdoc/service/evidence_unit_pipeline.py`
- [Citation ledger](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/tools/citation_ledger.py): `src/cogdoc/tools/citation_ledger.py`
- [Conversation memory](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/memory/manager.py): `src/cogdoc/memory/manager.py`
- [Rust retrieval core](https://github.com/jikongabc/cogdoc/blob/main/rust_core/src/lib.rs): `rust_core/src/lib.rs`

### Platform extensions

- [Deep Research](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/service/research_execution.py): `src/cogdoc/service/research_execution.py`
- [Distributed control plane](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/ha/runtime.py): `src/cogdoc/ha/runtime.py`
- [Runtime settings](https://github.com/jikongabc/cogdoc/blob/main/src/cogdoc/config/settings.py): `src/cogdoc/config/settings.py`

### Other components

- **User**

## Connections

- User → Next.js workspace: uses (evidence: `README.md`)
- User → Compatibility console: uses (evidence: `README.md`)
- Next.js workspace → HTTP API: calls (evidence: `README.md`)
- Compatibility console → HTTP API: calls (evidence: `src/cogdoc/frontend/app.py`)
- HTTP API → Accounts and access: uses (evidence: `src/cogdoc/api/app.py`)
- HTTP API → Ingestion jobs: routes (evidence: `src/cogdoc/api/app.py`)
- HTTP API → Derived knowledge review: uses (evidence: `src/cogdoc/api/app.py`)
- Ingestion jobs → Index generation: delegates (evidence: `src/cogdoc/api/ingest.py`)
- Connector sync → Sync state: persists sync (evidence: `src/cogdoc/connectors/manager.py`)
- User → Chat service: asks question (evidence: `README.md`)
- HTTP API → Chat service: serves chat (evidence: `README.md`)
- Chat service → Agent workflow: orchestrates
- Agent workflow → Hybrid retrieval: retrieves evidence (evidence: `README.md`)
- Hybrid retrieval → Evidence assembly: assembles context (evidence: `src/cogdoc/service/evidence_unit_pipeline.py`)
- Evidence assembly → Citation ledger: binds citations (evidence: `src/cogdoc/service/evidence_unit_pipeline.py`)
- Agent workflow → Rust retrieval core: validates citations (evidence: `README.md`)
- Chat service → Conversation memory: uses memory (evidence: `README.md`)
- User → Deep Research: starts research (evidence: `README.md`)
- Deep Research → Hybrid retrieval: uses retrieval (evidence: `README.md`)
- HTTP API → Connector sync: manages sources (evidence: `README.md`)
- HTTP API → Distributed control plane: optional coordination (evidence: `README.md`)
- Runtime settings → Distributed control plane: configures (evidence: `src/cogdoc/config/settings.py`)
