# leonardodavinci2049/erp-api-server-winerp-v1 architecture

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

- Interactive diagram: https://gitdiagram.com/leonardodavinci2049/erp-api-server-winerp-v1
- Repository: https://github.com/leonardodavinci2049/erp-api-server-winerp-v1

## Overview

WinERP is an early-stage NestJS API for desktop-facing ERP applications. Its implemented workflows authenticate brand and supplier requests, delegate business operations to services that build SQL, execute queries against MySQL/MariaDB, and shape database results into API responses. The repository also includes a static root page and a taxonomy module, though the README identifies brand management as the current business module. The map follows documented behavior and indexed references; unsampled modules are represented only where the tree or README establishes their role.

Main entry points: [`src/brand/brand.service.ts`](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/brand/brand.service.ts) (Brand operations), [`src/supplier/supplier.service.ts`](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/supplier/supplier.service.ts) (Supplier operations), [`src/app.main/app.module.ts`](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/app.main/app.module.ts) (App module), [`src/main.ts`](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/main.ts) (NestJS HTTP app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_http_app["NestJS HTTP app<br/>[main.ts]"]
  node_app_module["App module<br/>[app.module.ts]"]
  node_brand_routes["Brand routes"]
  node_supplier_routes["Supplier routes"]
  node_static_page["Static root page"]
end

subgraph group_business["Business Operations"]
  node_brand_service["Brand operations<br/>[brand.service.ts]"]
  node_brand_requests["Brand request DTOs"]
  node_brand_queries["Brand SQL builders"]
  node_supplier_service["Supplier operations"]
  node_supplier_requests["Supplier request DTOs"]
  node_supplier_queries["Supplier SQL builders"]
  node_taxonomy["Taxonomy endpoint"]
end

subgraph group_shared["Shared Services"]
  node_auth["API key guard<br/>[auth.guard.ts]"]
  node_result_processing["Result processing"]
  node_config["Environment config<br/>[envs.ts]"]
end

subgraph group_storage["Database Access"]
  node_db_operations["SQL operations"]
  node_db_connection["MySQL pool"]
end

node_desktop_client(("Desktop client"))
node_mysql[("MySQL / MariaDB")]

node_desktop_client -->|"sends requests"| node_http_app
node_http_app -->|"starts module"| node_app_module
node_app_module -->|"registers routes"| node_brand_routes
node_app_module -->|"registers routes"| node_supplier_routes
node_brand_routes -->|"guards routes"| node_auth
node_supplier_routes -->|"guards routes"| node_auth
node_brand_routes -->|"dispatches operations"| node_brand_service
node_supplier_routes -->|"dispatches operations"| node_supplier_service
node_brand_service -->|"builds SQL"| node_brand_queries
node_brand_service -->|"uses DTOs"| node_brand_requests
node_brand_service -->|"executes SQL"| node_db_operations
node_brand_service -->|"formats results"| node_result_processing
node_supplier_service -->|"builds SQL"| node_supplier_queries
node_supplier_service -->|"uses DTOs"| node_supplier_requests
node_supplier_service -->|"executes SQL"| node_db_operations
node_supplier_service -->|"formats results"| node_result_processing
node_db_operations -->|"acquires connections"| node_db_connection
node_db_connection -->|"reads settings"| node_config
node_db_connection -->|"creates pool"| node_mysql
node_http_app -.->|"serves root"| node_static_page
node_app_module -.->|"registers endpoint"| node_taxonomy

click node_http_app "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/main.ts"
click node_app_module "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/app.main/app.module.ts"
click node_brand_routes "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/brand/brand.controller.ts"
click node_supplier_routes "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/supplier/supplier.controller.ts"
click node_brand_service "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/brand/brand.service.ts"
click node_brand_requests "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/src/brand/dto"
click node_brand_queries "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/src/brand/query"
click node_supplier_service "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/supplier/supplier.service.ts"
click node_supplier_requests "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/src/supplier/dto"
click node_supplier_queries "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/src/supplier/query"
click node_taxonomy "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/taxonomy/taxonomy.controller.ts"
click node_auth "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/core/guards/auth.guard.ts"
click node_result_processing "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/src/core/process-result"
click node_config "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/core/config/envs.ts"
click node_db_operations "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/db-operation/db-operation.service.ts"
click node_db_connection "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/db-connection/db-connection.service.ts"
click node_static_page "https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/pageroot"

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_http_app,node_app_module,node_brand_routes,node_supplier_routes,node_static_page,node_desktop_client toneBlue
class node_brand_service,node_brand_requests,node_brand_queries,node_supplier_service,node_supplier_requests,node_supplier_queries,node_taxonomy,node_mysql toneAmber
class node_auth,node_result_processing,node_config toneMint
class node_db_operations,node_db_connection toneRose
```

## Components

### HTTP API

- [NestJS HTTP app](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/main.ts): `src/main.ts`
- [App module](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/app.main/app.module.ts): `src/app.main/app.module.ts`
- [Brand routes](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/brand/brand.controller.ts): `src/brand/brand.controller.ts`
- [Supplier routes](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/supplier/supplier.controller.ts): `src/supplier/supplier.controller.ts`
- [Static root page](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/pageroot): `pageroot`

### Business Operations

- [Brand operations](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/brand/brand.service.ts): `src/brand/brand.service.ts`
- [Brand request DTOs](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/src/brand/dto): `src/brand/dto`
- [Brand SQL builders](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/src/brand/query): `src/brand/query`
- [Supplier operations](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/supplier/supplier.service.ts): `src/supplier/supplier.service.ts`
- [Supplier request DTOs](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/src/supplier/dto): `src/supplier/dto`
- [Supplier SQL builders](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/src/supplier/query): `src/supplier/query`
- [Taxonomy endpoint](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/taxonomy/taxonomy.controller.ts): `src/taxonomy/taxonomy.controller.ts`

### Shared Services

- [API key guard](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/core/guards/auth.guard.ts): `src/core/guards/auth.guard.ts`
- [Result processing](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/tree/main/src/core/process-result): `src/core/process-result`
- [Environment config](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/core/config/envs.ts): `src/core/config/envs.ts`

### Database Access

- [SQL operations](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/db-operation/db-operation.service.ts): `src/db-operation/db-operation.service.ts`
- [MySQL pool](https://github.com/leonardodavinci2049/erp-api-server-winerp-v1/blob/main/src/db-connection/db-connection.service.ts): `src/db-connection/db-connection.service.ts`

### Other components

- **Desktop client**
- **MySQL / MariaDB**

## Connections

- Desktop client → NestJS HTTP app: sends requests
- NestJS HTTP app → App module: starts module (evidence: `src/main.ts`)
- App module → Brand routes: registers routes (evidence: `src/app.main/app.module.ts`)
- App module → Supplier routes: registers routes (evidence: `src/app.main/app.module.ts`)
- Brand routes → API key guard: guards routes (evidence: `src/brand/brand.controller.ts`)
- Supplier routes → API key guard: guards routes (evidence: `src/supplier/supplier.controller.ts`)
- Brand routes → Brand operations: dispatches operations (evidence: `src/brand/brand.controller.ts`)
- Supplier routes → Supplier operations: dispatches operations (evidence: `src/supplier/supplier.controller.ts`)
- Brand operations → Brand SQL builders: builds SQL (evidence: `src/brand/brand.service.ts`)
- Brand operations → Brand request DTOs: uses DTOs (evidence: `src/brand/brand.service.ts`)
- Brand operations → SQL operations: executes SQL (evidence: `src/brand/brand.service.ts`)
- Brand operations → Result processing: formats results (evidence: `src/brand/brand.service.ts`)
- Supplier operations → Supplier SQL builders: builds SQL (evidence: `src/supplier/supplier.service.ts`)
- Supplier operations → Supplier request DTOs: uses DTOs (evidence: `src/supplier/supplier.service.ts`)
- Supplier operations → SQL operations: executes SQL (evidence: `src/supplier/supplier.service.ts`)
- Supplier operations → Result processing: formats results (evidence: `src/supplier/supplier.service.ts`)
- SQL operations → MySQL pool: acquires connections (evidence: `src/db-operation/db-operation.service.ts`)
- MySQL pool → Environment config: reads settings (evidence: `src/db-connection/db-connection.service.ts`)
- MySQL pool → MySQL / MariaDB: creates pool (evidence: `src/db-connection/db-connection.service.ts`)
- NestJS HTTP app → Static root page: serves root
- App module → Taxonomy endpoint: registers endpoint
