# luongdinhkhanhvinh/main-micro-order architecture

> Architecture diagram of the GitHub repository luongdinhkhanhvinh/main-micro-order, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/luongdinhkhanhvinh/main-micro-order
- Repository: https://github.com/luongdinhkhanhvinh/main-micro-order

## Overview

##### Project Type Analysis
This is a microservices architecture project built using the NestJS framework, consisting of two main services:
- Order Service
- User Service
The project also includes a proxy setup and Docker configuration, indicating a containerized deployment strategy.

##### Main Components

A. Infrastructure Layer:
- Docker Container Environment
- Nginx Proxy (indicated by the proxy directory)
- SSL/TLS Security Layer (shown by ssl certificates in proxy/ssl)

B. Microservices:
##### Order Service
- Controllers (Order Controller)
- Services (Order Service)
- Domain Entities (Order Entity)
- DTOs (Data Transfer Objects)
- Swagger Documentation

##### User Service
- Address Controller
- User Address Service
- User Address Entity
- User Preference Entity
- DTOs (Request/Response)
- Swagger Documentation

C. Database Layer:
- Database connections (indicated by ormConfig.ts in both services)

**┌─────────────────────────────────────────────────┐**
- Nginx Proxy                     │
- (SSL/TLS Termination)                │
- ┬────────────────┬─────────────┘

- ┌─────────────▼──────┐ ┌──────▼─────────────┐
- Order Service    │ │    User Service     │
- (NestJS Module)   │ │   (NestJS Module)   │
- ┬──────┘ └──────┬─────────────┘

- ┌─────────▼───────┐ ┌─────▼────────┐
- Order Database │ │ User Database │
- ┘ └──────────────┘

**┌─────────────────────────────────┐**
- Microservice          │
- ┌───────────┐    ┌───────────┐ │
- Controllers│←───│   DTOs    │ │
- ┬─────┘    └───────────┘ │

- ┌─────▼─────┐    ┌───────────┐ │
- Services  │←───│ Entities  │ │
- ┬─────┘    └───────────┘ │

- ┌─────▼─────┐                 │
- Database  │                 │
- ┘                 │
- ┘

##### Important Elements to Highlight

a. Communication Flows:
- Database connections
- Service-to-service communication if any exists

b. Infrastructure Details:
- Docker container boundaries
- Network zones
- Security layers

c. Technical Stack Indicators:
- NestJS Framework
- TypeORM (indicated by ormConfig.ts)
- Swagger API documentation
- Docker containerization
- Nginx reverse proxy

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Infrastructure
        Proxy["Nginx Proxy"]:::proxy
        SSL["SSL/TLS Layer"]:::security
        Docker["Docker Environment"]:::infrastructure
    end

    subgraph "Order Service"
        OrderModule["Order Module"]:::module
        OrderController["Order Controller"]:::controller
        OrderService["Order Service"]:::service
        OrderEntity["Order Entity"]:::entity
        OrderDTO["Order DTOs"]:::dto
        OrderSwagger["Order Swagger Docs"]:::docs
        OrderDB[(Order Database)]:::database
        OrderDBConfig["Database Config"]:::config
    end

    subgraph "User Service"
        UserModule["User Module"]:::module
        AddressController["Address Controller"]:::controller
        AddressService["Address Service"]:::service
        AddressEntity["Address Entity"]:::entity
        PreferenceEntity["Preference Entity"]:::entity
        UserDTO["User DTOs"]:::dto
        UserSwagger["User Swagger Docs"]:::docs
        UserDB[(User Database)]:::database
        UserDBConfig["Database Config"]:::config
    end

    %% Infrastructure Relationships
    Proxy --> OrderModule
    Proxy --> UserModule
    SSL --- Proxy
    Docker --- Proxy

    %% Order Service Relationships
    OrderModule --> OrderController
    OrderController --> OrderService
    OrderService --> OrderEntity
    OrderController --> OrderDTO
    OrderModule --> OrderSwagger
    OrderService --> OrderDB
    OrderDBConfig --> OrderDB

    %% User Service Relationships
    UserModule --> AddressController
    AddressController --> AddressService
    AddressService --> AddressEntity
    AddressService --> PreferenceEntity
    AddressController --> UserDTO
    UserModule --> UserSwagger
    AddressService --> UserDB
    UserDBConfig --> UserDB

    %% Click Events
    click Docker "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/docker-compose.yml"
    click Proxy "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/proxy/default.conf"
    click SSL "https://github.com/luongdinhkhanhvinh/main-micro-order/tree/master/proxy/ssl"
    click OrderModule "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/order-service/src/app/domain/domain.module.ts"
    click OrderController "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/order-service/src/app/domain/order/controllers/order.controller.ts"
    click OrderService "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/order-service/src/app/domain/order/services/order.service.ts"
    click OrderEntity "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/order-service/src/app/domain/order/entity/order.entity.ts"
    click OrderDTO "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/order-service/src/app/domain/order/dto/order.dto.ts"
    click OrderSwagger "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/order-service/src/app/docs/swagger.ts"
    click OrderDBConfig "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/order-service/ormConfig.ts"
    click UserModule "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/user-service/src/app/domain/domain.module.ts"
    click AddressController "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/user-service/src/app/domain/address/controller/user.address.controller.ts"
    click AddressService "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/user-service/src/app/domain/address/services/user.address.service.ts"
    click AddressEntity "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/user-service/src/app/domain/address/entity/user.address.entity.ts"
    click PreferenceEntity "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/user-service/src/app/domain/address/entity/user.preference.entity.ts"
    click UserDTO "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/user-service/src/app/domain/address/dto/user-request.dto.ts"
    click UserSwagger "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/user-service/src/docs/swagger.ts"
    click UserDBConfig "https://github.com/luongdinhkhanhvinh/main-micro-order/blob/master/apps/user-service/ormconfig.ts"

    %% Styling
    classDef proxy fill:#6BA5E7,stroke:#333,stroke-width:2px
    classDef security fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#E8E8E8,stroke:#333,stroke-width:2px
    classDef module fill:#90EE90,stroke:#333,stroke-width:2px
    classDef controller fill:#98FB98,stroke:#333,stroke-width:2px
    classDef service fill:#98FB98,stroke:#333,stroke-width:2px
    classDef entity fill:#F0E68C,stroke:#333,stroke-width:2px
    classDef dto fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef docs fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef database fill:#FFD700,stroke:#333,stroke-width:2px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:2px
```
