# kheang1409/modular-erp architecture

> Architecture diagram of the GitHub repository kheang1409/modular-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/kheang1409/modular-erp
- Repository: https://github.com/kheang1409/modular-erp

## Overview

Open ERP is a company-scoped modular ERP: users work through a Blazor/API host to manage master data, leads, sales and purchasing documents, stock, accounting, and reports. Business modules own their persistence and expose public contracts; the platform provides organization, access, audit, and module-management services. The principal flow is represented through host-to-module dispatch and module-owned services to their stores; those dispatch edges are illustrative and marked unverified because the relevant endpoint wiring was not sampled. README capability statements preserve reporting and administration branches beyond sampled code.

Main entry points: [`src/Platform/Erp.Host/Program.cs`](https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.Host/Program.cs) (Web host), [`src/Modules/Reporting/ReportingService.cs`](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Reporting/ReportingService.cs) (Reports and exports), [`src/Modules/Sales/QuotationService.cs`](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Sales/QuotationService.cs) (Sales documents), [`src/Modules/Contacts/ContactService.cs`](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Contacts/ContactService.cs) (Contacts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Host and experience"]
  node_host["Web host<br/>[Program.cs]"]
end

subgraph group_business["Business workflows"]
  node_contacts["Contacts<br/>[ContactService.cs]"]
  node_contactsdb[("Contacts store")]
  node_products["Products<br/>[ProductService.cs]"]
  node_productsdb[("Products store")]
  node_crm["CRM pipeline<br/>[LeadService.cs]"]
  node_crmdb[("CRM store<br/>[CrmDbContext.cs]")]
  node_sales["Sales documents"]
  node_salesdb[("Sales store<br/>[SalesDbContext.cs]")]
  node_purchasing["Purchasing"]
  node_purchasingdb[("Purchasing store")]
  node_inventory["Inventory and stock"]
  node_inventorydb[("Inventory store")]
end

subgraph group_finance["Finance and reporting"]
  node_accounting["Accounting workflows"]
  node_invoices["Invoices and bills"]
  node_payments["Payments<br/>[PaymentService.cs]"]
  node_accountingdb[("Accounting store")]
  node_reporting["Reports and exports"]
end

subgraph group_platform["Platform services"]
  node_platform["Organization and access"]
  node_platformdb[("Platform store")]
  node_roles["Role administration"]
end

subgraph group_extensions["Module extensions"]
  node_modulemanager["Module packages"]
  node_manifest["Manifest parsing"]
  node_cli["Module CLI<br/>[Program.cs]"]
end

node_user(("ERP user"))

node_user -->|"uses"| node_host
node_host -.->|"dispatches"| node_contacts
node_host -.->|"dispatches"| node_products
node_host -.->|"dispatches"| node_crm
node_host -.->|"dispatches"| node_sales
node_host -.->|"dispatches"| node_purchasing
node_host -.->|"dispatches"| node_inventory
node_host -.->|"dispatches"| node_accounting
node_host -.->|"dispatches"| node_reporting
node_contacts -->|"reads and writes"| node_contactsdb
node_products -->|"reads and writes"| node_productsdb
node_crm -->|"reads and writes"| node_crmdb
node_crm -->|"resolves contacts"| node_contacts
node_sales -->|"reads and writes"| node_salesdb
node_sales -->|"resolves customers"| node_contacts
node_purchasing -->|"reads and writes"| node_purchasingdb
node_inventory -->|"reads and writes"| node_inventorydb
node_accounting -->|"reads and writes"| node_accountingdb
node_invoices -->|"reads and writes"| node_accountingdb
node_invoices -->|"uses ledger"| node_accounting
node_payments -->|"reads and writes"| node_accountingdb
node_reporting -.->|"summarizes"| node_sales
node_reporting -.->|"summarizes"| node_purchasing
node_reporting -.->|"summarizes"| node_inventory
node_reporting -.->|"summarizes"| node_accounting
node_platform -->|"reads and writes"| node_platformdb
node_roles -->|"reads and writes"| node_platformdb
node_cli -->|"runs commands"| node_modulemanager
node_modulemanager -.->|"parses manifests"| node_manifest

click node_host "https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.Host/Program.cs"
click node_contacts "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Contacts/ContactService.cs"
click node_contactsdb "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Contacts/ContactsDbContext.cs"
click node_products "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Products/ProductService.cs"
click node_productsdb "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Products/ProductsDbContext.cs"
click node_crm "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Crm/LeadService.cs"
click node_crmdb "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Crm/CrmDbContext.cs"
click node_sales "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Sales/QuotationService.cs"
click node_salesdb "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Sales/SalesDbContext.cs"
click node_purchasing "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Purchasing/PurchaseOrderService.cs"
click node_purchasingdb "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Purchasing/PurchasingDbContext.cs"
click node_inventory "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Inventory/InventoryService.cs"
click node_inventorydb "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Inventory/InventoryDbContext.cs"
click node_accounting "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Accounting/GeneralLedgerService.cs"
click node_invoices "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Accounting/CustomerInvoiceService.cs"
click node_payments "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Accounting/PaymentService.cs"
click node_accountingdb "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Accounting/AccountingDbContext.cs"
click node_reporting "https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Reporting/ReportingService.cs"
click node_platform "https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.Infrastructure/Persistence/OrganizationAdministrationService.cs"
click node_platformdb "https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.Infrastructure/Persistence/PlatformDbContext.cs"
click node_roles "https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.Infrastructure/Security/RoleAdministrationService.cs"
click node_modulemanager "https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.ModuleSystem/ModulePackageManager.cs"
click node_manifest "https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.ModuleSystem/ModuleManifestParser.cs"
click node_cli "https://github.com/kheang1409/modular-erp/blob/main/src/Tools/Erp.Cli/Program.cs"

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_host,node_user toneBlue
class node_contacts,node_contactsdb,node_products,node_productsdb,node_crm,node_crmdb,node_sales,node_salesdb,node_purchasing,node_purchasingdb,node_inventory,node_inventorydb toneAmber
class node_accounting,node_invoices,node_payments,node_accountingdb,node_reporting toneMint
class node_platform,node_platformdb,node_roles toneRose
class node_modulemanager,node_manifest,node_cli toneIndigo
```

## Components

### Host and experience

- [Web host](https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.Host/Program.cs): `src/Platform/Erp.Host/Program.cs`

### Business workflows

- [Contacts](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Contacts/ContactService.cs): `src/Modules/Contacts/ContactService.cs`
- [Contacts store](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Contacts/ContactsDbContext.cs): `src/Modules/Contacts/ContactsDbContext.cs`
- [Products](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Products/ProductService.cs): `src/Modules/Products/ProductService.cs`
- [Products store](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Products/ProductsDbContext.cs): `src/Modules/Products/ProductsDbContext.cs`
- [CRM pipeline](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Crm/LeadService.cs): `src/Modules/Crm/LeadService.cs`
- [CRM store](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Crm/CrmDbContext.cs): `src/Modules/Crm/CrmDbContext.cs`
- [Sales documents](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Sales/QuotationService.cs): `src/Modules/Sales/QuotationService.cs`
- [Sales store](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Sales/SalesDbContext.cs): `src/Modules/Sales/SalesDbContext.cs`
- [Purchasing](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Purchasing/PurchaseOrderService.cs): `src/Modules/Purchasing/PurchaseOrderService.cs`
- [Purchasing store](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Purchasing/PurchasingDbContext.cs): `src/Modules/Purchasing/PurchasingDbContext.cs`
- [Inventory and stock](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Inventory/InventoryService.cs): `src/Modules/Inventory/InventoryService.cs`
- [Inventory store](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Inventory/InventoryDbContext.cs): `src/Modules/Inventory/InventoryDbContext.cs`

### Finance and reporting

- [Accounting workflows](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Accounting/GeneralLedgerService.cs): `src/Modules/Accounting/GeneralLedgerService.cs`
- [Invoices and bills](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Accounting/CustomerInvoiceService.cs): `src/Modules/Accounting/CustomerInvoiceService.cs`
- [Payments](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Accounting/PaymentService.cs): `src/Modules/Accounting/PaymentService.cs`
- [Accounting store](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Accounting/AccountingDbContext.cs): `src/Modules/Accounting/AccountingDbContext.cs`
- [Reports and exports](https://github.com/kheang1409/modular-erp/blob/main/src/Modules/Reporting/ReportingService.cs): `src/Modules/Reporting/ReportingService.cs`

### Platform services

- [Organization and access](https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.Infrastructure/Persistence/OrganizationAdministrationService.cs): `src/Platform/Erp.Infrastructure/Persistence/OrganizationAdministrationService.cs`
- [Platform store](https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.Infrastructure/Persistence/PlatformDbContext.cs): `src/Platform/Erp.Infrastructure/Persistence/PlatformDbContext.cs`
- [Role administration](https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.Infrastructure/Security/RoleAdministrationService.cs): `src/Platform/Erp.Infrastructure/Security/RoleAdministrationService.cs`

### Module extensions

- [Module packages](https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.ModuleSystem/ModulePackageManager.cs): `src/Platform/Erp.ModuleSystem/ModulePackageManager.cs`
- [Manifest parsing](https://github.com/kheang1409/modular-erp/blob/main/src/Platform/Erp.ModuleSystem/ModuleManifestParser.cs): `src/Platform/Erp.ModuleSystem/ModuleManifestParser.cs`
- [Module CLI](https://github.com/kheang1409/modular-erp/blob/main/src/Tools/Erp.Cli/Program.cs): `src/Tools/Erp.Cli/Program.cs`

### Other components

- **ERP user**

## Connections

- ERP user → Web host: uses (evidence: `README.md`)
- Web host → Contacts: dispatches
- Web host → Products: dispatches
- Web host → CRM pipeline: dispatches
- Web host → Sales documents: dispatches
- Web host → Purchasing: dispatches
- Web host → Inventory and stock: dispatches
- Web host → Accounting workflows: dispatches
- Web host → Reports and exports: dispatches
- Contacts → Contacts store: reads and writes (evidence: `src/Modules/Contacts/ContactService.cs`)
- Products → Products store: reads and writes (evidence: `src/Modules/Products/ProductService.cs`)
- CRM pipeline → CRM store: reads and writes (evidence: `src/Modules/Crm/LeadService.cs`)
- CRM pipeline → Contacts: resolves contacts (evidence: `src/Modules/Crm/LeadService.cs`)
- Sales documents → Sales store: reads and writes (evidence: `src/Modules/Sales/QuotationService.cs`)
- Sales documents → Contacts: resolves customers (evidence: `src/Modules/Sales/QuotationService.cs`)
- Purchasing → Purchasing store: reads and writes (evidence: `src/Modules/Purchasing/PurchaseOrderService.cs`)
- Inventory and stock → Inventory store: reads and writes (evidence: `src/Modules/Inventory/InventoryService.cs`)
- Accounting workflows → Accounting store: reads and writes (evidence: `src/Modules/Accounting/GeneralLedgerService.cs`)
- Invoices and bills → Accounting store: reads and writes (evidence: `src/Modules/Accounting/CustomerInvoiceService.cs`)
- Invoices and bills → Accounting workflows: uses ledger (evidence: `src/Modules/Accounting/CustomerInvoiceService.cs`)
- Payments → Accounting store: reads and writes (evidence: `src/Modules/Accounting/PaymentService.cs`)
- Reports and exports → Sales documents: summarizes
- Reports and exports → Purchasing: summarizes
- Reports and exports → Inventory and stock: summarizes
- Reports and exports → Accounting workflows: summarizes
- Organization and access → Platform store: reads and writes (evidence: `src/Platform/Erp.Infrastructure/Persistence/OrganizationAdministrationService.cs`)
- Role administration → Platform store: reads and writes (evidence: `src/Platform/Erp.Infrastructure/Security/RoleAdministrationService.cs`)
- Module CLI → Module packages: runs commands (evidence: `src/Tools/Erp.Cli/Program.cs`)
- Module packages → Manifest parsing: parses manifests
