# quanghiep03198/be-wms architecture

> Architecture diagram of the GitHub repository quanghiep03198/be-wms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/quanghiep03198/be-wms
- Repository: https://github.com/quanghiep03198/be-wms

## Overview

##### Project Type and Purpose
- This is a RESTful API project built with NestJS.
- It is designed to manage warehouse operations such as product and inventory management, order processing, warehouse zones, and reporting.
- It uses SQL Server (via TypeORM) as the primary database and Redis for caching. Authentication (e.g., JWT-based) and third-party integrations further extend its functionality.
- Internationalization (i18n) support and modular design for various warehouse-related operations are evident.

##### Main Components
- API Gateway/Entry Point:
– Represented by NestJS components such as controllers, modules, and main.ts.
- Modules (Domain-Specific):
– Authentication Module: Handles user login, JWT strategies, and guards.
– Order Module: Manages order processing with both current and legacy (deprecated) components.
– Inventory/Database Module: Contains migration, seeds, and data-source management.
– Warehousing Module: Deals with warehouses, storage locations, and zone management.
– RFID Module: Processes RFID interactions and custom SQL queries.
– Report Module: Manages reporting services including inventory, outbound/inbound, and packing reports.
– Additional modules for third-party API integration, packing, user management, and tenancy.
- Cross-Cutting Concerns:
– Common utilities (helpers, filters, interceptors, pipes, decorators) that cover logging, error-handling, authentication, and data transformation.
– Internationalization (i18n) directories and generated files.
- Infrastructure Components:
– Database (SQL Server) and TypeORM for ORM/transactions.
– Redis for caching and fast data retrieval.
– Docker and Docker Compose for containerized deployment.
– CI/CD configuration through GitHub workflows.
– Monitoring tools such as SonarQube and Sentry.

##### Mapping Relationships and Interactions
- Client Interaction:
– Clients send HTTP requests to the REST API endpoints (exposed via controllers).
- Application Services:
– Controllers call service classes within each module. Services use dependency injection to interact with databases, caching, and external APIs.
- Database and Caching Layers:
– Services interact with the SQL Server database through TypeORM (database.module.ts, migrations, seeders).
- External Dependencies & Interceptors:
– Show external integrations such as third-party APIs used by the Third-Party API module.
– Include auxiliary components such as logging services, job schedulers (jobs directory), and internationalization files.

##### Highlighting Architectural Patterns and Technologies
- Modular & Layered Architecture:
- Dependency Injection & Separation of Concerns:
– Emphasize how modules keep responsibilities separated (e.g., authentication, order processing, RFID).
- Use of Cross-Cutting Concerns:
– Indicate where interceptors, filters, and pipes help in processing requests/responses.
- Technologies to Include:
– NestJS, TypeScript for the code base.
– SQL Server with TypeORM for the database layer.
– Redis for caching.
– Docker for containerization.
– CI/CD pipelines via GitHub Actions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        CLIENT["Client (User)"]:::presentation
        API["API Gateway / NestJS Controllers"]:::presentation
    end
    CLIENT -->|"HTTP_Request"| API

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        AUTH["Auth Module"]:::business
        ORDER["Order Module"]:::business
        WAREHOUSE["Warehouse Module"]:::business
        RFID["RFID Module"]:::business
        REPORT["Report Module"]:::business
        THIRD_PARTY["Third-Party API Module"]:::business
        PACKING["Packing Module"]:::business
        USER["User Module"]:::business
        TENANCY["Tenancy Module"]:::business
        COMMON["Common Utilities"]:::business
        I18N["Internationalization (i18n)"]:::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DB["SQL Server (TypeORM) / Inventory DB"]:::data
        REDIS["Redis Cache"]:::data
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        REDIS_MSG["Redis Messaging"]:::infra
        JOBS["Jobs Scheduler"]:::infra
        CI_CD["Containerization & CI/CD"]:::infra
    end

    %% Connections from Presentation to Business Logic
    API -->|"routes_to"| AUTH
    API -->|"routes_to"| ORDER
    API -->|"routes_to"| WAREHOUSE
    API -->|"routes_to"| RFID
    API -->|"routes_to"| REPORT
    API -->|"routes_to"| THIRD_PARTY
    API -->|"routes_to"| PACKING
    API -->|"routes_to"| USER
    API -->|"routes_to"| TENANCY

    %% Business Logic interactions with Data Access Layer
    AUTH -->|"DB_Cache"| DB
    ORDER -->|"DB"| DB
    WAREHOUSE -->|"DB"| DB
    RFID -->|"DB_Cache"| DB
    REPORT -->|"DB"| DB
    THIRD_PARTY -->|"DB"| DB
    PACKING -->|"DB"| DB
    USER -->|"DB"| DB
    TENANCY -->|"DB"| DB

    AUTH -->|"Cache"| REDIS
    RFID -->|"Cache"| REDIS

    %% Cross-Cutting Utilities Interaction
    COMMON ---|"supports"| AUTH
    COMMON ---|"supports"| ORDER
    COMMON ---|"supports"| WAREHOUSE
    COMMON ---|"supports"| RFID
    COMMON ---|"supports"| REPORT
    COMMON ---|"supports"| THIRD_PARTY
    COMMON ---|"supports"| PACKING
    COMMON ---|"supports"| USER
    COMMON ---|"supports"| TENANCY

    %% Internationalization support
    I18N ---|"i18n_support"| COMMON

    %% Infrastructure integration
    COMMON ---|"logging/error"| JOBS
    COMMON ---|"integration"| REDIS_MSG
    API ---|"deploys_via"| CI_CD

    %% Click Events
    click API "https://github.com/quanghiep03198/be-wms/blob/develop/src/main.ts"
    click AUTH "https://github.com/quanghiep03198/be-wms/tree/develop/src/modules/auth"
    click ORDER "https://github.com/quanghiep03198/be-wms/tree/develop/src/modules/order"
    click WAREHOUSE "https://github.com/quanghiep03198/be-wms/tree/develop/src/modules/warehouse"
    click RFID "https://github.com/quanghiep03198/be-wms/tree/develop/src/modules/rfid"
    click REPORT "https://github.com/quanghiep03198/be-wms/tree/develop/src/modules/report"
    click THIRD_PARTY "https://github.com/quanghiep03198/be-wms/tree/develop/src/modules/third-party-api"
    click PACKING "https://github.com/quanghiep03198/be-wms/tree/develop/src/modules/packing"
    click USER "https://github.com/quanghiep03198/be-wms/tree/develop/src/modules/user"
    click TENANCY "https://github.com/quanghiep03198/be-wms/tree/develop/src/modules/tenancy"
    click COMMON "https://github.com/quanghiep03198/be-wms/tree/develop/src/common"
    click I18N "https://github.com/quanghiep03198/be-wms/tree/develop/src/i18n"
    click DB "https://github.com/quanghiep03198/be-wms/tree/develop/src/databases"
    click REDIS_MSG "https://github.com/quanghiep03198/be-wms/tree/develop/src/messages"
    click JOBS "https://github.com/quanghiep03198/be-wms/tree/develop/src/jobs"
    click CI_CD "https://github.com/quanghiep03198/be-wms/tree/develop/Dockerfile"

    %% Styles
    classDef presentation fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef business fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef data fill:#FFCDD2,stroke:#B71C1C,stroke-width:2px;
    classDef infra fill:#FFF9C4,stroke:#F57F17,stroke-width:2px;
```
