How huantian3365/ai-personal-agent works
This is an Electron desktop chat application with a React renderer, a main-process service layer, and a LangGraph-based conversational agent. The principal workflow is: a user works in the chat UI, renderer requests cross the preload IPC bridge, main-process handlers coordinate conversation execution, and the core streams agent events while persisting conversation state in SQLite. The graph preserves the workspace/conversation, settings, tools, and checkpoint subsystems. Some handler-to-runtime and renderer-to-IPC call sites were not excerpted, so those links are omitted rather than inferred.
Main entry points: main/index.ts App Bootstrap · database/index.ts SQLite Database · routers.tsx Page Router · ipc/index.ts IPC Registry
Components 31
Renderer UI
- Renderer App
src/renderer/src/main.tsx - Page Router
src/renderer/src/router/routers.tsx - Chat Page
src/renderer/src/pages/Chat/index.tsx - Conversation Sidebar
src/renderer/src/layouts/components/Sidebar.tsx - Settings Page
src/renderer/src/pages/Setting/index.tsx - Welcome Page
src/renderer/src/pages/Welcome/index.tsx
IPC Bridge
- Preload API
src/preload/mount.ts - Conversation API
src/preload/api/conversation.ts - IPC Channels
src/shared/ipc.ts
Main Services
- App Bootstrap
src/main/index.ts - IPC Registry
src/main/ipc/index.ts - Agent Handler
src/main/ipc/impl/agent.ts - Conversation Handler
src/main/ipc/impl/conversation.ts - Configuration
src/main/config/file/config.ts - SQLite Database
src/main/database/index.ts - Schema Migrations
src/main/database/init/migrate.ts - SQLite Repository
src/main/database/service/impl/sqlite/index.ts
Agent Core
- Agent Loop
src/core/agent/loop.ts - Agent Initialization
src/core/agent/init.ts - Event Emitter
src/core/agent/emitter.ts - Stream Parsing
src/core/message/parseStream.ts - Message History
src/core/message/historyMessage.ts - Checkpoint Store
src/core/graph/checkpoint.ts - Graph Nodes
src/core/graph/nodes.ts - Tool Registration
src/core/tools/register.ts - File Tool
src/core/tools/impl/file.ts - Shell Tool
src/core/tools/impl/shell.ts - Time Tool
src/core/tools/impl/time.ts - Core Lifecycle
src/core/index.ts - Core Logging
src/core/utils/log.ts
Other components
- User
Connections 32
- User → Renderer App: uses
- Renderer App → Page Router: mounts
src/renderer/src/main.tsx - Page Router → Chat Page: routes
src/renderer/src/router/routers.tsx - Page Router → Settings Page: routes
src/renderer/src/router/routers.tsx - Page Router → Welcome Page: routes
src/renderer/src/router/routers.tsx - Preload API → Conversation API: exposes
src/preload/mount.ts - Conversation API → IPC Channels: invokes channels
src/preload/api/conversation.ts - Preload API → IPC Channels: uses channels
src/preload/mount.ts - App Bootstrap → IPC Registry: mounts handlers
src/main/index.ts - App Bootstrap → SQLite Database: opens
src/main/index.ts - App Bootstrap → Configuration: initializes
src/main/index.ts - App Bootstrap → Core Lifecycle: initializes
src/main/index.ts - App Bootstrap → Renderer App: loads window
src/main/index.ts - IPC Registry → IPC Channels: uses channels
src/main/ipc/index.ts - IPC Registry → Agent Handler: registers
src/main/ipc/index.ts - IPC Registry → Conversation Handler: registers
src/main/ipc/index.ts - SQLite Database → Schema Migrations: migrates schema
src/main/database/index.ts - SQLite Database → SQLite Repository: creates repository
src/main/database/index.ts - Schema Migrations → SQLite Database: updates schema
src/main/database/init/migrate.ts - Core Lifecycle → Checkpoint Store: opens store
src/core/index.ts - Core Lifecycle → Core Logging: configures
src/core/index.ts - Checkpoint Store → SQLite Database: reads and writes
src/core/graph/checkpoint.ts - Agent Loop → Agent Initialization: initializes
src/core/agent/loop.ts - Agent Loop → Event Emitter: emits events
src/core/agent/loop.ts - Agent Loop → Stream Parsing: parses stream
src/core/agent/loop.ts - Message History → Stream Parsing: uses parser
src/core/message/historyMessage.ts - Agent Handler → Agent Loop: dispatches
- Conversation Handler → SQLite Repository: queries
- Graph Nodes → Tool Registration: uses tools
- Tool Registration → File Tool: registers
- Tool Registration → Shell Tool: registers
- Tool Registration → Time Tool: registers