# zcj117/live-hub architecture

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

- Interactive diagram: https://gitdiagram.com/zcj117/live-hub
- Repository: https://github.com/zcj117/live-hub

## Overview

Live-hub is a microservice local-commerce and customer-support platform. A client enters through the gateway; authentication and Agent rate limiting precede service routing. The Agent creates or resumes a session, streams chat, and uses planning/ReAct tools to answer, search knowledge, or open a ticket and transfer context. Separate branches cover commerce, orders, social features, and RAG document ingestion and question answering. The README documents service-level capabilities not represented by sampled implementation excerpts; those relationships are cited to it, while source-level edges use the excerpts or index. Storage and infrastructure links are shown only where documented.

Main entry points: [`agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java`](https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java) (Agent chat), [`gateway-service/src/main/java/com/hmdp/gateway`](https://github.com/zcj117/live-hub/tree/master/gateway-service/src/main/java/com/hmdp/gateway) (API gateway), [`rag-service/src/main/java/com/hmdp/rag/pipeline/QaPipeline.java`](https://github.com/zcj117/live-hub/blob/master/rag-service/src/main/java/com/hmdp/rag/pipeline/QaPipeline.java) (RAG question answering), [`agent-service/src/main/java/com/hmdp/agent/react/ReActEngine.java`](https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/react/ReActEngine.java) (ReAct engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and identity"]
  node_gateway["API gateway"]
  node_user["User service"]
end

subgraph group_commerce["Commerce and community"]
  node_shop["Shop service"]
  node_voucher["Voucher service"]
  node_order["Order service"]
  node_social["Social service"]
end

subgraph group_intelligence["Knowledge and support"]
  node_agent["Agent chat"]
  node_session["Session lifecycle"]
  node_memory["Chat memory"]
  node_planner["Intent planning"]
  node_react["ReAct engine<br/>[ReActEngine.java]"]
  node_tools["Business tools"]
  node_security["Input/output safety"]
  node_ticket["Ticket workflow<br/>[TicketService.java]"]
  node_transfer["Human handoff"]
  node_sse["SSE sessions"]
  node_ragdocs["Knowledge documents"]
  node_ragqa["RAG question answering<br/>[QaPipeline.java]"]
end

subgraph group_operations["Persistence and messaging"]
  node_redis[("Redis")]
  node_databases[("Service databases")]
  node_mq["RocketMQ"]
end

node_client(("Web client"))
node_glm["GLM APIs"]

node_client -->|"sends requests"| node_gateway
node_gateway -->|"routes requests"| node_user
node_gateway -->|"routes and limits"| node_agent
node_gateway -->|"routes requests"| node_shop
node_gateway -->|"routes requests"| node_voucher
node_gateway -->|"routes requests"| node_order
node_gateway -->|"routes requests"| node_social
node_gateway -->|"routes requests"| node_ragqa
node_agent -->|"manages sessions"| node_session
node_agent -->|"loads conversation"| node_memory
node_agent -->|"plans intent"| node_planner
node_agent -->|"runs decisions"| node_react
node_react -->|"executes tools"| node_tools
node_agent -->|"checks messages"| node_security
node_agent -->|"starts complaint flow"| node_ticket
node_agent -->|"triggers handoff"| node_transfer
node_transfer -->|"creates handoff ticket"| node_ticket
node_agent -->|"streams events"| node_sse
node_react -->|"requests completions"| node_glm
node_tools -->|"searches knowledge"| node_ragqa
node_ragdocs -->|"queues processing"| node_mq
node_ragqa -->|"generates answers"| node_glm
node_ragdocs -->|"stores chunks"| node_databases
node_ragqa -->|"retrieves chunks"| node_databases
node_session -->|"stores sessions"| node_databases
node_ticket -->|"stores tickets"| node_databases
node_memory -->|"stores history"| node_redis
node_shop -->|"reads and writes shops"| node_databases
node_voucher -->|"manages vouchers"| node_databases
node_order -->|"processes orders asynchronously"| node_mq
node_social -->|"maintains feeds"| node_redis
node_user -->|"stores login sessions"| node_redis

click node_gateway "https://github.com/zcj117/live-hub/tree/master/gateway-service/src/main/java/com/hmdp/gateway"
click node_user "https://github.com/zcj117/live-hub/tree/master/user-service/src/main/java/com/hmdp/user"
click node_shop "https://github.com/zcj117/live-hub/tree/master/shop-service/src/main/java/com/hmdp/shop"
click node_voucher "https://github.com/zcj117/live-hub/tree/master/voucher-service/src/main/java/com/hmdp/voucher"
click node_order "https://github.com/zcj117/live-hub/tree/master/order-service/src/main/java/com/hmdp/order"
click node_social "https://github.com/zcj117/live-hub/tree/master/social-service/src/main/java/com/hmdp/social"
click node_agent "https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java"
click node_session "https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/service/AgentSessionService.java"
click node_memory "https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/memory/ChatMemoryService.java"
click node_planner "https://github.com/zcj117/live-hub/tree/master/agent-service/src/main/java/com/hmdp/agent/planner"
click node_react "https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/react/ReActEngine.java"
click node_tools "https://github.com/zcj117/live-hub/tree/master/agent-service/src/main/java/com/hmdp/agent/tool"
click node_security "https://github.com/zcj117/live-hub/tree/master/agent-service/src/main/java/com/hmdp/agent/security"
click node_ticket "https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/ticket/TicketService.java"
click node_transfer "https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/transfer/TransferService.java"
click node_sse "https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/sse/SseSessionManager.java"
click node_ragdocs "https://github.com/zcj117/live-hub/blob/master/rag-service/src/main/java/com/hmdp/rag/pipeline/DocumentPipeline.java"
click node_ragqa "https://github.com/zcj117/live-hub/blob/master/rag-service/src/main/java/com/hmdp/rag/pipeline/QaPipeline.java"

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_gateway,node_user,node_client toneBlue
class node_shop,node_voucher,node_order,node_social toneAmber
class node_agent,node_session,node_memory,node_planner,node_react,node_tools,node_security,node_ticket,node_transfer,node_sse,node_ragdocs,node_ragqa,node_glm toneMint
class node_redis,node_databases,node_mq toneRose
```

## Components

### Entry and identity

- [API gateway](https://github.com/zcj117/live-hub/tree/master/gateway-service/src/main/java/com/hmdp/gateway): `gateway-service/src/main/java/com/hmdp/gateway`
- [User service](https://github.com/zcj117/live-hub/tree/master/user-service/src/main/java/com/hmdp/user): `user-service/src/main/java/com/hmdp/user`

### Commerce and community

- [Shop service](https://github.com/zcj117/live-hub/tree/master/shop-service/src/main/java/com/hmdp/shop): `shop-service/src/main/java/com/hmdp/shop`
- [Voucher service](https://github.com/zcj117/live-hub/tree/master/voucher-service/src/main/java/com/hmdp/voucher): `voucher-service/src/main/java/com/hmdp/voucher`
- [Order service](https://github.com/zcj117/live-hub/tree/master/order-service/src/main/java/com/hmdp/order): `order-service/src/main/java/com/hmdp/order`
- [Social service](https://github.com/zcj117/live-hub/tree/master/social-service/src/main/java/com/hmdp/social): `social-service/src/main/java/com/hmdp/social`

### Knowledge and support

- [Agent chat](https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java): `agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java`
- [Session lifecycle](https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/service/AgentSessionService.java): `agent-service/src/main/java/com/hmdp/agent/service/AgentSessionService.java`
- [Chat memory](https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/memory/ChatMemoryService.java): `agent-service/src/main/java/com/hmdp/agent/memory/ChatMemoryService.java`
- [Intent planning](https://github.com/zcj117/live-hub/tree/master/agent-service/src/main/java/com/hmdp/agent/planner): `agent-service/src/main/java/com/hmdp/agent/planner`
- [ReAct engine](https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/react/ReActEngine.java): `agent-service/src/main/java/com/hmdp/agent/react/ReActEngine.java`
- [Business tools](https://github.com/zcj117/live-hub/tree/master/agent-service/src/main/java/com/hmdp/agent/tool): `agent-service/src/main/java/com/hmdp/agent/tool`
- [Input/output safety](https://github.com/zcj117/live-hub/tree/master/agent-service/src/main/java/com/hmdp/agent/security): `agent-service/src/main/java/com/hmdp/agent/security`
- [Ticket workflow](https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/ticket/TicketService.java): `agent-service/src/main/java/com/hmdp/agent/ticket/TicketService.java`
- [Human handoff](https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/transfer/TransferService.java): `agent-service/src/main/java/com/hmdp/agent/transfer/TransferService.java`
- [SSE sessions](https://github.com/zcj117/live-hub/blob/master/agent-service/src/main/java/com/hmdp/agent/sse/SseSessionManager.java): `agent-service/src/main/java/com/hmdp/agent/sse/SseSessionManager.java`
- [Knowledge documents](https://github.com/zcj117/live-hub/blob/master/rag-service/src/main/java/com/hmdp/rag/pipeline/DocumentPipeline.java): `rag-service/src/main/java/com/hmdp/rag/pipeline/DocumentPipeline.java`
- [RAG question answering](https://github.com/zcj117/live-hub/blob/master/rag-service/src/main/java/com/hmdp/rag/pipeline/QaPipeline.java): `rag-service/src/main/java/com/hmdp/rag/pipeline/QaPipeline.java`

### Persistence and messaging

- **Redis**
- **Service databases**
- **RocketMQ**

### Other components

- **Web client**
- **GLM APIs**

## Connections

- Web client → API gateway: sends requests
- API gateway → User service: routes requests
- API gateway → Agent chat: routes and limits
- API gateway → Shop service: routes requests
- API gateway → Voucher service: routes requests
- API gateway → Order service: routes requests
- API gateway → Social service: routes requests
- API gateway → RAG question answering: routes requests
- Agent chat → Session lifecycle: manages sessions (evidence: `agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java`)
- Agent chat → Chat memory: loads conversation (evidence: `agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java`)
- Agent chat → Intent planning: plans intent (evidence: `agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java`)
- Agent chat → ReAct engine: runs decisions (evidence: `agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java`)
- ReAct engine → Business tools: executes tools (evidence: `agent-service/src/main/java/com/hmdp/agent/react/ReActEngine.java`)
- Agent chat → Input/output safety: checks messages (evidence: `agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java`)
- Agent chat → Ticket workflow: starts complaint flow
- Agent chat → Human handoff: triggers handoff (evidence: `agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java`)
- Human handoff → Ticket workflow: creates handoff ticket (evidence: `agent-service/src/main/java/com/hmdp/agent/transfer/TransferService.java`)
- Agent chat → SSE sessions: streams events (evidence: `agent-service/src/main/java/com/hmdp/agent/service/ChatOrchestratorService.java`)
- ReAct engine → GLM APIs: requests completions (evidence: `agent-service/src/main/java/com/hmdp/agent/react/ReActEngine.java`)
- Business tools → RAG question answering: searches knowledge
- Knowledge documents → RocketMQ: queues processing
- RAG question answering → GLM APIs: generates answers
- Knowledge documents → Service databases: stores chunks
- RAG question answering → Service databases: retrieves chunks
- Session lifecycle → Service databases: stores sessions
- Ticket workflow → Service databases: stores tickets
- Chat memory → Redis: stores history (evidence: `agent-service/src/main/java/com/hmdp/agent/memory/ChatMemoryService.java`)
- Shop service → Service databases: reads and writes shops
- Voucher service → Service databases: manages vouchers
- Order service → RocketMQ: processes orders asynchronously
- Social service → Redis: maintains feeds
- User service → Redis: stores login sessions
