# mochat-cloud/mochat architecture

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

- Interactive diagram: https://gitdiagram.com/mochat-cloud/mochat
- Repository: https://github.com/mochat-cloud/mochat

## Overview

MoChat is a multi-tenant enterprise WeChat SaaS framework. Its user-facing workflow spans tenant and enterprise setup, employee and customer management, customer engagement, and operational campaigns, with dashboard and chat-sidebar clients backed by a Hyperf API. The README documents the major capability areas; the tree identifies their implementation modules. Several backend subsystems were not sampled, so their internal call paths are not inferred. Dashed links mark documented capabilities whose implementation-level wiring was not shown.

Main entry points: [`api-server/config/routes.php`](https://github.com/mochat-cloud/mochat/blob/master/api-server/config/routes.php) (Hyperf API), [`api-server/app/core/work-contact`](https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/work-contact) (Customer management), [`dashboard/src/App.vue`](https://github.com/mochat-cloud/mochat/blob/master/dashboard/src/App.vue) (Admin dashboard), [`sidebar/src/App.vue`](https://github.com/mochat-cloud/mochat/blob/master/sidebar/src/App.vue) (Chat sidebar)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User clients"]
  node_dashboard["Admin dashboard<br/>[App.vue]"]
  node_sidebar["Chat sidebar<br/>[App.vue]"]
  node_operation["Operations tools<br/>[App.vue]"]
end

subgraph group_platform["SaaS platform"]
  node_tenants["Tenant management"]
  node_identity["Users and RBAC"]
  node_corporations["Enterprise setup"]
  node_official["Official accounts"]
end

subgraph group_customer["Customer operations"]
  node_employees["Employee directory"]
  node_contacts["Customer management"]
  node_groups["Customer groups"]
end

subgraph group_engagement["Engagement and campaigns"]
  node_media["Media library"]
  node_chattools["Chat sidebar tools"]
  node_channelcode["Channel QR codes"]
  node_greeting["Welcome messages"]
  node_batchsend["Message campaigns"]
  node_fission["Customer fission"]
  node_transfer["Contact transfer"]
  node_roomcampaigns["Group campaigns"]
end

subgraph group_runtime["API and integrations"]
  node_api["Hyperf API<br/>[routes.php]"]
  node_database[("MySQL and Redis<br/>[databases.php]")]
end

node_operator(("Business operator"))
node_employee(("WeWork employee"))
node_wework{{"WeWork platform"}}

node_operator -->|"manages"| node_dashboard
node_employee -->|"uses"| node_sidebar
node_operator -.->|"runs campaigns"| node_operation
node_dashboard -.->|"calls API"| node_api
node_sidebar -.->|"calls API"| node_api
node_operation -.->|"calls API"| node_api
node_api -.->|"serves"| node_tenants
node_api -.->|"serves"| node_identity
node_api -.->|"serves"| node_corporations
node_api -.->|"serves"| node_official
node_api -.->|"serves"| node_employees
node_api -.->|"serves"| node_contacts
node_api -.->|"serves"| node_groups
node_api -.->|"serves"| node_media
node_api -.->|"serves"| node_chattools
node_api -.->|"serves"| node_channelcode
node_api -.->|"serves"| node_greeting
node_api -.->|"serves"| node_batchsend
node_api -.->|"serves"| node_fission
node_api -.->|"serves"| node_transfer
node_api -.->|"serves"| node_roomcampaigns
node_api -.->|"persists data"| node_database
node_wework -->|"sends callbacks"| node_api
node_api -.->|"syncs employee events"| node_employees
node_api -.->|"acquires customers"| node_contacts
node_contacts -.->|"supports conversion"| node_media
node_contacts -.->|"acquires via channels"| node_channelcode
node_contacts -.->|"engages with"| node_greeting
node_contacts -.->|"receives messages"| node_batchsend
node_groups -.->|"receives campaigns"| node_roomcampaigns
node_contacts -.->|"joins campaigns"| node_fission
node_contacts -.->|"transfers ownership"| node_transfer

click node_dashboard "https://github.com/mochat-cloud/mochat/blob/master/dashboard/src/App.vue"
click node_sidebar "https://github.com/mochat-cloud/mochat/blob/master/sidebar/src/App.vue"
click node_operation "https://github.com/mochat-cloud/mochat/blob/master/operation/src/App.vue"
click node_api "https://github.com/mochat-cloud/mochat/blob/master/api-server/config/routes.php"
click node_tenants "https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/tenant"
click node_identity "https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/user"
click node_corporations "https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/corp"
click node_official "https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/official-account"
click node_employees "https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/work-employee"
click node_contacts "https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/work-contact"
click node_groups "https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/work-room"
click node_media "https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/medium"
click node_chattools "https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/chat-tool"
click node_channelcode "https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/channel-code"
click node_greeting "https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/greeting"
click node_batchsend "https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/contact-message-batch-send"
click node_fission "https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/work-fission"
click node_transfer "https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/contact-transfer"
click node_roomcampaigns "https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/room-message-batch-send"
click node_database "https://github.com/mochat-cloud/mochat/blob/master/api-server/config/autoload/databases.php"

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_dashboard,node_sidebar,node_operation toneBlue
class node_tenants,node_identity,node_corporations,node_official toneAmber
class node_employees,node_contacts,node_groups toneMint
class node_media,node_chattools,node_channelcode,node_greeting,node_batchsend,node_fission,node_transfer,node_roomcampaigns toneRose
class node_api,node_database,node_operator,node_employee,node_wework toneIndigo
```

## Components

### User clients

- [Admin dashboard](https://github.com/mochat-cloud/mochat/blob/master/dashboard/src/App.vue): `dashboard/src/App.vue`
- [Chat sidebar](https://github.com/mochat-cloud/mochat/blob/master/sidebar/src/App.vue): `sidebar/src/App.vue`
- [Operations tools](https://github.com/mochat-cloud/mochat/blob/master/operation/src/App.vue): `operation/src/App.vue`

### SaaS platform

- [Tenant management](https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/tenant): `api-server/app/core/tenant`
- [Users and RBAC](https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/user): `api-server/app/core/user`
- [Enterprise setup](https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/corp): `api-server/app/core/corp`
- [Official accounts](https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/official-account): `api-server/app/core/official-account`

### Customer operations

- [Employee directory](https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/work-employee): `api-server/app/core/work-employee`
- [Customer management](https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/work-contact): `api-server/app/core/work-contact`
- [Customer groups](https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/work-room): `api-server/app/core/work-room`

### Engagement and campaigns

- [Media library](https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/medium): `api-server/app/core/medium`
- [Chat sidebar tools](https://github.com/mochat-cloud/mochat/tree/master/api-server/app/core/chat-tool): `api-server/app/core/chat-tool`
- [Channel QR codes](https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/channel-code): `api-server/plugin/mochat/channel-code`
- [Welcome messages](https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/greeting): `api-server/plugin/mochat/greeting`
- [Message campaigns](https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/contact-message-batch-send): `api-server/plugin/mochat/contact-message-batch-send`
- [Customer fission](https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/work-fission): `api-server/plugin/mochat/work-fission`
- [Contact transfer](https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/contact-transfer): `api-server/plugin/mochat/contact-transfer`
- [Group campaigns](https://github.com/mochat-cloud/mochat/tree/master/api-server/plugin/mochat/room-message-batch-send): `api-server/plugin/mochat/room-message-batch-send`

### API and integrations

- [Hyperf API](https://github.com/mochat-cloud/mochat/blob/master/api-server/config/routes.php): `api-server/config/routes.php`
- [MySQL and Redis](https://github.com/mochat-cloud/mochat/blob/master/api-server/config/autoload/databases.php): `api-server/config/autoload/databases.php`

### Other components

- **Business operator**
- **WeWork employee**
- **WeWork platform**

## Connections

- Business operator → Admin dashboard: manages
- WeWork employee → Chat sidebar: uses
- Business operator → Operations tools: runs campaigns
- Admin dashboard → Hyperf API: calls API
- Chat sidebar → Hyperf API: calls API
- Operations tools → Hyperf API: calls API
- Hyperf API → Tenant management: serves
- Hyperf API → Users and RBAC: serves
- Hyperf API → Enterprise setup: serves (evidence: `api-server/config/routes.php`)
- Hyperf API → Official accounts: serves (evidence: `api-server/config/routes.php`)
- Hyperf API → Employee directory: serves
- Hyperf API → Customer management: serves
- Hyperf API → Customer groups: serves
- Hyperf API → Media library: serves
- Hyperf API → Chat sidebar tools: serves
- Hyperf API → Channel QR codes: serves
- Hyperf API → Welcome messages: serves
- Hyperf API → Message campaigns: serves
- Hyperf API → Customer fission: serves
- Hyperf API → Contact transfer: serves
- Hyperf API → Group campaigns: serves
- Hyperf API → MySQL and Redis: persists data
- WeWork platform → Hyperf API: sends callbacks (evidence: `api-server/config/routes.php`)
- Hyperf API → Employee directory: syncs employee events
- Hyperf API → Customer management: acquires customers
- Customer management → Media library: supports conversion
- Customer management → Channel QR codes: acquires via channels
- Customer management → Welcome messages: engages with
- Customer management → Message campaigns: receives messages
- Customer groups → Group campaigns: receives campaigns
- Customer management → Customer fission: joins campaigns
- Customer management → Contact transfer: transfers ownership
