# garment-wms/garment-wms-be architecture

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

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

## Overview

##### Main Components
- Database Layer: Illustrate the database component behind Prisma. This should be shown as a distinct “Database (via Prisma ORM)” component. Optionally include a note about “Prisma Migrations” and “Prisma Schema” files.
- Common Infrastructure: Add components such as “Common Utilities”, “Global Filters”, “Interceptors”, “Pipes”, and “Guards” to represent cross-cutting concerns that the entire NestJS application uses.
- External Services: Highlight connections to other systems such as email (via the “Mail” module), Firebase, notifications (socket gateway for notifications), and any other integrations (e.g., third-party authentication or storage services).

##### Architectural Patterns and Design Principles
- That each module encapsulates its own domain logic while all modules are unified under the central NestJS application.

##### Putting It All Together
- External dependencies like Mail, Firebase, or Notification services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    APIReq["API Request"]:::api
    NestJSApp["NestJS Application (main.ts, app.module.ts)"]:::nestjs

    APIReq --> NestJSApp

    subgraph "Domain Modules"
        direction TB
        AuthModule["Auth Module"]:::domain
        ChatModule["Chat Module"]:::domain
        DefectModule["Defect Module"]:::domain
        DashboardModule["Dashboard Module"]:::domain
        ImportReqModule["Import Request Module"]:::domain
        InspectionReportModule["Inspection Report Module"]:::domain
        InventoryReportModule["Inventory Report Module"]:::domain
        MaterialModule["Material Module"]:::domain
        ProductModule["Product Module"]:::domain
        ProductionBatchModule["Production Batch Module"]:::domain
        PurchaseOrderModule["Purchase Order Module"]:::domain
        UserModule["User Module"]:::domain
    end

    NestJSApp --> AuthModule
    NestJSApp --> ChatModule
    NestJSApp --> DefectModule
    NestJSApp --> DashboardModule
    NestJSApp --> ImportReqModule
    NestJSApp --> InspectionReportModule
    NestJSApp --> InventoryReportModule
    NestJSApp --> MaterialModule
    NestJSApp --> ProductModule
    NestJSApp --> ProductionBatchModule
    NestJSApp --> PurchaseOrderModule
    NestJSApp --> UserModule

    AuthModule --> PrismaDB["Database (via Prisma ORM)"]:::database
    ChatModule --> PrismaDB
    DefectModule --> PrismaDB
    DashboardModule --> PrismaDB
    ImportReqModule --> PrismaDB
    InspectionReportModule --> PrismaDB
    InventoryReportModule --> PrismaDB
    MaterialModule --> PrismaDB
    ProductModule --> PrismaDB
    ProductionBatchModule --> PrismaDB
    PurchaseOrderModule --> PrismaDB
    UserModule --> PrismaDB

    NestJSApp --> CommonInfra["Common Infrastructure"]:::common

    subgraph "External Integrations"
        direction TB
        MailIntegration["Mail Integration"]:::ext
        FirebaseIntegration["Firebase Integration"]:::ext
        NotificationService["Notification Service"]:::ext
    end

    NestJSApp --> MailIntegration
    NestJSApp --> FirebaseIntegration
    NestJSApp --> NotificationService

    Deployment["Containerization & Deployment"]:::deploy
    Deployment --> NestJSApp

    %% Example of cross-module interaction
    AuthModule -->|"uses"| UserModule

    %% Click Events
    click NestJSApp "https://github.com/garment-wms/garment-wms-be/blob/d_dev/src/main.ts"
    click NestJSApp "https://github.com/garment-wms/garment-wms-be/blob/d_dev/src/app.module.ts"
    click AuthModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/auth/"
    click ChatModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/chat/"
    click DefectModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/defect/"
    click DashboardModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/dashboard/"
    click ImportReqModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/import-request/"
    click InspectionReportModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/inspection-report/"
    click InventoryReportModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/inventory-report/"
    click MaterialModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/material/"
    click ProductModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/product/"
    click ProductionBatchModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/production-batch/"
    click PurchaseOrderModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/purchase-order/"
    click UserModule "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/user/"
    click PrismaDB "https://github.com/garment-wms/garment-wms-be/tree/d_dev/prisma/"
    click CommonInfra "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/common/"
    click MailIntegration "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/mail/"
    click FirebaseIntegration "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/modules/firebase/"
    click NotificationService "https://github.com/garment-wms/garment-wms-be/tree/d_dev/src/notification/"
    click Deployment "https://github.com/garment-wms/garment-wms-be/tree/d_dev/Dockerfile"
    click Deployment "https://github.com/garment-wms/garment-wms-be/blob/d_dev/docker-compose.yml"
    click Deployment "https://github.com/garment-wms/garment-wms-be/blob/d_dev/render.yaml"

    %% Styles
    classDef api fill:#ffd1dc,stroke:#333,stroke-width:2px;
    classDef nestjs fill:#ade1f9,stroke:#333,stroke-width:2px;
    classDef domain fill:#c4f7c5,stroke:#333,stroke-width:2px;
    classDef database fill:#f7e1ad,stroke:#333,stroke-width:2px;
    classDef common fill:#f9d6ad,stroke:#333,stroke-width:2px;
    classDef ext fill:#f9c1ff,stroke:#333,stroke-width:2px;
    classDef deploy fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
