# buson-digital-services/insignia_crm_node architecture

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

- Interactive diagram: https://gitdiagram.com/buson-digital-services/insignia_crm_node
- Repository: https://github.com/buson-digital-services/insignia_crm_node

## Overview

This repository is a NestJS backend for a multi-tenant mobile sales and operations application, despite the README describing only the Nest starter. The main workflow is tenant selection, user login, JWT-authenticated requests, then CRM, attendance, or admin operations backed by SQL Server and SAP Business One. The graph preserves these distinct domains and the shared tenant, database, and SAP layers. Several capabilities are visible only in the file tree or SOURCE INDEX, so their internal relationships are not inferred.

Main entry points: [`src/database/database.service.ts`](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/database/database.service.ts) (Tenant SQL access), [`src/sap/sap.service.ts`](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/sap/sap.service.ts) (SAP Service Layer), [`src/auth/auth.service.ts`](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/auth/auth.service.ts) (Login and SAP identity), [`src/crm/crm.service.ts`](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/crm/crm.service.ts) (CRM workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_api["HTTP API<br/>[main.ts]"]
  node_authapi["Authentication routes<br/>[auth.controller.ts]"]
end

subgraph group_identity["Identity and tenancy"]
  node_authlogic["Login and SAP identity<br/>[auth.service.ts]"]
  node_jwt["JWT guards and strategy<br/>[jwt-auth.guard.ts]"]
  node_tenant["Tenant configuration<br/>[tenant.service.ts]"]
  node_tenantapi["Tenant routes"]
end

subgraph group_operations["Business operations"]
  node_attendanceapi["Attendance routes"]
  node_attendance["Attendance recording"]
  node_crmapi["CRM routes<br/>[crm.controller.ts]"]
  node_crm["CRM workflows<br/>[crm.service.ts]"]
  node_sellerkit["SellerKit integration"]
  node_controlapi["Control panel routes"]
  node_control["Admin operations"]
end

subgraph group_integrations["Data integrations"]
  node_database[("Tenant SQL access")]
  node_sap["SAP Service Layer<br/>[sap.service.ts]"]
  node_email["Email delivery<br/>[email.service.ts]"]
end

node_mobile(("Mobile client"))
node_adminclient(("Admin client"))
node_sqlserver[("SQL Server databases")]
node_sapservice["SAP Business One"]

node_mobile -->|"sends requests"| node_api
node_adminclient -.->|"sends requests"| node_api
node_api -.->|"routes to"| node_authapi
node_mobile -->|"logs in"| node_authapi
node_authapi -->|"delegates to"| node_authlogic
node_authlogic -->|"resolves tenant"| node_tenant
node_authlogic -->|"queries"| node_database
node_authlogic -->|"checks credentials"| node_sap
node_api -.->|"routes to"| node_tenantapi
node_attendanceapi -->|"requires JWT"| node_jwt
node_attendanceapi -->|"delegates to"| node_attendance
node_attendance -->|"queries"| node_database
node_crmapi -->|"requires JWT"| node_jwt
node_crmapi -->|"delegates to"| node_crm
node_crm -->|"queries"| node_database
node_crm -->|"requests"| node_sap
node_crm -->|"uses"| node_email
node_sellerkit -->|"requires JWT"| node_jwt
node_sellerkit -->|"queries"| node_database
node_sellerkit -->|"requests"| node_sap
node_controlapi -->|"delegates to"| node_control
node_control -->|"queries"| node_database
node_control -->|"requests"| node_sap
node_database -->|"loads connection"| node_tenant
node_database -->|"reads and writes"| node_sqlserver
node_sap -->|"calls Service Layer"| node_sapservice

click node_api "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/main.ts"
click node_authapi "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/auth/auth.controller.ts"
click node_authlogic "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/auth/auth.service.ts"
click node_jwt "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/auth/jwt-auth.guard.ts"
click node_tenant "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/tenant/tenant.service.ts"
click node_tenantapi "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/tenant/tenant.controller.ts"
click node_attendanceapi "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/attendance/attendance.controller.ts"
click node_attendance "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/attendance/attendance.service.ts"
click node_crmapi "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/crm/crm.controller.ts"
click node_crm "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/crm/crm.service.ts"
click node_sellerkit "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/crm/sellerkit.controller.ts"
click node_controlapi "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/control-panel/control-panel.controller.ts"
click node_control "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/control-panel/control-panel.service.ts"
click node_database "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/database/database.service.ts"
click node_sap "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/sap/sap.service.ts"
click node_email "https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/crm/email.service.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_api,node_authapi,node_mobile,node_adminclient toneBlue
class node_authlogic,node_jwt,node_tenant,node_tenantapi,node_sqlserver toneAmber
class node_attendanceapi,node_attendance,node_crmapi,node_crm,node_sellerkit,node_controlapi,node_control toneMint
class node_database,node_sap,node_email toneRose
class node_sapservice toneIndigo
```

## Components

### API entry

- [HTTP API](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/main.ts): `src/main.ts`
- [Authentication routes](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`

### Identity and tenancy

- [Login and SAP identity](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [JWT guards and strategy](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/auth/jwt-auth.guard.ts): `src/auth/jwt-auth.guard.ts`
- [Tenant configuration](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/tenant/tenant.service.ts): `src/tenant/tenant.service.ts`
- [Tenant routes](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/tenant/tenant.controller.ts): `src/tenant/tenant.controller.ts`

### Business operations

- [Attendance routes](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/attendance/attendance.controller.ts): `src/attendance/attendance.controller.ts`
- [Attendance recording](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/attendance/attendance.service.ts): `src/attendance/attendance.service.ts`
- [CRM routes](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/crm/crm.controller.ts): `src/crm/crm.controller.ts`
- [CRM workflows](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/crm/crm.service.ts): `src/crm/crm.service.ts`
- [SellerKit integration](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/crm/sellerkit.controller.ts): `src/crm/sellerkit.controller.ts`
- [Control panel routes](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/control-panel/control-panel.controller.ts): `src/control-panel/control-panel.controller.ts`
- [Admin operations](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/control-panel/control-panel.service.ts): `src/control-panel/control-panel.service.ts`

### Data integrations

- [Tenant SQL access](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/database/database.service.ts): `src/database/database.service.ts`
- [SAP Service Layer](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/sap/sap.service.ts): `src/sap/sap.service.ts`
- [Email delivery](https://github.com/buson-digital-services/insignia_crm_node/blob/main/src/crm/email.service.ts): `src/crm/email.service.ts`

### Other components

- **Mobile client**
- **Admin client**
- **SQL Server databases**
- **SAP Business One**

## Connections

- Mobile client → HTTP API: sends requests (evidence: `src/main.ts`)
- Admin client → HTTP API: sends requests
- HTTP API → Authentication routes: routes to
- Mobile client → Authentication routes: logs in (evidence: `src/auth/auth.controller.ts`)
- Authentication routes → Login and SAP identity: delegates to (evidence: `src/auth/auth.controller.ts`)
- Login and SAP identity → Tenant configuration: resolves tenant (evidence: `src/auth/auth.service.ts`)
- Login and SAP identity → Tenant SQL access: queries (evidence: `src/auth/auth.service.ts`)
- Login and SAP identity → SAP Service Layer: checks credentials (evidence: `src/auth/auth.service.ts`)
- HTTP API → Tenant routes: routes to
- Attendance routes → JWT guards and strategy: requires JWT (evidence: `src/attendance/attendance.controller.ts`)
- Attendance routes → Attendance recording: delegates to (evidence: `src/attendance/attendance.controller.ts`)
- Attendance recording → Tenant SQL access: queries (evidence: `src/attendance/attendance.service.ts`)
- CRM routes → JWT guards and strategy: requires JWT (evidence: `src/crm/crm.controller.ts`)
- CRM routes → CRM workflows: delegates to (evidence: `src/crm/crm.controller.ts`)
- CRM workflows → Tenant SQL access: queries (evidence: `src/crm/crm.service.ts`)
- CRM workflows → SAP Service Layer: requests (evidence: `src/crm/crm.service.ts`)
- CRM workflows → Email delivery: uses (evidence: `src/crm/crm.service.ts`)
- SellerKit integration → JWT guards and strategy: requires JWT (evidence: `src/crm/sellerkit.controller.ts`)
- SellerKit integration → Tenant SQL access: queries (evidence: `src/crm/sellerkit.controller.ts`)
- SellerKit integration → SAP Service Layer: requests (evidence: `src/crm/sellerkit.controller.ts`)
- Control panel routes → Admin operations: delegates to (evidence: `src/control-panel/control-panel.controller.ts`)
- Admin operations → Tenant SQL access: queries (evidence: `src/control-panel/control-panel.service.ts`)
- Admin operations → SAP Service Layer: requests (evidence: `src/control-panel/control-panel.service.ts`)
- Tenant SQL access → Tenant configuration: loads connection (evidence: `src/database/database.service.ts`)
- Tenant SQL access → SQL Server databases: reads and writes (evidence: `src/database/database.service.ts`)
- SAP Service Layer → SAP Business One: calls Service Layer (evidence: `src/sap/sap.service.ts`)
