# albiehao/nonjingai architecture

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

- Interactive diagram: https://gitdiagram.com/albiehao/nonjingai
- Repository: https://github.com/albiehao/nonjingai

## Overview

QianXun is an AI knowledge and agricultural analysis platform. Users enter through the Vue interface to ask questions or manage knowledge bases, while FastAPI routes requests to agent workflows and knowledge services; answers can draw on retrieval, graph context, external search, and specialist tools. Separate product branches cover document ingestion, visual detection, knowledge-graph exploration, and crop administration. The README documents those capabilities, but sampled code does not expose all route-to-service wiring, so uncertain connections are omitted; crop-management backend implementation is not present in the supplied tree.

Main entry points: [`src/knowledge/manager.py`](https://github.com/albiehao/nonjingai/blob/develop/src/knowledge/manager.py) (Knowledge manager), [`web/src/App.vue`](https://github.com/albiehao/nonjingai/blob/develop/web/src/App.vue) (Vue application), [`src/agents/common/toolkits`](https://github.com/albiehao/nonjingai/tree/develop/src/agents/common/toolkits) (Agent toolkits), [`server/main.py`](https://github.com/albiehao/nonjingai/blob/develop/server/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web interface"]
  node_webapp["Vue application<br/>[App.vue]"]
  node_chatui["Agent chat UI"]
  node_chatstream["Stream handling"]
  node_kbui["Knowledge UI<br/>[QuerySection.vue]"]
  node_graphui["Graph explorer<br/>[GraphCanvas.vue]"]
  node_cropui["Crop administration<br/>[CropAdminView.vue]"]
end

subgraph group_api["API and services"]
  node_api["FastAPI application<br/>[main.py]"]
  node_chatroute["Chat endpoints<br/>[chat_router.py]"]
  node_kbroute["Knowledge endpoints"]
  node_graphroute["Graph endpoints<br/>[graph_router.py]"]
  node_croproute["Crop endpoints<br/>[crop_router.py]"]
end

subgraph group_knowledge["Knowledge and agents"]
  node_agent["Chat agent graph<br/>[graph.py]"]
  node_tools["Agent toolkits"]
  node_kbmanager["Knowledge manager<br/>[manager.py]"]
  node_indexing["Document indexing<br/>[indexing.py]"]
  node_parsers["Document parsers"]
  node_cropagent["Crop agent<br/>[graph.py]"]
end

subgraph group_data["Data and integrations"]
  node_pg[("PostgreSQL<br/>[manager.py]")]
  node_repos["Repositories"]
  node_minio[("MinIO storage<br/>[client.py]")]
  node_milvus[("Vector search<br/>[milvus.py]")]
  node_lightrag[("LightRAG graph<br/>[lightrag.py]")]
  node_llm{{"Model providers"}}
  node_search{{"Tavily search"}}
  node_yolo["YOLO detection<br/>[main.py]"]
end

subgraph group_agri["Agriculture features"]
  node_cropdata[("Crop records<br/>[models_crop.py]")]
  node_cropapi["Crop API client<br/>[crop_manager.js]"]
end

node_user(("Platform user"))

node_user -->|"uses"| node_webapp
node_webapp -->|"renders"| node_chatui
node_webapp -->|"renders"| node_kbui
node_webapp -->|"renders"| node_graphui
node_webapp -->|"renders"| node_cropui
node_chatui -->|"sends chat"| node_chatroute
node_chatstream -->|"updates stream"| node_chatui
node_kbui -->|"queries API"| node_kbroute
node_graphui -->|"requests graph"| node_graphroute
node_cropui -->|"manages crops"| node_cropapi
node_cropapi -->|"calls API"| node_croproute
node_api -->|"dispatches"| node_chatroute
node_api -->|"dispatches"| node_kbroute
node_api -->|"dispatches"| node_graphroute
node_api -->|"dispatches"| node_croproute
node_chatroute -->|"agent workflow"| node_agent
node_kbroute -->|"manages knowledge"| node_kbmanager
node_agent -->|"invokes tools"| node_tools
node_agent -->|"generates response"| node_llm
node_tools -->|"retrieves knowledge"| node_kbmanager
node_tools -.->|"web search"| node_search
node_tools -.->|"image detection"| node_yolo
node_kbmanager -->|"indexes documents"| node_indexing
node_indexing -->|"parses files"| node_parsers
node_kbmanager -->|"vector retrieval"| node_milvus
node_kbmanager -->|"graph retrieval"| node_lightrag
node_kbmanager -->|"file storage"| node_minio
node_chatroute -->|"loads history"| node_repos
node_repos -->|"reads and writes"| node_pg
node_croproute -->|"crop records"| node_cropdata
node_cropagent -.->|"uses tools"| node_tools

click node_webapp "https://github.com/albiehao/nonjingai/blob/develop/web/src/App.vue"
click node_chatui "https://github.com/albiehao/nonjingai/blob/develop/web/src/components/AgentChatComponent.vue"
click node_chatstream "https://github.com/albiehao/nonjingai/blob/develop/web/src/composables/useAgentStreamHandler.js"
click node_kbui "https://github.com/albiehao/nonjingai/blob/develop/web/src/components/QuerySection.vue"
click node_graphui "https://github.com/albiehao/nonjingai/blob/develop/web/src/components/GraphCanvas.vue"
click node_cropui "https://github.com/albiehao/nonjingai/blob/develop/web/src/views/CropAdminView.vue"
click node_api "https://github.com/albiehao/nonjingai/blob/develop/server/main.py"
click node_chatroute "https://github.com/albiehao/nonjingai/blob/develop/server/routers/chat_router.py"
click node_kbroute "https://github.com/albiehao/nonjingai/blob/develop/server/routers/knowledge_router.py"
click node_graphroute "https://github.com/albiehao/nonjingai/blob/develop/server/routers/graph_router.py"
click node_croproute "https://github.com/albiehao/nonjingai/blob/develop/server/routers/crop_router.py"
click node_agent "https://github.com/albiehao/nonjingai/blob/develop/src/agents/chatbot/graph.py"
click node_tools "https://github.com/albiehao/nonjingai/tree/develop/src/agents/common/toolkits"
click node_kbmanager "https://github.com/albiehao/nonjingai/blob/develop/src/knowledge/manager.py"
click node_indexing "https://github.com/albiehao/nonjingai/blob/develop/src/knowledge/indexing.py"
click node_parsers "https://github.com/albiehao/nonjingai/blob/develop/src/plugins/document_processor_factory.py"
click node_cropagent "https://github.com/albiehao/nonjingai/blob/develop/src/agents/crop_agent/graph.py"
click node_pg "https://github.com/albiehao/nonjingai/blob/develop/src/storage/postgres/manager.py"
click node_repos "https://github.com/albiehao/nonjingai/blob/develop/src/repositories/conversation_repository.py"
click node_minio "https://github.com/albiehao/nonjingai/blob/develop/src/storage/minio/client.py"
click node_milvus "https://github.com/albiehao/nonjingai/blob/develop/src/knowledge/implementations/milvus.py"
click node_lightrag "https://github.com/albiehao/nonjingai/blob/develop/src/knowledge/implementations/lightrag.py"
click node_yolo "https://github.com/albiehao/nonjingai/blob/develop/yolo/main.py"
click node_cropdata "https://github.com/albiehao/nonjingai/blob/develop/src/storage/postgres/models_crop.py"
click node_cropapi "https://github.com/albiehao/nonjingai/blob/develop/web/src/apis/crop_manager.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_webapp,node_chatui,node_chatstream,node_kbui,node_graphui,node_cropui,node_user toneBlue
class node_api,node_chatroute,node_kbroute,node_graphroute,node_croproute toneAmber
class node_agent,node_tools,node_kbmanager,node_indexing,node_parsers,node_cropagent toneMint
class node_pg,node_repos,node_minio,node_milvus,node_lightrag,node_llm,node_search,node_yolo toneRose
class node_cropdata,node_cropapi toneIndigo
```

## Components

### Web interface

- [Vue application](https://github.com/albiehao/nonjingai/blob/develop/web/src/App.vue): `web/src/App.vue`
- [Agent chat UI](https://github.com/albiehao/nonjingai/blob/develop/web/src/components/AgentChatComponent.vue): `web/src/components/AgentChatComponent.vue`
- [Stream handling](https://github.com/albiehao/nonjingai/blob/develop/web/src/composables/useAgentStreamHandler.js): `web/src/composables/useAgentStreamHandler.js`
- [Knowledge UI](https://github.com/albiehao/nonjingai/blob/develop/web/src/components/QuerySection.vue): `web/src/components/QuerySection.vue`
- [Graph explorer](https://github.com/albiehao/nonjingai/blob/develop/web/src/components/GraphCanvas.vue): `web/src/components/GraphCanvas.vue`
- [Crop administration](https://github.com/albiehao/nonjingai/blob/develop/web/src/views/CropAdminView.vue): `web/src/views/CropAdminView.vue`

### API and services

- [FastAPI application](https://github.com/albiehao/nonjingai/blob/develop/server/main.py): `server/main.py`
- [Chat endpoints](https://github.com/albiehao/nonjingai/blob/develop/server/routers/chat_router.py): `server/routers/chat_router.py`
- [Knowledge endpoints](https://github.com/albiehao/nonjingai/blob/develop/server/routers/knowledge_router.py): `server/routers/knowledge_router.py`
- [Graph endpoints](https://github.com/albiehao/nonjingai/blob/develop/server/routers/graph_router.py): `server/routers/graph_router.py`
- [Crop endpoints](https://github.com/albiehao/nonjingai/blob/develop/server/routers/crop_router.py): `server/routers/crop_router.py`

### Knowledge and agents

- [Chat agent graph](https://github.com/albiehao/nonjingai/blob/develop/src/agents/chatbot/graph.py): `src/agents/chatbot/graph.py`
- [Agent toolkits](https://github.com/albiehao/nonjingai/tree/develop/src/agents/common/toolkits): `src/agents/common/toolkits`
- [Knowledge manager](https://github.com/albiehao/nonjingai/blob/develop/src/knowledge/manager.py): `src/knowledge/manager.py`
- [Document indexing](https://github.com/albiehao/nonjingai/blob/develop/src/knowledge/indexing.py): `src/knowledge/indexing.py`
- [Document parsers](https://github.com/albiehao/nonjingai/blob/develop/src/plugins/document_processor_factory.py): `src/plugins/document_processor_factory.py`
- [Crop agent](https://github.com/albiehao/nonjingai/blob/develop/src/agents/crop_agent/graph.py): `src/agents/crop_agent/graph.py`

### Data and integrations

- [PostgreSQL](https://github.com/albiehao/nonjingai/blob/develop/src/storage/postgres/manager.py): `src/storage/postgres/manager.py`
- [Repositories](https://github.com/albiehao/nonjingai/blob/develop/src/repositories/conversation_repository.py): `src/repositories/conversation_repository.py`
- [MinIO storage](https://github.com/albiehao/nonjingai/blob/develop/src/storage/minio/client.py): `src/storage/minio/client.py`
- [Vector search](https://github.com/albiehao/nonjingai/blob/develop/src/knowledge/implementations/milvus.py): `src/knowledge/implementations/milvus.py`
- [LightRAG graph](https://github.com/albiehao/nonjingai/blob/develop/src/knowledge/implementations/lightrag.py): `src/knowledge/implementations/lightrag.py`
- **Model providers**
- **Tavily search**
- [YOLO detection](https://github.com/albiehao/nonjingai/blob/develop/yolo/main.py): `yolo/main.py`

### Agriculture features

- [Crop records](https://github.com/albiehao/nonjingai/blob/develop/src/storage/postgres/models_crop.py): `src/storage/postgres/models_crop.py`
- [Crop API client](https://github.com/albiehao/nonjingai/blob/develop/web/src/apis/crop_manager.js): `web/src/apis/crop_manager.js`

### Other components

- **Platform user**

## Connections

- Platform user → Vue application: uses
- Vue application → Agent chat UI: renders
- Vue application → Knowledge UI: renders
- Vue application → Graph explorer: renders
- Vue application → Crop administration: renders
- Agent chat UI → Chat endpoints: sends chat
- Stream handling → Agent chat UI: updates stream
- Knowledge UI → Knowledge endpoints: queries API
- Graph explorer → Graph endpoints: requests graph
- Crop administration → Crop API client: manages crops
- Crop API client → Crop endpoints: calls API
- FastAPI application → Chat endpoints: dispatches
- FastAPI application → Knowledge endpoints: dispatches
- FastAPI application → Graph endpoints: dispatches
- FastAPI application → Crop endpoints: dispatches
- Chat endpoints → Chat agent graph: agent workflow
- Knowledge endpoints → Knowledge manager: manages knowledge
- Chat agent graph → Agent toolkits: invokes tools
- Chat agent graph → Model providers: generates response
- Agent toolkits → Knowledge manager: retrieves knowledge
- Agent toolkits → Tavily search: web search
- Agent toolkits → YOLO detection: image detection
- Knowledge manager → Document indexing: indexes documents
- Document indexing → Document parsers: parses files
- Knowledge manager → Vector search: vector retrieval
- Knowledge manager → LightRAG graph: graph retrieval
- Knowledge manager → MinIO storage: file storage
- Chat endpoints → Repositories: loads history
- Repositories → PostgreSQL: reads and writes
- Crop endpoints → Crop records: crop records
- Crop agent → Agent toolkits: uses tools
