# nclamvn/viet-erp architecture

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

- Interactive diagram: https://gitdiagram.com/nclamvn/viet-erp
- Repository: https://github.com/nclamvn/viet-erp

## Overview

VietERP is a multi-application ERP platform for Vietnamese enterprises. A typical user works in a domain app—such as CRM, HRM, manufacturing, commerce, or accounting—and receives operational records, reports, or analysis. The README also documents shared platform capabilities, including identity, events, search, notifications, and Vietnamese compliance. The graph preserves the principal domain apps and the sampled ExcelAI and CRM internals. Most app-to-app wiring is not shown in the excerpts, so only the documented event-bus relationship is connected; unsampled app details are represented at supported directory paths.

Main entry points: [`apps/CRM`](https://github.com/nclamvn/viet-erp/tree/main/apps/CRM) (CRM App), [`apps/ExcelAI/src/App.tsx`](https://github.com/nclamvn/viet-erp/blob/main/apps/ExcelAI/src/App.tsx) (ExcelAI), [`apps/HRM`](https://github.com/nclamvn/viet-erp/tree/main/apps/HRM) (HRM), [`packages/events`](https://github.com/nclamvn/viet-erp/tree/main/packages/events) (Event Bus)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_domain["ERP Domain Apps"]
  node_accounting["Accounting"]
  node_hrm["HRM"]
  node_mrp["Manufacturing"]
  node_ecommerce["Ecommerce"]
  node_otb["Open-to-Buy"]
  node_tpm["TPM"]
  node_recruitment["Recruitment Applications"]
end

subgraph group_shared["Shared Platform"]
  node_events["Event Bus"]
  node_auth["Authentication"]
  node_search["Federated Search"]
  node_notifications["Notifications"]
  node_vietnam["Vietnam Compliance"]
end

subgraph group_crm["CRM Operations"]
  node_crmapp["CRM App"]
  node_campaigns["Audience Rules<br/>[rule-engine.ts]"]
  node_audience["Audience Resolution<br/>[audience.ts]"]
end

subgraph group_excelai["ExcelAI Analysis"]
  node_excel["ExcelAI<br/>[App.tsx]"]
  node_autoviz["Auto Visualization"]
  node_macros["AI Macros"]
  node_proactive["Proactive Insights"]
  node_calc["Formula Worker<br/>[calc.worker.ts]"]
end

subgraph group_pm["Project Management"]
  node_pm["Project Management"]
  node_pmexport["Project Exports<br/>[ExportEngine.jsx]"]
end

node_user(("Enterprise User"))

node_user -->|"uses"| node_accounting
node_user -->|"uses"| node_hrm
node_user -->|"uses"| node_mrp
node_user -->|"uses"| node_ecommerce
node_user -->|"uses"| node_otb
node_user -->|"uses"| node_tpm
node_user -->|"manages customers"| node_crmapp
node_user -->|"analyzes spreadsheets"| node_excel
node_user -->|"manages projects"| node_pm
node_accounting -.->|"applies compliance"| node_vietnam
node_hrm -.->|"shares module events"| node_events
node_crmapp -.->|"shares module events"| node_events
node_mrp -.->|"shares module events"| node_events
node_crmapp -.->|"uses SSO and RBAC"| node_auth
node_crmapp -.->|"supports cross-module search"| node_search
node_crmapp -.->|"uses notifications"| node_notifications
node_campaigns -->|"resolves contacts"| node_audience
node_recruitment -.->|"supports hiring"| node_hrm
node_excel -.->|"creates visualizations"| node_autoviz
node_excel -.->|"runs macros"| node_macros
node_excel -.->|"surfaces suggestions"| node_proactive
node_excel -->|"dispatches calculations"| node_calc
node_pm -->|"offers exports"| node_pmexport

click node_accounting "https://github.com/nclamvn/viet-erp/tree/main/apps/Accounting"
click node_hrm "https://github.com/nclamvn/viet-erp/tree/main/apps/HRM"
click node_mrp "https://github.com/nclamvn/viet-erp/tree/main/apps/MRP"
click node_ecommerce "https://github.com/nclamvn/viet-erp/tree/main/apps/Ecommerce"
click node_otb "https://github.com/nclamvn/viet-erp/tree/main/apps/OTB"
click node_tpm "https://github.com/nclamvn/viet-erp/tree/main/apps/TPM-api-nestjs"
click node_events "https://github.com/nclamvn/viet-erp/tree/main/packages/events"
click node_auth "https://github.com/nclamvn/viet-erp/tree/main/packages/auth"
click node_search "https://github.com/nclamvn/viet-erp/tree/main/packages/search"
click node_notifications "https://github.com/nclamvn/viet-erp/tree/main/packages/notifications"
click node_vietnam "https://github.com/nclamvn/viet-erp/tree/main/packages/vietnam"
click node_crmapp "https://github.com/nclamvn/viet-erp/tree/main/apps/CRM"
click node_campaigns "https://github.com/nclamvn/viet-erp/blob/main/apps/CRM/src/lib/campaigns/rule-engine.ts"
click node_audience "https://github.com/nclamvn/viet-erp/blob/main/apps/CRM/src/lib/campaigns/audience.ts"
click node_recruitment "https://github.com/nclamvn/viet-erp/blob/main/apps/HRM-AI/src/lib/recruitment/services/application.service.ts"
click node_excel "https://github.com/nclamvn/viet-erp/blob/main/apps/ExcelAI/src/App.tsx"
click node_autoviz "https://github.com/nclamvn/viet-erp/tree/main/apps/ExcelAI/src/autoviz"
click node_macros "https://github.com/nclamvn/viet-erp/tree/main/apps/ExcelAI/src/macros"
click node_proactive "https://github.com/nclamvn/viet-erp/tree/main/apps/ExcelAI/src/proactive"
click node_calc "https://github.com/nclamvn/viet-erp/blob/main/apps/ExcelAI/src/workers/calc.worker.ts"
click node_pm "https://github.com/nclamvn/viet-erp/tree/main/apps/PM"
click node_pmexport "https://github.com/nclamvn/viet-erp/blob/main/apps/PM/src/components/ExportEngine.jsx"

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_accounting,node_hrm,node_mrp,node_ecommerce,node_otb,node_tpm,node_recruitment,node_user toneBlue
class node_events,node_auth,node_search,node_notifications,node_vietnam toneAmber
class node_crmapp,node_campaigns,node_audience toneMint
class node_excel,node_autoviz,node_macros,node_proactive,node_calc toneRose
class node_pm,node_pmexport toneIndigo
```

## Components

### ERP Domain Apps

- [Accounting](https://github.com/nclamvn/viet-erp/tree/main/apps/Accounting): `apps/Accounting`
- [HRM](https://github.com/nclamvn/viet-erp/tree/main/apps/HRM): `apps/HRM`
- [Manufacturing](https://github.com/nclamvn/viet-erp/tree/main/apps/MRP): `apps/MRP`
- [Ecommerce](https://github.com/nclamvn/viet-erp/tree/main/apps/Ecommerce): `apps/Ecommerce`
- [Open-to-Buy](https://github.com/nclamvn/viet-erp/tree/main/apps/OTB): `apps/OTB`
- [TPM](https://github.com/nclamvn/viet-erp/tree/main/apps/TPM-api-nestjs): `apps/TPM-api-nestjs`
- [Recruitment Applications](https://github.com/nclamvn/viet-erp/blob/main/apps/HRM-AI/src/lib/recruitment/services/application.service.ts): `apps/HRM-AI/src/lib/recruitment/services/application.service.ts`

### Shared Platform

- [Event Bus](https://github.com/nclamvn/viet-erp/tree/main/packages/events): `packages/events`
- [Authentication](https://github.com/nclamvn/viet-erp/tree/main/packages/auth): `packages/auth`
- [Federated Search](https://github.com/nclamvn/viet-erp/tree/main/packages/search): `packages/search`
- [Notifications](https://github.com/nclamvn/viet-erp/tree/main/packages/notifications): `packages/notifications`
- [Vietnam Compliance](https://github.com/nclamvn/viet-erp/tree/main/packages/vietnam): `packages/vietnam`

### CRM Operations

- [CRM App](https://github.com/nclamvn/viet-erp/tree/main/apps/CRM): `apps/CRM`
- [Audience Rules](https://github.com/nclamvn/viet-erp/blob/main/apps/CRM/src/lib/campaigns/rule-engine.ts): `apps/CRM/src/lib/campaigns/rule-engine.ts`
- [Audience Resolution](https://github.com/nclamvn/viet-erp/blob/main/apps/CRM/src/lib/campaigns/audience.ts): `apps/CRM/src/lib/campaigns/audience.ts`

### ExcelAI Analysis

- [ExcelAI](https://github.com/nclamvn/viet-erp/blob/main/apps/ExcelAI/src/App.tsx): `apps/ExcelAI/src/App.tsx`
- [Auto Visualization](https://github.com/nclamvn/viet-erp/tree/main/apps/ExcelAI/src/autoviz): `apps/ExcelAI/src/autoviz`
- [AI Macros](https://github.com/nclamvn/viet-erp/tree/main/apps/ExcelAI/src/macros): `apps/ExcelAI/src/macros`
- [Proactive Insights](https://github.com/nclamvn/viet-erp/tree/main/apps/ExcelAI/src/proactive): `apps/ExcelAI/src/proactive`
- [Formula Worker](https://github.com/nclamvn/viet-erp/blob/main/apps/ExcelAI/src/workers/calc.worker.ts): `apps/ExcelAI/src/workers/calc.worker.ts`

### Project Management

- [Project Management](https://github.com/nclamvn/viet-erp/tree/main/apps/PM): `apps/PM`
- [Project Exports](https://github.com/nclamvn/viet-erp/blob/main/apps/PM/src/components/ExportEngine.jsx): `apps/PM/src/components/ExportEngine.jsx`

### Other components

- **Enterprise User**

## Connections

- Enterprise User → Accounting: uses
- Enterprise User → HRM: uses
- Enterprise User → Manufacturing: uses
- Enterprise User → Ecommerce: uses
- Enterprise User → Open-to-Buy: uses
- Enterprise User → TPM: uses
- Enterprise User → CRM App: manages customers
- Enterprise User → ExcelAI: analyzes spreadsheets
- Enterprise User → Project Management: manages projects
- Accounting → Vietnam Compliance: applies compliance
- HRM → Event Bus: shares module events
- CRM App → Event Bus: shares module events
- Manufacturing → Event Bus: shares module events
- CRM App → Authentication: uses SSO and RBAC
- CRM App → Federated Search: supports cross-module search
- CRM App → Notifications: uses notifications
- Audience Rules → Audience Resolution: resolves contacts (evidence: `apps/CRM/src/lib/campaigns/rule-engine.ts`)
- Recruitment Applications → HRM: supports hiring
- ExcelAI → Auto Visualization: creates visualizations (evidence: `apps/ExcelAI/src/autoviz/AutoVizEngine.ts`)
- ExcelAI → AI Macros: runs macros (evidence: `apps/ExcelAI/src/macros/MacroEngine.ts`)
- ExcelAI → Proactive Insights: surfaces suggestions (evidence: `apps/ExcelAI/src/proactive/ProactiveEngine.ts`)
- ExcelAI → Formula Worker: dispatches calculations
- Project Management → Project Exports: offers exports (evidence: `apps/PM/src/components/ExportEngine.jsx`)
