# ncfventurestudio-ship-it/nvfs-crm architecture

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

- Interactive diagram: https://gitdiagram.com/ncfventurestudio-ship-it/nvfs-crm
- Repository: https://github.com/ncfventurestudio-ship-it/nvfs-crm

## Overview

This repository is a Next.js enterprise operations platform spanning workforce, finance, CRM, inventory, legal, and other business areas. The visible workflow is an authenticated user working through the app interface and its API routes; routes apply domain services and shared persistence. Sampled source supports the employee, task, operations, and automation paths, plus shared authentication and event handling. Other product areas are present in the tree but their internal wiring was not sampled, so their links are omitted rather than inferred.

Main entry points: [`src/app/api/employees/route.ts`](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/employees/route.ts) (Employee API), [`src/lib/auth.ts`](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/auth.ts) (Session auth), [`src/lib/db.ts`](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/db.ts) (Prisma database), [`src/services/workflow-engine.service.ts`](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/workflow-engine.service.ts) (Workflow engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_app["App interface<br/>[layout.tsx]"]
end

subgraph group_domains["Business domains"]
  node_employee_api["Employee API<br/>[route.ts]"]
  node_tasks_api["Task API<br/>[route.ts]"]
  node_operations_api["Operations API<br/>[route.ts]"]
  node_calendar_api["Calendar API<br/>[route.ts]"]
  node_finance["Finance<br/>[route.ts]"]
  node_crm["CRM<br/>[route.ts]"]
  node_inventory["Inventory<br/>[route.ts]"]
  node_hr["HR and payroll<br/>[route.ts]"]
  node_legal["Legal<br/>[route.ts]"]
  node_task_service["Task service<br/>[task.service.ts]"]
  node_operation_service["Operations service"]
end

subgraph group_platform["Shared platform"]
  node_auth["Session auth<br/>[auth.ts]"]
  node_offline_auth["Offline auth<br/>[offline-auth.ts]"]
  node_employee_store[("Employee store<br/>[employee-store.ts]")]
  node_rbac["Access control<br/>[rbac.service.ts]"]
  node_db[("Prisma database<br/>[db.ts]")]
  node_api_response["API responses<br/>[api-response.ts]"]
  node_audit["Audit service<br/>[audit.service.ts]"]
end

subgraph group_automation["Automation"]
  node_workflow["Workflow engine"]
  node_events["Event bus"]
  node_escalation["Escalation engine"]
  node_ai["AI services<br/>[ai.service.ts]"]
end

node_user(("Business user"))

node_user -.->|"uses"| node_app
node_app -.->|"requests"| node_employee_api
node_employee_api -->|"authenticates"| node_auth
node_employee_api -->|"queries"| node_db
node_employee_api -->|"uses fallback"| node_employee_store
node_employee_api -->|"checks access"| node_rbac
node_employee_api -->|"formats response"| node_api_response
node_tasks_api -->|"authenticates"| node_auth
node_tasks_api -->|"delegates"| node_task_service
node_tasks_api -->|"formats response"| node_api_response
node_operations_api -->|"authenticates"| node_auth
node_operations_api -->|"delegates"| node_operation_service
node_calendar_api -->|"authenticates"| node_auth
node_calendar_api -->|"formats response"| node_api_response
node_auth -->|"loads session"| node_db
node_auth -->|"falls back"| node_offline_auth
node_offline_auth -->|"looks up employees"| node_employee_store
node_workflow -->|"reads and writes"| node_db
node_workflow -->|"publishes events"| node_events
node_workflow -->|"executes escalation"| node_escalation
node_workflow -->|"logs mutations"| node_audit
node_events -->|"writes notifications"| node_db
node_events -->|"logs events"| node_audit
node_escalation -->|"publishes notice"| node_events
node_escalation -->|"resolves targets"| node_db

click node_app "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/app/layout.tsx"
click node_employee_api "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/employees/route.ts"
click node_tasks_api "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/tasks/route.ts"
click node_operations_api "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/operations/route.ts"
click node_calendar_api "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/calendar/route.ts"
click node_finance "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/finance/overview/route.ts"
click node_crm "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/crm/clients/route.ts"
click node_inventory "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/inventory/overview/route.ts"
click node_hr "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/hr/leaves/route.ts"
click node_legal "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/legal/cases/route.ts"
click node_auth "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/auth.ts"
click node_offline_auth "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/offline-auth.ts"
click node_employee_store "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/employee-store.ts"
click node_rbac "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/rbac.service.ts"
click node_db "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/db.ts"
click node_api_response "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/api-response.ts"
click node_task_service "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/task.service.ts"
click node_operation_service "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/operation.service.ts"
click node_workflow "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/workflow-engine.service.ts"
click node_events "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/event-bus.service.ts"
click node_escalation "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/escalation-engine.service.ts"
click node_audit "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/audit.service.ts"
click node_ai "https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/ai/ai.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_app,node_user toneBlue
class node_employee_api,node_tasks_api,node_operations_api,node_calendar_api,node_finance,node_crm,node_inventory,node_hr,node_legal,node_task_service,node_operation_service toneAmber
class node_auth,node_offline_auth,node_employee_store,node_rbac,node_db,node_api_response,node_audit toneMint
class node_workflow,node_events,node_escalation,node_ai toneRose
```

## Components

### App experience

- [App interface](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/app/layout.tsx): `src/app/app/layout.tsx`

### Business domains

- [Employee API](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/employees/route.ts): `src/app/api/employees/route.ts`
- [Task API](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/tasks/route.ts): `src/app/api/tasks/route.ts`
- [Operations API](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/operations/route.ts): `src/app/api/operations/route.ts`
- [Calendar API](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/calendar/route.ts): `src/app/api/calendar/route.ts`
- [Finance](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/finance/overview/route.ts): `src/app/api/finance/overview/route.ts`
- [CRM](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/crm/clients/route.ts): `src/app/api/crm/clients/route.ts`
- [Inventory](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/inventory/overview/route.ts): `src/app/api/inventory/overview/route.ts`
- [HR and payroll](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/hr/leaves/route.ts): `src/app/api/hr/leaves/route.ts`
- [Legal](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/app/api/legal/cases/route.ts): `src/app/api/legal/cases/route.ts`
- [Task service](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/task.service.ts): `src/services/task.service.ts`
- [Operations service](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/operation.service.ts): `src/services/operation.service.ts`

### Shared platform

- [Session auth](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/auth.ts): `src/lib/auth.ts`
- [Offline auth](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/offline-auth.ts): `src/lib/offline-auth.ts`
- [Employee store](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/employee-store.ts): `src/lib/employee-store.ts`
- [Access control](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/rbac.service.ts): `src/services/rbac.service.ts`
- [Prisma database](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/db.ts): `src/lib/db.ts`
- [API responses](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/lib/api-response.ts): `src/lib/api-response.ts`
- [Audit service](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/audit.service.ts): `src/services/audit.service.ts`

### Automation

- [Workflow engine](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/workflow-engine.service.ts): `src/services/workflow-engine.service.ts`
- [Event bus](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/event-bus.service.ts): `src/services/event-bus.service.ts`
- [Escalation engine](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/escalation-engine.service.ts): `src/services/escalation-engine.service.ts`
- [AI services](https://github.com/ncfventurestudio-ship-it/nvfs-crm/blob/master/src/services/ai/ai.service.ts): `src/services/ai/ai.service.ts`

### Other components

- **Business user**

## Connections

- Business user → App interface: uses
- App interface → Employee API: requests
- Employee API → Session auth: authenticates (evidence: `src/app/api/employees/route.ts`)
- Employee API → Prisma database: queries (evidence: `src/app/api/employees/route.ts`)
- Employee API → Employee store: uses fallback (evidence: `src/app/api/employees/route.ts`)
- Employee API → Access control: checks access (evidence: `src/app/api/employees/route.ts`)
- Employee API → API responses: formats response (evidence: `src/app/api/employees/route.ts`)
- Task API → Session auth: authenticates (evidence: `src/app/api/tasks/route.ts`)
- Task API → Task service: delegates (evidence: `src/app/api/tasks/route.ts`)
- Task API → API responses: formats response (evidence: `src/app/api/tasks/route.ts`)
- Operations API → Session auth: authenticates (evidence: `src/app/api/operations/route.ts`)
- Operations API → Operations service: delegates (evidence: `src/app/api/operations/route.ts`)
- Calendar API → Session auth: authenticates (evidence: `src/app/api/calendar/route.ts`)
- Calendar API → API responses: formats response (evidence: `src/app/api/calendar/route.ts`)
- Session auth → Prisma database: loads session (evidence: `src/lib/auth.ts`)
- Session auth → Offline auth: falls back (evidence: `src/lib/auth.ts`)
- Offline auth → Employee store: looks up employees (evidence: `src/lib/offline-auth.ts`)
- Workflow engine → Prisma database: reads and writes (evidence: `src/services/workflow-engine.service.ts`)
- Workflow engine → Event bus: publishes events (evidence: `src/services/workflow-engine.service.ts`)
- Workflow engine → Escalation engine: executes escalation (evidence: `src/services/workflow-engine.service.ts`)
- Workflow engine → Audit service: logs mutations (evidence: `src/services/workflow-engine.service.ts`)
- Event bus → Prisma database: writes notifications (evidence: `src/services/event-bus.service.ts`)
- Event bus → Audit service: logs events (evidence: `src/services/event-bus.service.ts`)
- Escalation engine → Event bus: publishes notice (evidence: `src/services/escalation-engine.service.ts`)
- Escalation engine → Prisma database: resolves targets (evidence: `src/services/escalation-engine.service.ts`)
