# hd325/houkongintellect-public architecture

> Architecture diagram of the GitHub repository hd325/houkongintellect-public, 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/hd325/houkongintellect-public
- Repository: https://github.com/hd325/houkongintellect-public

## Overview

HouKongIntellect is a local-first campus learning assistant: learners and teachers manage source documents, ask cited questions, and use review, OCR, quiz, and usage-reporting features. The main workflow is upload, extract and suggest metadata, confirm and publish or submit for review, index approved material, then retrieve passages for answers with citations. The FastAPI application in main.py coordinates these routes and services; the static page is the user interface. Edges reflect README statements or source-index references and shown calls; unsampled route internals are not inferred.

Main entry points: [`main.py`](https://github.com/hd325/houkongintellect-public/blob/main/main.py) (FastAPI application), [`services/knowledge/vector_store.py`](https://github.com/hd325/houkongintellect-public/blob/main/services/knowledge/vector_store.py) (Vector store), [`index.html`](https://github.com/hd325/houkongintellect-public/blob/main/index.html) (Web interface), [`services/ocr/tencent_ocr.py`](https://github.com/hd325/houkongintellect-public/blob/main/services/ocr/tencent_ocr.py) (Tencent OCR)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_web["Web interface<br/>[index.html]"]
  node_api["FastAPI application<br/>[main.py]"]
  node_config["Runtime configuration<br/>[settings.py]"]
end

subgraph group_content["Document lifecycle"]
  node_upload["Upload analysis<br/>[upload_analysis.py]"]
  node_ocr["Tencent OCR<br/>[tencent_ocr.py]"]
  node_documents["Document catalog"]
  node_files["Document files<br/>[document_files.py]"]
  node_review["Review policy<br/>[review_policy.py]"]
end

subgraph group_knowledge["Knowledge services"]
  node_chunker["Text chunking<br/>[chunker.py]"]
  node_vector[("Vector store<br/>[vector_store.py]")]
  node_embedder["Embedding backends<br/>[embedder.py]"]
  node_retriever["Hybrid retrieval<br/>[retriever.py]"]
end

subgraph group_learning["Learning features"]
  node_chatmodel["Chat model service"]
  node_search["Web search<br/>[search_util.py]"]
  node_quiz["Quiz generation<br/>[quiz_service.py]"]
end

subgraph group_operations["Accounts and reporting"]
  node_accounts["Account management<br/>[accounts.py]"]
  node_metrics["Retrieval metrics<br/>[metrics_summary.py]"]
  node_metricsdata["Metrics records"]
end

node_learner(("Learner / teacher"))

node_learner -->|"uses"| node_web
node_web -->|"requests"| node_api
node_api -->|"loads settings"| node_config
node_api -->|"authenticates"| node_accounts
node_api -->|"analyzes upload"| node_upload
node_api -->|"extracts scans"| node_ocr
node_api -->|"manages documents"| node_documents
node_documents -->|"uses storage helpers"| node_files
node_api -->|"checks publication"| node_review
node_api -->|"indexes documents"| node_vector
node_vector -->|"chunks text"| node_chunker
node_vector -->|"embeds chunks"| node_embedder
node_api -->|"retrieves context"| node_retriever
node_retriever -->|"queries vectors"| node_vector
node_api -->|"requests answers"| node_chatmodel
node_api -->|"offers web search"| node_search
node_api -->|"generates practice"| node_quiz
node_quiz -->|"reads document chunks"| node_vector
node_api -->|"summarizes usage"| node_metrics
node_metrics -->|"reads records"| node_metricsdata
node_ocr -->|"loads credentials"| node_config

click node_web "https://github.com/hd325/houkongintellect-public/blob/main/index.html"
click node_api "https://github.com/hd325/houkongintellect-public/blob/main/main.py"
click node_config "https://github.com/hd325/houkongintellect-public/blob/main/config/settings.py"
click node_upload "https://github.com/hd325/houkongintellect-public/blob/main/services/upload_analysis.py"
click node_ocr "https://github.com/hd325/houkongintellect-public/blob/main/services/ocr/tencent_ocr.py"
click node_documents "https://github.com/hd325/houkongintellect-public/blob/main/services/document_catalog.py"
click node_files "https://github.com/hd325/houkongintellect-public/blob/main/services/document_files.py"
click node_review "https://github.com/hd325/houkongintellect-public/blob/main/services/review_policy.py"
click node_chunker "https://github.com/hd325/houkongintellect-public/blob/main/services/chunker.py"
click node_vector "https://github.com/hd325/houkongintellect-public/blob/main/services/knowledge/vector_store.py"
click node_embedder "https://github.com/hd325/houkongintellect-public/blob/main/services/knowledge/embedder.py"
click node_retriever "https://github.com/hd325/houkongintellect-public/blob/main/services/retrieval/retriever.py"
click node_search "https://github.com/hd325/houkongintellect-public/blob/main/search_util.py"
click node_quiz "https://github.com/hd325/houkongintellect-public/blob/main/services/quiz_service.py"
click node_accounts "https://github.com/hd325/houkongintellect-public/blob/main/services/accounts.py"
click node_metrics "https://github.com/hd325/houkongintellect-public/blob/main/services/metrics_summary.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_api,node_config toneBlue
class node_upload,node_ocr,node_documents,node_files,node_review toneAmber
class node_chunker,node_vector,node_embedder,node_retriever toneMint
class node_chatmodel,node_search,node_quiz toneRose
class node_accounts,node_metrics,node_metricsdata,node_learner toneIndigo
```

## Components

### Application

- [Web interface](https://github.com/hd325/houkongintellect-public/blob/main/index.html): `index.html`
- [FastAPI application](https://github.com/hd325/houkongintellect-public/blob/main/main.py): `main.py`
- [Runtime configuration](https://github.com/hd325/houkongintellect-public/blob/main/config/settings.py): `config/settings.py`

### Document lifecycle

- [Upload analysis](https://github.com/hd325/houkongintellect-public/blob/main/services/upload_analysis.py): `services/upload_analysis.py`
- [Tencent OCR](https://github.com/hd325/houkongintellect-public/blob/main/services/ocr/tencent_ocr.py): `services/ocr/tencent_ocr.py`
- [Document catalog](https://github.com/hd325/houkongintellect-public/blob/main/services/document_catalog.py): `services/document_catalog.py`
- [Document files](https://github.com/hd325/houkongintellect-public/blob/main/services/document_files.py): `services/document_files.py`
- [Review policy](https://github.com/hd325/houkongintellect-public/blob/main/services/review_policy.py): `services/review_policy.py`

### Knowledge services

- [Text chunking](https://github.com/hd325/houkongintellect-public/blob/main/services/chunker.py): `services/chunker.py`
- [Vector store](https://github.com/hd325/houkongintellect-public/blob/main/services/knowledge/vector_store.py): `services/knowledge/vector_store.py`
- [Embedding backends](https://github.com/hd325/houkongintellect-public/blob/main/services/knowledge/embedder.py): `services/knowledge/embedder.py`
- [Hybrid retrieval](https://github.com/hd325/houkongintellect-public/blob/main/services/retrieval/retriever.py): `services/retrieval/retriever.py`

### Learning features

- **Chat model service**
- [Web search](https://github.com/hd325/houkongintellect-public/blob/main/search_util.py): `search_util.py`
- [Quiz generation](https://github.com/hd325/houkongintellect-public/blob/main/services/quiz_service.py): `services/quiz_service.py`

### Accounts and reporting

- [Account management](https://github.com/hd325/houkongintellect-public/blob/main/services/accounts.py): `services/accounts.py`
- [Retrieval metrics](https://github.com/hd325/houkongintellect-public/blob/main/services/metrics_summary.py): `services/metrics_summary.py`
- **Metrics records**

### Other components

- **Learner / teacher**

## Connections

- Learner / teacher → Web interface: uses (evidence: `README.md`)
- Web interface → FastAPI application: requests (evidence: `README.md`)
- FastAPI application → Runtime configuration: loads settings (evidence: `main.py`)
- FastAPI application → Account management: authenticates (evidence: `main.py`)
- FastAPI application → Upload analysis: analyzes upload (evidence: `main.py`)
- FastAPI application → Tencent OCR: extracts scans (evidence: `main.py`)
- FastAPI application → Document catalog: manages documents (evidence: `main.py`)
- Document catalog → Document files: uses storage helpers (evidence: `services/document_catalog.py`)
- FastAPI application → Review policy: checks publication (evidence: `main.py`)
- FastAPI application → Vector store: indexes documents (evidence: `main.py`)
- Vector store → Text chunking: chunks text (evidence: `services/knowledge/vector_store.py`)
- Vector store → Embedding backends: embeds chunks (evidence: `services/knowledge/vector_store.py`)
- FastAPI application → Hybrid retrieval: retrieves context (evidence: `main.py`)
- Hybrid retrieval → Vector store: queries vectors (evidence: `services/retrieval/retriever.py`)
- FastAPI application → Chat model service: requests answers (evidence: `README.md`)
- FastAPI application → Web search: offers web search (evidence: `main.py`)
- FastAPI application → Quiz generation: generates practice (evidence: `main.py`)
- Quiz generation → Vector store: reads document chunks (evidence: `services/quiz_service.py`)
- FastAPI application → Retrieval metrics: summarizes usage (evidence: `main.py`)
- Retrieval metrics → Metrics records: reads records (evidence: `services/metrics_summary.py`)
- Tencent OCR → Runtime configuration: loads credentials (evidence: `services/ocr/tencent_ocr.py`)
