How tugraph-family/chat2graph works
Project type and purpose
• Chat2Graph is a full‑stack, multi‑agent, AI‑driven graph‑database orchestration system.
• Its core (Python) implements agents, reasoning, memory, prompt chains, a toolkit, and DAL; exposed as REST APIs via Flask; with a React/TypeScript web UI; plus an SDK for programmatic embedding.
File structure
• Top‑level:
• app/core: the heart of the system (agent framework, memory, knowledge, reasoner, prompt, DAL, service, toolkit, workflow, tracer)
• app/plugin: pluggable connectors for external graph databases (Neo4j, TuGraph) and LLMs
• app/server: REST API layer (api/, manager/) and bootstrap
• web: frontend SPA (React + Ant Design + UmiJS)
• bin: build and start scripts
• test: unit, integration, and example scenarios
• Key architectural patterns:
• Layered architecture in backend (API → manager → service → core → DAL)
• Plugin pattern for GraphDB and LLM clients
• SDK wrapper around core services for external consumers
Extract additional insights from README
• One‑Active‑Many‑Passive hybrid MAS
• Dual‑LLM fast/slow thinking
• Chain‑of‑agents task decomposition
• Hierarchical memory and vector/graph stores
• RESTful Web Service and concise Python SDK
Main components
a. Frontend (web/): SPA served by Flask, handles user interaction, submits API calls for graph management and chat.
b. API Gateway (app/server/api): exposes endpoints for files, graph‑db registration, jobs, knowledge bases, sessions.
c. Manager Layer (app/server/manager): orchestrates API calls, maps them to service methods, formats views.
d. Service Layer (app/core/service): business logic—agent_service, job_service, knowledge_base_service, etc.
e. Core Engine (app/core/):
• Agent Framework (agents, leader/expert)
• Reasoner (dual_model_reasoner, mono_model…)
• Prompt Chain & Workflow (decomposition, operator config)
• Memory & Knowledge Store (vector + graph DO/DAO)
• Toolkit (pluggable tools & graph operations)
• DAL (DAO + DO + DB init/drop)
• Tracer (logging, debugging)
f. Plugin Connectors (app/plugin/neo4j, tugraph, aisuite, dbgpt): abstract GraphDB and LLM endpoints.
g. External Services:
• Graph Databases (Neo4j, TuGraph)
• LLM Providers (OpenAI, custom LLMs via plugin)
h. SDK (app/core/sdk + chat2graph.yml): programmatic client for MAS.
i. Shell Scripts (bin/): deploy and launch.
Relationships and data flow
1. User ↔ Browser UI (React)
2. UI → REST API (Flask bootstrap)
3. API → Manager → Service → Core Engine
4. Core Engine ↔ Plugin Connectors ↔ External GraphDB & LLMs
5. Core Engine ↔ DAL ↔ System DB (SQLite by default)
6. SDK clients → Core Engine (bypass REST)
7. Results bubble back up the stack to UI or SDK.
Architectural patterns & design principles
• Layered separation of concerns: presentation → orchestration → business logic → engine → persistence
• Plugin architecture: allows GraphDB/LLM extension without core changes
• Agent‑centric MAS: leader/expert agents coordinate via workflows
• Dual‑model reasoning: fast “mono_model_reasoner” + accurate “dual_model_reasoner”
• Chain‑of‑agents for task decomposition and graph planning
Final checklist
• All major layers and modules represented
• Data flow from UI → API → Core → Plugins → External → back
• SDK usage path optionally displayed
• Patterns: MAS, dual‑model, plugin, layered