# dotanminh/zaplo architecture

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

- Interactive diagram: https://gitdiagram.com/dotanminh/zaplo
- Repository: https://github.com/dotanminh/zaplo

## Overview

Zaplo is a local-first Electron desktop workspace for sales, marketing, and customer-support teams managing Zalo and Facebook accounts. Users connect accounts, work from a unified inbox, and then use CRM, AI agents, scheduled posting, workflows, integrations, and ERP tools; records and media remain local. The runtime centers on Electron IPC, domain services, and SQLite-backed state. The README documents the product capabilities; source-index references and excerpts establish only selected implementation relationships, so unverified UI-to-handler links are dashed.

Main entry points: [`src/services/database/DatabaseService.ts`](https://github.com/dotanminh/zaplo/blob/main/src/services/database/DatabaseService.ts) (SQLite database), [`src/services/workflow/WorkflowEngineService.ts`](https://github.com/dotanminh/zaplo/blob/main/src/services/workflow/WorkflowEngineService.ts) (Workflow engine), [`electron/ipc`](https://github.com/dotanminh/zaplo/tree/main/electron/ipc) (IPC handlers), [`src/ui/App.tsx`](https://github.com/dotanminh/zaplo/blob/main/src/ui/App.tsx) (Workspace UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop workspace"]
  node_app["Workspace UI<br/>[App.tsx]"]
  node_ipc["Renderer IPC client<br/>[ipc.ts]"]
  node_main["Electron main<br/>[main.ts]"]
  node_handlers["IPC handlers"]
end

subgraph group_messaging["Messaging channels"]
  node_inbox["Unified inbox"]
  node_zalo["Zalo accounts<br/>[ZaloService.ts]"]
  node_connections["Zalo connections"]
  node_facebook["Facebook messaging<br/>[FacebookService.ts]"]
end

subgraph group_automation["Automation"]
  node_ai["AI assistant"]
  node_agents["Agent hub"]
  node_posting["Scheduled posting"]
  node_workflow["Workflow engine"]
end

subgraph group_operations["Business operations"]
  node_crm["CRM<br/>[CRMQueueService.ts]"]
  node_integrations["External integrations"]
  node_erp["ERP modules"]
  node_employees["Employee management<br/>[EmployeeService.ts]"]
end

subgraph group_runtime["Local runtime"]
  node_database[("SQLite database<br/>[DatabaseService.ts]")]
  node_workspace["Workspace manager"]
  node_media["Local media storage"]
  node_events["Event broadcaster"]
end

node_team(("Sales team"))
node_facebookaccounts(("Facebook accounts"))
node_zaloaccounts(("Zalo accounts"))
node_externalapis(("Service APIs"))

node_team -->|"uses"| node_app
node_app -->|"renders"| node_inbox
node_app -.->|"requests data"| node_ipc
node_ipc -.->|"invokes"| node_handlers
node_main -->|"registers"| node_handlers
node_main -->|"initializes"| node_database
node_zaloaccounts -->|"connect"| node_zalo
node_zalo -->|"manages sessions"| node_connections
node_facebookaccounts -->|"connect"| node_facebook
node_inbox -.->|"communicates"| node_zalo
node_inbox -.->|"communicates"| node_facebook
node_team -->|"manages contacts"| node_crm
node_team -->|"configures agents"| node_agents
node_team -->|"schedules posts"| node_posting
node_team -->|"builds workflows"| node_workflow
node_team -->|"uses ERP"| node_erp
node_team -->|"connects services"| node_integrations
node_workflow -->|"reads and writes"| node_database
node_workflow -->|"publishes events"| node_events
node_workflow -->|"dispatches actions"| node_integrations
node_workflow -->|"requests assistance"| node_ai
node_workflow -->|"sends messages"| node_facebook
node_integrations -->|"calls adapters"| node_externalapis
node_database -->|"uses workspace config"| node_workspace
node_database -->|"stores media folders"| node_media
node_handlers -->|"reads and writes"| node_database
node_handlers -->|"controls workflows"| node_workflow
node_handlers -->|"manages files"| node_media
node_events -->|"reads state"| node_database
node_events -->|"uses local files"| node_media
node_posting -->|"reads and writes"| node_database
node_crm -->|"reads and writes"| node_database
node_employees -.->|"syncs data"| node_externalapis

click node_app "https://github.com/dotanminh/zaplo/blob/main/src/ui/App.tsx"
click node_ipc "https://github.com/dotanminh/zaplo/blob/main/src/ui/lib/ipc.ts"
click node_main "https://github.com/dotanminh/zaplo/blob/main/electron/main.ts"
click node_handlers "https://github.com/dotanminh/zaplo/tree/main/electron/ipc"
click node_inbox "https://github.com/dotanminh/zaplo/tree/main/src/ui/components/chat"
click node_zalo "https://github.com/dotanminh/zaplo/blob/main/src/services/zalo/ZaloService.ts"
click node_connections "https://github.com/dotanminh/zaplo/blob/main/src/utils/ConnectionManager.ts"
click node_facebook "https://github.com/dotanminh/zaplo/blob/main/src/services/facebook/FacebookService.ts"
click node_crm "https://github.com/dotanminh/zaplo/blob/main/src/services/crm/CRMQueueService.ts"
click node_ai "https://github.com/dotanminh/zaplo/blob/main/src/services/ai/AIAssistantService.ts"
click node_agents "https://github.com/dotanminh/zaplo/tree/main/src/services/chat-agent"
click node_posting "https://github.com/dotanminh/zaplo/blob/main/src/services/posting/posting-scheduler-service.ts"
click node_workflow "https://github.com/dotanminh/zaplo/blob/main/src/services/workflow/WorkflowEngineService.ts"
click node_integrations "https://github.com/dotanminh/zaplo/blob/main/src/services/integrations/IntegrationRegistry.ts"
click node_erp "https://github.com/dotanminh/zaplo/tree/main/src/services/erp"
click node_employees "https://github.com/dotanminh/zaplo/blob/main/src/services/employee/EmployeeService.ts"
click node_database "https://github.com/dotanminh/zaplo/blob/main/src/services/database/DatabaseService.ts"
click node_workspace "https://github.com/dotanminh/zaplo/blob/main/src/utils/WorkspaceManager.ts"
click node_media "https://github.com/dotanminh/zaplo/blob/main/src/services/file/FileStorageService.ts"
click node_events "https://github.com/dotanminh/zaplo/blob/main/src/services/event/EventBroadcaster.ts"

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_app,node_ipc,node_main,node_handlers toneBlue
class node_inbox,node_zalo,node_connections,node_facebook toneAmber
class node_ai,node_agents,node_posting,node_workflow,node_externalapis toneMint
class node_crm,node_integrations,node_erp,node_employees toneRose
class node_database,node_workspace,node_media,node_events,node_team,node_facebookaccounts,node_zaloaccounts toneIndigo
```

## Components

### Desktop workspace

- [Workspace UI](https://github.com/dotanminh/zaplo/blob/main/src/ui/App.tsx): `src/ui/App.tsx`
- [Renderer IPC client](https://github.com/dotanminh/zaplo/blob/main/src/ui/lib/ipc.ts): `src/ui/lib/ipc.ts`
- [Electron main](https://github.com/dotanminh/zaplo/blob/main/electron/main.ts): `electron/main.ts`
- [IPC handlers](https://github.com/dotanminh/zaplo/tree/main/electron/ipc): `electron/ipc`

### Messaging channels

- [Unified inbox](https://github.com/dotanminh/zaplo/tree/main/src/ui/components/chat): `src/ui/components/chat`
- [Zalo accounts](https://github.com/dotanminh/zaplo/blob/main/src/services/zalo/ZaloService.ts): `src/services/zalo/ZaloService.ts`
- [Zalo connections](https://github.com/dotanminh/zaplo/blob/main/src/utils/ConnectionManager.ts): `src/utils/ConnectionManager.ts`
- [Facebook messaging](https://github.com/dotanminh/zaplo/blob/main/src/services/facebook/FacebookService.ts): `src/services/facebook/FacebookService.ts`

### Automation

- [AI assistant](https://github.com/dotanminh/zaplo/blob/main/src/services/ai/AIAssistantService.ts): `src/services/ai/AIAssistantService.ts`
- [Agent hub](https://github.com/dotanminh/zaplo/tree/main/src/services/chat-agent): `src/services/chat-agent`
- [Scheduled posting](https://github.com/dotanminh/zaplo/blob/main/src/services/posting/posting-scheduler-service.ts): `src/services/posting/posting-scheduler-service.ts`
- [Workflow engine](https://github.com/dotanminh/zaplo/blob/main/src/services/workflow/WorkflowEngineService.ts): `src/services/workflow/WorkflowEngineService.ts`

### Business operations

- [CRM](https://github.com/dotanminh/zaplo/blob/main/src/services/crm/CRMQueueService.ts): `src/services/crm/CRMQueueService.ts`
- [External integrations](https://github.com/dotanminh/zaplo/blob/main/src/services/integrations/IntegrationRegistry.ts): `src/services/integrations/IntegrationRegistry.ts`
- [ERP modules](https://github.com/dotanminh/zaplo/tree/main/src/services/erp): `src/services/erp`
- [Employee management](https://github.com/dotanminh/zaplo/blob/main/src/services/employee/EmployeeService.ts): `src/services/employee/EmployeeService.ts`

### Local runtime

- [SQLite database](https://github.com/dotanminh/zaplo/blob/main/src/services/database/DatabaseService.ts): `src/services/database/DatabaseService.ts`
- [Workspace manager](https://github.com/dotanminh/zaplo/blob/main/src/utils/WorkspaceManager.ts): `src/utils/WorkspaceManager.ts`
- [Local media storage](https://github.com/dotanminh/zaplo/blob/main/src/services/file/FileStorageService.ts): `src/services/file/FileStorageService.ts`
- [Event broadcaster](https://github.com/dotanminh/zaplo/blob/main/src/services/event/EventBroadcaster.ts): `src/services/event/EventBroadcaster.ts`

### Other components

- **Sales team**
- **Facebook accounts**
- **Zalo accounts**
- **Service APIs**

## Connections

- Sales team → Workspace UI: uses (evidence: `README.md`)
- Workspace UI → Unified inbox: renders (evidence: `src/ui/App.tsx`)
- Workspace UI → Renderer IPC client: requests data (evidence: `src/ui/App.tsx`)
- Renderer IPC client → IPC handlers: invokes
- Electron main → IPC handlers: registers (evidence: `electron/main.ts`)
- Electron main → SQLite database: initializes (evidence: `electron/main.ts`)
- Zalo accounts → Zalo accounts: connect (evidence: `README.md`)
- Zalo accounts → Zalo connections: manages sessions (evidence: `src/utils/ConnectionManager.ts`)
- Facebook accounts → Facebook messaging: connect (evidence: `README.md`)
- Unified inbox → Zalo accounts: communicates
- Unified inbox → Facebook messaging: communicates
- Sales team → CRM: manages contacts (evidence: `README.md`)
- Sales team → Agent hub: configures agents (evidence: `README.md`)
- Sales team → Scheduled posting: schedules posts (evidence: `README.md`)
- Sales team → Workflow engine: builds workflows (evidence: `README.md`)
- Sales team → ERP modules: uses ERP (evidence: `README.md`)
- Sales team → External integrations: connects services (evidence: `README.md`)
- Workflow engine → SQLite database: reads and writes (evidence: `src/services/workflow/WorkflowEngineService.ts`)
- Workflow engine → Event broadcaster: publishes events (evidence: `src/services/workflow/WorkflowEngineService.ts`)
- Workflow engine → External integrations: dispatches actions (evidence: `src/services/workflow/WorkflowEngineService.ts`)
- Workflow engine → AI assistant: requests assistance (evidence: `src/services/workflow/WorkflowEngineService.ts`)
- Workflow engine → Facebook messaging: sends messages (evidence: `src/services/workflow/WorkflowEngineService.ts`)
- External integrations → Service APIs: calls adapters (evidence: `src/services/integrations/IntegrationRegistry.ts`)
- SQLite database → Workspace manager: uses workspace config (evidence: `src/services/database/DatabaseService.ts`)
- SQLite database → Local media storage: stores media folders (evidence: `src/services/database/DatabaseService.ts`)
- IPC handlers → SQLite database: reads and writes (evidence: `electron/ipc/databaseIpc.ts`)
- IPC handlers → Workflow engine: controls workflows (evidence: `electron/ipc/databaseIpc.ts`)
- IPC handlers → Local media storage: manages files (evidence: `electron/ipc/databaseIpc.ts`)
- Event broadcaster → SQLite database: reads state (evidence: `src/services/event/EventBroadcaster.ts`)
- Event broadcaster → Local media storage: uses local files (evidence: `src/services/event/EventBroadcaster.ts`)
- Scheduled posting → SQLite database: reads and writes (evidence: `src/services/posting/posting-scheduler-service.ts`)
- CRM → SQLite database: reads and writes (evidence: `src/services/crm/CRMQueueService.ts`)
- Employee management → Service APIs: syncs data
