# xxmazenxx21/drba7r_erp architecture

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

- Interactive diagram: https://gitdiagram.com/xxmazenxx21/drba7r_erp
- Repository: https://github.com/xxmazenxx21/drba7r_erp

## Overview

DrBa7r ERP is a NestJS backend API for branch-based business administration, product and unit setup, warehouse inventory, and stock tracking. The user workflow is to authenticate, then use SUPERADMIN-protected API endpoints to maintain reference data and record or inspect warehouse stock. Controllers delegate to domain services; the sampled services use Prisma for persistence, and product-inventory explicitly delegates stock effects to the stock service. The README establishes the broader API capabilities; some unsampled service internals and application wiring are not shown, so those relationships are omitted.

Main entry points: [`src/prisma/prisma.service.ts`](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/prisma/prisma.service.ts) (PostgreSQL), [`src/auth/auth.service.ts`](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/auth/auth.service.ts) (Authentication), [`src/product-inventory/product-inventory.service.ts`](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/product-inventory/product-inventory.service.ts) (Warehouse products), [`src/stock/stock.service.ts`](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/stock/stock.service.ts) (Stock movements)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity &amp; Access"]
  node_auth_api["Auth endpoints<br/>[auth.controller.ts]"]
  node_auth_service["Authentication<br/>[auth.service.ts]"]
  node_users["User management"]
end

subgraph group_organization["Organization"]
  node_branches["Branches"]
  node_employees["Employees"]
  node_customers["Customers"]
  node_suppliers["Suppliers"]
  node_currencies["Currencies"]
end

subgraph group_catalog["Product Catalog"]
  node_categories["Categories"]
  node_item_units["Item units"]
  node_products["Products"]
  node_product_units["Product units"]
end

subgraph group_stock["Warehouse &amp; Stock"]
  node_warehouses["Warehouses"]
  node_warehouse_products["Warehouse products"]
  node_stock_service["Stock movements<br/>[stock.service.ts]"]
  node_stock_api["Stock queries"]
end

node_client(("API client"))
node_jwt["JWT service"]
node_database[("PostgreSQL<br/>[prisma.service.ts]")]

node_client -->|"logs in"| node_auth_api
node_auth_api -->|"delegates"| node_auth_service
node_auth_service -->|"reads and writes"| node_database
node_auth_service -->|"signs token"| node_jwt
node_client -.->|"manages users"| node_users
node_users -->|"delegates login"| node_auth_service
node_client -.->|"uses API"| node_branches
node_client -.->|"uses API"| node_employees
node_client -.->|"uses API"| node_customers
node_client -.->|"uses API"| node_suppliers
node_client -.->|"uses API"| node_categories
node_client -.->|"uses API"| node_item_units
node_client -.->|"uses API"| node_products
node_client -.->|"uses API"| node_product_units
node_client -.->|"uses API"| node_currencies
node_client -.->|"uses API"| node_warehouses
node_client -.->|"uses API"| node_warehouse_products
node_client -.->|"queries stock"| node_stock_api
node_stock_api -->|"delegates"| node_stock_service
node_products -->|"reads and writes"| node_database
node_product_units -->|"uses Prisma"| node_database
node_warehouse_products -->|"uses Prisma"| node_database
node_warehouse_products -->|"updates stock"| node_stock_service
node_stock_service -->|"uses Prisma"| node_database

