# hertilan/kaizen-be architecture

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

- Interactive diagram: https://gitdiagram.com/hertilan/kaizen-be
- Repository: https://github.com/hertilan/kaizen-be

## Overview

Kaizen BE is an Express backend for a business-management portal. A client request enters through the API server and a domain route, then a controller performs domain operations and accesses persisted records through Prisma; selected routes also apply authentication. The visible capabilities include general commerce, finance, supplier distribution, engineering project management, tasks, notifications, and exports. Controller and route files establish these domains, but only some controller implementations were sampled, so internal links are shown only where supported.

Main entry points: [`src/prisma.ts`](https://github.com/hertilan/kaizen-be/blob/develop/src/prisma.ts) (Prisma client), [`src/index.ts`](https://github.com/hertilan/kaizen-be/blob/develop/src/index.ts) (Express API), [`src/controllers/productController.ts`](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/productController.ts) (Commerce controllers), [`src/routes/financeRoutes.ts`](https://github.com/hertilan/kaizen-be/blob/develop/src/routes/financeRoutes.ts) (Finance routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["API platform"]
  node_server["Express API<br/>[index.ts]"]
  node_auth_routes["Auth routes<br/>[authRoutes.ts]"]
  node_auth_controller["Authentication<br/>[authController.ts]"]
  node_auth_middleware["Auth middleware<br/>[auth.ts]"]
  node_users["User management<br/>[userController.ts]"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
end

subgraph group_commerce["Commerce operations"]
  node_commerce_routes["Commerce routes<br/>[productRoutes.ts]"]
  node_commerce_controllers["Commerce controllers"]
  node_purchases["Purchasing"]
  node_stock["Inventory<br/>[stockController.ts]"]
  node_invoices["Invoicing"]
  node_payments["Payments"]
end

subgraph group_finance["Finance"]
  node_finance_routes["Finance routes<br/>[financeRoutes.ts]"]
  node_finance["Finance and reports"]
end

subgraph group_specialty["Specialty operations"]
  node_sd_routes["Distribution routes<br/>[sdRoutes.ts]"]
  node_sd["Supplier distribution<br/>[sdController.ts]"]
  node_engineering_routes["Engineering routes<br/>[engRoutes.ts]"]
  node_engineering["Engineering projects<br/>[engController.ts]"]
  node_tasks["Task management<br/>[taskController.ts]"]
end

subgraph group_shared["Shared services"]
  node_notifications["Notifications"]
  node_exports["Exports"]
  node_export_service["Export generation<br/>[exportService.ts]"]
end

node_client(("API client"))
node_database[("PostgreSQL database")]

node_client -->|"sends requests"| node_server
node_server -->|"mounts auth"| node_auth_routes
node_server -->|"mounts commerce"| node_commerce_routes
node_server -->|"mounts finance"| node_finance_routes
node_server -->|"mounts distribution"| node_sd_routes
node_server -->|"mounts engineering"| node_engineering_routes
node_server -->|"initializes client"| node_prisma
node_auth_routes -->|"dispatches"| node_auth_controller
node_commerce_routes -->|"dispatches"| node_commerce_controllers
node_finance_routes -->|"authenticates"| node_auth_middleware
node_finance_routes -->|"dispatches"| node_finance
node_sd_routes -->|"authenticates"| node_auth_middleware
node_sd_routes -->|"dispatches"| node_sd
node_engineering_routes -->|"authenticates"| node_auth_middleware
node_engineering_routes -->|"dispatches"| node_engineering
node_commerce_controllers -.->|"delegates"| node_purchases
node_commerce_controllers -.->|"delegates"| node_stock
node_commerce_controllers -.->|"delegates"| node_invoices
node_commerce_controllers -.->|"delegates"| node_payments
node_tasks -->|"creates alerts"| node_notifications
node_engineering -->|"uses service"| node_notifications
node_exports -.->|"generates files"| node_export_service
node_auth_controller -->|"accesses records"| node_prisma
node_users -->|"accesses records"| node_prisma
node_finance -->|"reads and writes"| node_prisma
node_sd -->|"reads and writes"| node_prisma
node_engineering -->|"reads and writes"| node_prisma
node_tasks -->|"reads and writes"| node_prisma
node_notifications -->|"reads and writes"| node_prisma
node_prisma -->|"queries"| node_database

click node_server "https://github.com/hertilan/kaizen-be/blob/develop/src/index.ts"
click node_auth_routes "https://github.com/hertilan/kaizen-be/blob/develop/src/routes/authRoutes.ts"
click node_auth_controller "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/authController.ts"
click node_auth_middleware "https://github.com/hertilan/kaizen-be/blob/develop/src/middlewares/auth.ts"
click node_users "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/userController.ts"
click node_commerce_routes "https://github.com/hertilan/kaizen-be/blob/develop/src/routes/productRoutes.ts"
click node_commerce_controllers "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/productController.ts"
click node_purchases "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/purchaseController.ts"
click node_stock "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/stockController.ts"
click node_invoices "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/invoiceController.ts"
click node_payments "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/paymentController.ts"
click node_finance_routes "https://github.com/hertilan/kaizen-be/blob/develop/src/routes/financeRoutes.ts"
click node_finance "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/financeController.ts"
click node_sd_routes "https://github.com/hertilan/kaizen-be/blob/develop/src/routes/sdRoutes.ts"
click node_sd "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/sdController.ts"
click node_engineering_routes "https://github.com/hertilan/kaizen-be/blob/develop/src/routes/engRoutes.ts"
click node_engineering "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/engController.ts"
click node_tasks "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/taskController.ts"
click node_notifications "https://github.com/hertilan/kaizen-be/blob/develop/src/services/notificationService.ts"
click node_exports "https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/exportController.ts"
click node_export_service "https://github.com/hertilan/kaizen-be/blob/develop/src/services/exportService.ts"
click node_prisma "https://github.com/hertilan/kaizen-be/blob/develop/src/prisma.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_server,node_auth_routes,node_auth_controller,node_auth_middleware,node_users,node_prisma,node_client toneBlue
class node_commerce_routes,node_commerce_controllers,node_purchases,node_stock,node_invoices,node_payments,node_database toneAmber
class node_finance_routes,node_finance toneMint
class node_sd_routes,node_sd,node_engineering_routes,node_engineering,node_tasks toneRose
class node_notifications,node_exports,node_export_service toneIndigo
```

## Components

### API platform

- [Express API](https://github.com/hertilan/kaizen-be/blob/develop/src/index.ts): `src/index.ts`
- [Auth routes](https://github.com/hertilan/kaizen-be/blob/develop/src/routes/authRoutes.ts): `src/routes/authRoutes.ts`
- [Authentication](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/authController.ts): `src/controllers/authController.ts`
- [Auth middleware](https://github.com/hertilan/kaizen-be/blob/develop/src/middlewares/auth.ts): `src/middlewares/auth.ts`
- [User management](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/userController.ts): `src/controllers/userController.ts`
- [Prisma client](https://github.com/hertilan/kaizen-be/blob/develop/src/prisma.ts): `src/prisma.ts`

### Commerce operations

- [Commerce routes](https://github.com/hertilan/kaizen-be/blob/develop/src/routes/productRoutes.ts): `src/routes/productRoutes.ts`
- [Commerce controllers](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/productController.ts): `src/controllers/productController.ts`
- [Purchasing](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/purchaseController.ts): `src/controllers/purchaseController.ts`
- [Inventory](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/stockController.ts): `src/controllers/stockController.ts`
- [Invoicing](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/invoiceController.ts): `src/controllers/invoiceController.ts`
- [Payments](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/paymentController.ts): `src/controllers/paymentController.ts`

### Finance

- [Finance routes](https://github.com/hertilan/kaizen-be/blob/develop/src/routes/financeRoutes.ts): `src/routes/financeRoutes.ts`
- [Finance and reports](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/financeController.ts): `src/controllers/financeController.ts`

### Specialty operations

- [Distribution routes](https://github.com/hertilan/kaizen-be/blob/develop/src/routes/sdRoutes.ts): `src/routes/sdRoutes.ts`
- [Supplier distribution](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/sdController.ts): `src/controllers/sdController.ts`
- [Engineering routes](https://github.com/hertilan/kaizen-be/blob/develop/src/routes/engRoutes.ts): `src/routes/engRoutes.ts`
- [Engineering projects](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/engController.ts): `src/controllers/engController.ts`
- [Task management](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/taskController.ts): `src/controllers/taskController.ts`

### Shared services

- [Notifications](https://github.com/hertilan/kaizen-be/blob/develop/src/services/notificationService.ts): `src/services/notificationService.ts`
- [Exports](https://github.com/hertilan/kaizen-be/blob/develop/src/controllers/exportController.ts): `src/controllers/exportController.ts`
- [Export generation](https://github.com/hertilan/kaizen-be/blob/develop/src/services/exportService.ts): `src/services/exportService.ts`

### Other components

- **API client**
- **PostgreSQL database**

## Connections

- API client → Express API: sends requests
- Express API → Auth routes: mounts auth
- Express API → Commerce routes: mounts commerce
- Express API → Finance routes: mounts finance
- Express API → Distribution routes: mounts distribution
- Express API → Engineering routes: mounts engineering
- Express API → Prisma client: initializes client
- Auth routes → Authentication: dispatches
- Commerce routes → Commerce controllers: dispatches
- Finance routes → Auth middleware: authenticates
- Finance routes → Finance and reports: dispatches
- Distribution routes → Auth middleware: authenticates
- Distribution routes → Supplier distribution: dispatches
- Engineering routes → Auth middleware: authenticates
- Engineering routes → Engineering projects: dispatches
- Commerce controllers → Purchasing: delegates
- Commerce controllers → Inventory: delegates
- Commerce controllers → Invoicing: delegates
- Commerce controllers → Payments: delegates
- Task management → Notifications: creates alerts
- Engineering projects → Notifications: uses service
- Exports → Export generation: generates files
- Authentication → Prisma client: accesses records
- User management → Prisma client: accesses records
- Finance and reports → Prisma client: reads and writes
- Supplier distribution → Prisma client: reads and writes
- Engineering projects → Prisma client: reads and writes
- Task management → Prisma client: reads and writes
- Notifications → Prisma client: reads and writes
- Prisma client → PostgreSQL database: queries
