# phatvo2002/crm architecture

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

- Interactive diagram: https://gitdiagram.com/phatvo2002/crm
- Repository: https://github.com/phatvo2002/crm

## Overview

This repository is a Vietnamese CRM application: a React client presents sales, customer, activity, reporting, and administration workflows backed by an ASP.NET Core API and relational CRM model. The user-facing path begins at login and role-filtered navigation, then enters CRM screens; API calls connect those screens to server controllers and persisted records. The supplied excerpts show routing, selected controller-to-service calls, and database modeling, but not the client API request implementations or most server service implementations, so those links are marked unverified or omitted.

Main entry points: [`client/src/App/Router.js`](https://github.com/phatvo2002/crm/blob/main/client/src/App/Router.js) (Screen routes), [`client/src/App/Api`](https://github.com/phatvo2002/crm/tree/main/client/src/App/Api) (API clients), [`server/CRM/CRM/Services`](https://github.com/phatvo2002/crm/tree/main/server/CRM/CRM/Services) (Domain services), [`server/CRM/CRM/Controllers/KhachHangMucTieus/KhachHangMucTieuController.cs`](https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/KhachHangMucTieus/KhachHangMucTieuController.cs) (Customer controllers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["CRM client"]
  node_app["App shell<br/>[App.js]"]
  node_auth["Authentication<br/>[AuthContext.js]"]
  node_navigation["Role navigation<br/>[AppRouter.js]"]
  node_routes["Screen routes<br/>[Router.js]"]
  node_api["API clients"]
end

subgraph group_sales["Sales workflows"]
  node_lead["Prospect management<br/>[index.jsx]"]
  node_target["Target customers<br/>[index.jsx]"]
  node_opportunity["Opportunities<br/>[index.jsx]"]
  node_quotes["Quotes<br/>[index.jsx]"]
  node_orders["Orders<br/>[index.jsx]"]
  node_work["Activities and tasks<br/>[index.jsx]"]
  node_dashboard["Sales workspace<br/>[BanLamViec.jsx]"]
end

subgraph group_server["CRM API"]
  node_customercontroller["Customer controllers"]
  node_prospectcontroller["Prospect controller"]
  node_quotecontroller["Quote controller"]
  node_reportcontroller["Reporting controller"]
  node_lookupcontroller["Lookup controller"]
  node_services["Domain services"]
end

subgraph group_data["CRM data"]
  node_dbcontext[("CRM data model<br/>[CrmDbContext.cs]")]
  node_targetrecord["Target customer record"]
  node_userrecord["User and sales records<br/>[Nguoidung.cs]"]
  node_quotedto["Quote response model<br/>[BaoGiaDTO.cs]"]
end

node_user(("CRM user"))

node_user -->|"uses"| node_app
node_app -->|"loads"| node_auth
node_auth -->|"auth requests"| node_api
node_app -->|"renders"| node_navigation
node_navigation -->|"selects screens"| node_routes
node_navigation -->|"loads role menu"| node_api
node_routes -->|"routes to"| node_lead
node_routes -->|"routes to"| node_target
node_routes -->|"routes to"| node_opportunity
node_routes -->|"routes to"| node_quotes
node_routes -->|"routes to"| node_orders
node_routes -->|"routes to"| node_work
node_routes -->|"routes to"| node_dashboard
node_lead -.->|"uses endpoints"| node_api
node_target -.->|"uses endpoints"| node_api
node_quotes -.->|"uses endpoints"| node_api
node_api -.->|"HTTP requests"| node_customercontroller
node_api -.->|"HTTP requests"| node_prospectcontroller
node_api -.->|"HTTP requests"| node_quotecontroller
node_customercontroller -->|"delegates"| node_services
node_prospectcontroller -->|"delegates"| node_services
node_quotecontroller -->|"delegates"| node_services
node_reportcontroller -->|"delegates"| node_services
node_lookupcontroller -->|"delegates"| node_services
node_customercontroller -->|"reads and writes"| node_dbcontext
node_prospectcontroller -->|"reads and writes"| node_dbcontext
node_quotecontroller -->|"queries model"| node_dbcontext
node_customercontroller -->|"creates records"| node_targetrecord
node_prospectcontroller -->|"uses user context"| node_userrecord
node_quotecontroller -->|"returns quotes"| node_quotedto

click node_app "https://github.com/phatvo2002/crm/blob/main/client/src/App.js"
click node_auth "https://github.com/phatvo2002/crm/blob/main/client/src/App/Context/AuthContext.js"
click node_navigation "https://github.com/phatvo2002/crm/blob/main/client/src/App/AppRouter.js"
click node_routes "https://github.com/phatvo2002/crm/blob/main/client/src/App/Router.js"
click node_api "https://github.com/phatvo2002/crm/tree/main/client/src/App/Api"
click node_lead "https://github.com/phatvo2002/crm/blob/main/client/src/App/View/KhachHangTiemNang/index.jsx"
click node_target "https://github.com/phatvo2002/crm/blob/main/client/src/App/View/KhachHangMucTieu/index.jsx"
click node_opportunity "https://github.com/phatvo2002/crm/blob/main/client/src/App/View/CoHoi/index.jsx"
click node_quotes "https://github.com/phatvo2002/crm/blob/main/client/src/App/View/BaoGia/index.jsx"
click node_orders "https://github.com/phatvo2002/crm/blob/main/client/src/App/View/DonHang/index.jsx"
click node_work "https://github.com/phatvo2002/crm/blob/main/client/src/App/View/NhiemVu/index.jsx"
click node_dashboard "https://github.com/phatvo2002/crm/blob/main/client/src/App/View/BanLamViec/BanLamViec.jsx"
click node_customercontroller "https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/KhachHangMucTieus/KhachHangMucTieuController.cs"
click node_prospectcontroller "https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/KhachHangTiemnangs/KhachHangTiemNangController.cs"
click node_quotecontroller "https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/BaoGias/BaoGiaController.cs"
click node_reportcontroller "https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/BaoCaos/BaoCaoController.cs"
click node_lookupcontroller "https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/GetDatas/GetDataController.cs"
click node_services "https://github.com/phatvo2002/crm/tree/main/server/CRM/CRM/Services"
click node_dbcontext "https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Entities/CrmDbContext.cs"
click node_targetrecord "https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Entities/KhachHangMucTieu.cs"
click node_userrecord "https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Entities/Nguoidung.cs"
click node_quotedto "https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/DTO/BaoGiaDTO.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_app,node_auth,node_navigation,node_routes,node_api,node_user toneBlue
class node_lead,node_target,node_opportunity,node_quotes,node_orders,node_work,node_dashboard toneAmber
class node_customercontroller,node_prospectcontroller,node_quotecontroller,node_reportcontroller,node_lookupcontroller,node_services toneMint
class node_dbcontext,node_targetrecord,node_userrecord,node_quotedto toneRose
```

## Components

### CRM client

- [App shell](https://github.com/phatvo2002/crm/blob/main/client/src/App.js): `client/src/App.js`
- [Authentication](https://github.com/phatvo2002/crm/blob/main/client/src/App/Context/AuthContext.js): `client/src/App/Context/AuthContext.js`
- [Role navigation](https://github.com/phatvo2002/crm/blob/main/client/src/App/AppRouter.js): `client/src/App/AppRouter.js`
- [Screen routes](https://github.com/phatvo2002/crm/blob/main/client/src/App/Router.js): `client/src/App/Router.js`
- [API clients](https://github.com/phatvo2002/crm/tree/main/client/src/App/Api): `client/src/App/Api`

### Sales workflows

- [Prospect management](https://github.com/phatvo2002/crm/blob/main/client/src/App/View/KhachHangTiemNang/index.jsx): `client/src/App/View/KhachHangTiemNang/index.jsx`
- [Target customers](https://github.com/phatvo2002/crm/blob/main/client/src/App/View/KhachHangMucTieu/index.jsx): `client/src/App/View/KhachHangMucTieu/index.jsx`
- [Opportunities](https://github.com/phatvo2002/crm/blob/main/client/src/App/View/CoHoi/index.jsx): `client/src/App/View/CoHoi/index.jsx`
- [Quotes](https://github.com/phatvo2002/crm/blob/main/client/src/App/View/BaoGia/index.jsx): `client/src/App/View/BaoGia/index.jsx`
- [Orders](https://github.com/phatvo2002/crm/blob/main/client/src/App/View/DonHang/index.jsx): `client/src/App/View/DonHang/index.jsx`
- [Activities and tasks](https://github.com/phatvo2002/crm/blob/main/client/src/App/View/NhiemVu/index.jsx): `client/src/App/View/NhiemVu/index.jsx`
- [Sales workspace](https://github.com/phatvo2002/crm/blob/main/client/src/App/View/BanLamViec/BanLamViec.jsx): `client/src/App/View/BanLamViec/BanLamViec.jsx`

### CRM API

- [Customer controllers](https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/KhachHangMucTieus/KhachHangMucTieuController.cs): `server/CRM/CRM/Controllers/KhachHangMucTieus/KhachHangMucTieuController.cs`
- [Prospect controller](https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/KhachHangTiemnangs/KhachHangTiemNangController.cs): `server/CRM/CRM/Controllers/KhachHangTiemnangs/KhachHangTiemNangController.cs`
- [Quote controller](https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/BaoGias/BaoGiaController.cs): `server/CRM/CRM/Controllers/BaoGias/BaoGiaController.cs`
- [Reporting controller](https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/BaoCaos/BaoCaoController.cs): `server/CRM/CRM/Controllers/BaoCaos/BaoCaoController.cs`
- [Lookup controller](https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Controllers/GetDatas/GetDataController.cs): `server/CRM/CRM/Controllers/GetDatas/GetDataController.cs`
- [Domain services](https://github.com/phatvo2002/crm/tree/main/server/CRM/CRM/Services): `server/CRM/CRM/Services`

### CRM data

- [CRM data model](https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Entities/CrmDbContext.cs): `server/CRM/CRM/Entities/CrmDbContext.cs`
- [Target customer record](https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Entities/KhachHangMucTieu.cs): `server/CRM/CRM/Entities/KhachHangMucTieu.cs`
- [User and sales records](https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/Entities/Nguoidung.cs): `server/CRM/CRM/Entities/Nguoidung.cs`
- [Quote response model](https://github.com/phatvo2002/crm/blob/main/server/CRM/CRM/DTO/BaoGiaDTO.cs): `server/CRM/CRM/DTO/BaoGiaDTO.cs`

### Other components

- **CRM user**

## Connections

- CRM user → App shell: uses (evidence: `client/src/App.js`)
- App shell → Authentication: loads (evidence: `client/src/App.js`)
- Authentication → API clients: auth requests (evidence: `client/src/App/Context/AuthContext.js`)
- App shell → Role navigation: renders (evidence: `client/src/App.js`)
- Role navigation → Screen routes: selects screens (evidence: `client/src/App/AppRouter.js`)
- Role navigation → API clients: loads role menu (evidence: `client/src/App/AppRouter.js`)
- Screen routes → Prospect management: routes to (evidence: `client/src/App/Router.js`)
- Screen routes → Target customers: routes to (evidence: `client/src/App/Router.js`)
- Screen routes → Opportunities: routes to (evidence: `client/src/App/Router.js`)
- Screen routes → Quotes: routes to (evidence: `client/src/App/Router.js`)
- Screen routes → Orders: routes to (evidence: `client/src/App/Router.js`)
- Screen routes → Activities and tasks: routes to (evidence: `client/src/App/Router.js`)
- Screen routes → Sales workspace: routes to (evidence: `client/src/App/Router.js`)
- Prospect management → API clients: uses endpoints
- Target customers → API clients: uses endpoints
- Quotes → API clients: uses endpoints
- API clients → Customer controllers: HTTP requests
- API clients → Prospect controller: HTTP requests
- API clients → Quote controller: HTTP requests
- Customer controllers → Domain services: delegates (evidence: `server/CRM/CRM/Controllers/KhachHangMucTieus/KhachHangMucTieuController.cs`)
- Prospect controller → Domain services: delegates (evidence: `server/CRM/CRM/Controllers/KhachHangTiemnangs/KhachHangTiemNangController.cs`)
- Quote controller → Domain services: delegates (evidence: `server/CRM/CRM/Controllers/BaoGias/BaoGiaController.cs`)
- Reporting controller → Domain services: delegates (evidence: `server/CRM/CRM/Controllers/BaoCaos/BaoCaoController.cs`)
- Lookup controller → Domain services: delegates (evidence: `server/CRM/CRM/Controllers/GetDatas/GetDataController.cs`)
- Customer controllers → CRM data model: reads and writes (evidence: `server/CRM/CRM/Controllers/KhachHangMucTieus/KhachHangMucTieuController.cs`)
- Prospect controller → CRM data model: reads and writes (evidence: `server/CRM/CRM/Controllers/KhachHangTiemnangs/KhachHangTiemNangController.cs`)
- Quote controller → CRM data model: queries model (evidence: `server/CRM/CRM/Controllers/BaoGias/BaoGiaController.cs`)
- Customer controllers → Target customer record: creates records (evidence: `server/CRM/CRM/Controllers/KhachHangMucTieus/KhachHangMucTieuController.cs`)
- Prospect controller → User and sales records: uses user context (evidence: `server/CRM/CRM/Controllers/KhachHangTiemnangs/KhachHangTiemNangController.cs`)
- Quote controller → Quote response model: returns quotes (evidence: `server/CRM/CRM/Controllers/BaoGias/BaoGiaController.cs`)
