# bhuman-it-organization/erp-docs architecture

> Architecture diagram of the GitHub repository bhuman-it-organization/erp-docs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhuman-it-organization/erp-docs
- Repository: https://github.com/bhuman-it-organization/erp-docs

## Overview

This repository copy contains backend-module and frontend-feature templates, not the running ERP stack. The example-item feature demonstrates the intended user workflow: browse/search and page records, open or edit a record, create one, and export a list. The backend example shows controller-to-service orchestration and repository-backed reads/writes, with shared auth, paging, export, and error facilities. The frontend page-to-feature wiring and several backend rule-layer calls are not shown in the excerpts, so those links are omitted or marked unverified rather than inferred.

Main entry points: [`05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts`](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts) (HTTP controller), [`05-templates/backend-module/src/v1/example-item/service/example-item.service.ts`](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/service/example-item.service.ts) (Use-case service), [`05-templates/frontend-feature/src/features/example-item/pages/ExampleItemListPage.tsx`](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/src/features/example-item/pages/ExampleItemListPage.tsx) (List and record UI), [`05-templates/frontend-feature/src/features/example-item/hooks/use-example-item.ts`](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/src/features/example-item/hooks/use-example-item.ts) (Data hooks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend feature"]
  node_web_pages["Feature pages<br/>[page.tsx]"]
  node_feature_pages["List and record UI"]
  node_feature_components["Forms and lists"]
  node_feature_hooks["Data hooks"]
  node_endpoints["Endpoint table"]
end

subgraph group_backend["Backend module"]
  node_controller["HTTP controller"]
  node_service["Use-case service"]
  node_repository["Example repository"]
  node_model["Example item model"]
  node_dto["Request and response DTOs"]
  node_routes["Routes and permissions"]
  node_memory_store["In-memory rows"]
end

subgraph group_shared["Backend platform"]
  node_guards["JWT and permission guards<br/>[jwt-auth.guard.ts]"]
  node_verifier["Token verifier port"]
  node_scope["Read scope<br/>[scope.decorator.ts]"]
  node_paging["Keyset paging<br/>[keyset.ts]"]
  node_export["File export<br/>[export.ts]"]
  node_errors["Error mapping<br/>[app-error.ts]"]
  node_error_codes["Error catalog<br/>[error-codes.ts]"]
end

node_user(("Staff user"))
node_api_actor(("HTTP client"))

node_user -.->|"uses"| node_web_pages
node_web_pages -.->|"renders"| node_feature_pages
node_feature_pages -.->|"uses"| node_feature_components
node_feature_pages -.->|"loads data"| node_feature_hooks
node_feature_hooks -.->|"uses"| node_endpoints
node_feature_hooks -.->|"requests"| node_api_actor
node_api_actor -->|"calls routes"| node_controller
node_controller -->|"dispatches"| node_service
node_service -->|"queries and writes"| node_repository
node_repository -->|"reads and writes"| node_memory_store
node_repository -->|"stores rows"| node_model
node_controller -->|"uses schemas"| node_dto
node_controller -->|"binds paths"| node_routes
node_controller -->|"runs guards"| node_guards
node_guards -->|"verifies token"| node_verifier
node_controller -->|"reads scope"| node_scope
node_service -->|"runs export"| node_export
node_service -->|"uses cursors"| node_paging
node_errors -->|"looks up codes"| node_error_codes

click node_web_pages "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/app/(shell)/example-item/page.tsx"
click node_feature_pages "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/src/features/example-item/pages/ExampleItemListPage.tsx"
click node_feature_components "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/src/features/example-item/components/ExampleItemForm.tsx"
click node_feature_hooks "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/src/features/example-item/hooks/use-example-item.ts"
click node_endpoints "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/src/features/example-item/api/example-item.endpoints.ts"
click node_controller "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts"
click node_service "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/service/example-item.service.ts"
click node_repository "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/repository/example-item.repository.ts"
click node_model "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/model/example-item.model.ts"
click node_dto "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/dto/example-item.dto.ts"
click node_routes "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/example-item.routes.ts"
click node_guards "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/http/guards/jwt-auth.guard.ts"
click node_verifier "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/http/auth/access-token-verifier.ts"
click node_scope "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/http/decorators/scope.decorator.ts"
click node_paging "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/http/keyset.ts"
click node_export "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/http/export.ts"
click node_errors "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/errors/app-error.ts"
click node_error_codes "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/errors/error-codes.ts"
click node_memory_store "https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/repository/example-item.repository.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_web_pages,node_feature_pages,node_feature_components,node_feature_hooks,node_endpoints,node_user,node_api_actor toneBlue
class node_controller,node_service,node_repository,node_model,node_dto,node_routes,node_memory_store toneAmber
class node_guards,node_verifier,node_scope,node_paging,node_export,node_errors,node_error_codes toneMint
```

## Components

### Frontend feature

- [Feature pages](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/app/(shell)/example-item/page.tsx): `05-templates/frontend-feature/app/(shell)/example-item/page.tsx`
- [List and record UI](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/src/features/example-item/pages/ExampleItemListPage.tsx): `05-templates/frontend-feature/src/features/example-item/pages/ExampleItemListPage.tsx`
- [Forms and lists](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/src/features/example-item/components/ExampleItemForm.tsx): `05-templates/frontend-feature/src/features/example-item/components/ExampleItemForm.tsx`
- [Data hooks](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/src/features/example-item/hooks/use-example-item.ts): `05-templates/frontend-feature/src/features/example-item/hooks/use-example-item.ts`
- [Endpoint table](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/frontend-feature/src/features/example-item/api/example-item.endpoints.ts): `05-templates/frontend-feature/src/features/example-item/api/example-item.endpoints.ts`

### Backend module

- [HTTP controller](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts): `05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts`
- [Use-case service](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/service/example-item.service.ts): `05-templates/backend-module/src/v1/example-item/service/example-item.service.ts`
- [Example repository](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/repository/example-item.repository.ts): `05-templates/backend-module/src/v1/example-item/repository/example-item.repository.ts`
- [Example item model](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/model/example-item.model.ts): `05-templates/backend-module/src/v1/example-item/model/example-item.model.ts`
- [Request and response DTOs](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/dto/example-item.dto.ts): `05-templates/backend-module/src/v1/example-item/dto/example-item.dto.ts`
- [Routes and permissions](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/example-item.routes.ts): `05-templates/backend-module/src/v1/example-item/example-item.routes.ts`
- [In-memory rows](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/v1/example-item/repository/example-item.repository.ts): `05-templates/backend-module/src/v1/example-item/repository/example-item.repository.ts`

### Backend platform

- [JWT and permission guards](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/http/guards/jwt-auth.guard.ts): `05-templates/backend-module/src/shared/http/guards/jwt-auth.guard.ts`
- [Token verifier port](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/http/auth/access-token-verifier.ts): `05-templates/backend-module/src/shared/http/auth/access-token-verifier.ts`
- [Read scope](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/http/decorators/scope.decorator.ts): `05-templates/backend-module/src/shared/http/decorators/scope.decorator.ts`
- [Keyset paging](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/http/keyset.ts): `05-templates/backend-module/src/shared/http/keyset.ts`
- [File export](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/http/export.ts): `05-templates/backend-module/src/shared/http/export.ts`
- [Error mapping](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/errors/app-error.ts): `05-templates/backend-module/src/shared/errors/app-error.ts`
- [Error catalog](https://github.com/bhuman-it-organization/erp-docs/blob/main/05-templates/backend-module/src/shared/errors/error-codes.ts): `05-templates/backend-module/src/shared/errors/error-codes.ts`

### Other components

- **Staff user**
- **HTTP client**

## Connections

- Staff user → Feature pages: uses
- Feature pages → List and record UI: renders
- List and record UI → Forms and lists: uses
- List and record UI → Data hooks: loads data
- Data hooks → Endpoint table: uses
- Data hooks → HTTP client: requests
- HTTP client → HTTP controller: calls routes (evidence: `05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts`)
- HTTP controller → Use-case service: dispatches (evidence: `05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts`)
- Use-case service → Example repository: queries and writes (evidence: `05-templates/backend-module/src/v1/example-item/service/example-item.service.ts`)
- Example repository → In-memory rows: reads and writes (evidence: `05-templates/backend-module/src/v1/example-item/repository/example-item.repository.ts`)
- Example repository → Example item model: stores rows (evidence: `05-templates/backend-module/src/v1/example-item/repository/example-item.repository.ts`)
- HTTP controller → Request and response DTOs: uses schemas (evidence: `05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts`)
- HTTP controller → Routes and permissions: binds paths (evidence: `05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts`)
- HTTP controller → JWT and permission guards: runs guards (evidence: `05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts`)
- JWT and permission guards → Token verifier port: verifies token (evidence: `05-templates/backend-module/src/shared/http/guards/jwt-auth.guard.ts`)
- HTTP controller → Read scope: reads scope (evidence: `05-templates/backend-module/src/v1/example-item/controller/example-item.controller.ts`)
- Use-case service → File export: runs export (evidence: `05-templates/backend-module/src/v1/example-item/service/example-item.service.ts`)
- Use-case service → Keyset paging: uses cursors (evidence: `05-templates/backend-module/src/v1/example-item/service/example-item.service.ts`)
- Error mapping → Error catalog: looks up codes (evidence: `05-templates/backend-module/src/shared/errors/app-error.ts`)