click node_auth_api "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/auth/auth.controller.ts"
click node_auth_service "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/auth/auth.service.ts"
click node_users "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/users/users.controller.ts"
click node_branches "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/branch/branch.controller.ts"
click node_employees "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/employees/employees.controller.ts"
click node_customers "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/customer/customer.controller.ts"
click node_suppliers "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/supplier/supplier.controller.ts"
click node_categories "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/categories/categories.controller.ts"
click node_item_units "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/item-unit/item-unit.controller.ts"
click node_products "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/products/products.service.ts"
click node_product_units "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/product-units/product-units.service.ts"
click node_currencies "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/currency/currency.controller.ts"
click node_warehouses "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/inventory/inventory.controller.ts"
click node_warehouse_products "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/product-inventory/product-inventory.service.ts"
click node_stock_service "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/stock/stock.service.ts"
click node_stock_api "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/stock/stock-movements.controller.ts"
click node_database "https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/prisma/prisma.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_auth_api,node_auth_service,node_users,node_client toneBlue
class node_branches,node_employees,node_customers,node_suppliers,node_currencies,node_database toneAmber
class node_categories,node_item_units,node_products,node_product_units toneMint
class node_warehouses,node_warehouse_products,node_stock_service,node_stock_api toneRose
class node_jwt toneIndigo
```

## Components

### Identity & Access

- [Auth endpoints](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Authentication](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [User management](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/users/users.controller.ts): `src/users/users.controller.ts`

### Organization

- [Branches](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/branch/branch.controller.ts): `src/branch/branch.controller.ts`
- [Employees](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/employees/employees.controller.ts): `src/employees/employees.controller.ts`
- [Customers](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/customer/customer.controller.ts): `src/customer/customer.controller.ts`
- [Suppliers](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/supplier/supplier.controller.ts): `src/supplier/supplier.controller.ts`
- [Currencies](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/currency/currency.controller.ts): `src/currency/currency.controller.ts`

### Product Catalog

- [Categories](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/categories/categories.controller.ts): `src/categories/categories.controller.ts`
- [Item units](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/item-unit/item-unit.controller.ts): `src/item-unit/item-unit.controller.ts`
- [Products](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/products/products.service.ts): `src/products/products.service.ts`
- [Product units](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/product-units/product-units.service.ts): `src/product-units/product-units.service.ts`

### Warehouse & Stock

- [Warehouses](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/inventory/inventory.controller.ts): `src/inventory/inventory.controller.ts`
- [Warehouse products](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/product-inventory/product-inventory.service.ts): `src/product-inventory/product-inventory.service.ts`
- [Stock movements](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/stock/stock.service.ts): `src/stock/stock.service.ts`
- [Stock queries](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/stock/stock-movements.controller.ts): `src/stock/stock-movements.controller.ts`

### Other components

- **API client**
- **JWT service**
- [PostgreSQL](https://github.com/xxmazenxx21/drba7r_erp/blob/main/src/prisma/prisma.service.ts): `src/prisma/prisma.service.ts`

## Connections

- API client → Auth endpoints: logs in (evidence: `README.md`)
- Auth endpoints → Authentication: delegates (evidence: `src/auth/auth.controller.ts`)
- Authentication → PostgreSQL: reads and writes (evidence: `src/auth/auth.service.ts`)
- Authentication → JWT service: signs token (evidence: `src/auth/auth.service.ts`)
- API client → User management: manages users
- User management → Authentication: delegates login (evidence: `src/users/users.controller.ts`)
- API client → Branches: uses API
- API client → Employees: uses API
- API client → Customers: uses API
- API client → Suppliers: uses API
- API client → Categories: uses API
- API client → Item units: uses API
- API client → Products: uses API
- API client → Product units: uses API
- API client → Currencies: uses API
- API client → Warehouses: uses API
- API client → Warehouse products: uses API
- API client → Stock queries: queries stock
- Stock queries → Stock movements: delegates (evidence: `src/stock/stock-movements.controller.ts`)
- Products → PostgreSQL: reads and writes (evidence: `src/products/products.service.ts`)
- Product units → PostgreSQL: uses Prisma (evidence: `src/product-units/product-units.service.ts`)
- Warehouse products → PostgreSQL: uses Prisma (evidence: `src/product-inventory/product-inventory.service.ts`)
- Warehouse products → Stock movements: updates stock (evidence: `src/product-inventory/product-inventory.service.ts`)
- Stock movements → PostgreSQL: uses Prisma (evidence: `src/stock/stock.service.ts`)
