# triminh12042002/mgd-main-be architecture

> Architecture diagram of the GitHub repository triminh12042002/mgd-main-be, 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/triminh12042002/mgd-main-be
- Repository: https://github.com/triminh12042002/mgd-main-be

## Overview

##### Project Type and Purpose
- The project is a backend service written in Go (see cmd/server/main.go).
- Its purpose appears to be processing or handling image data (mockData directory shows various image and pose JSON assets) and utilizing Kafka for message handling (see pkg/kafka).

##### File Structure and Architectural Components
- cmd/server: Contains the main entry point. This server is likely the central hub where requests originate.
- config and internal/configs: Hold configuration files and loaders—indicating a clear separation of configuration and core service initialization.
- pkg/kafka: Encapsulates Kafka integration, suggesting that messaging (publishing/subscribing) is a key cross-cutting aspect.
- mockData: Provides sample input data for various image-based operations, which hints that the system processes images and possibly performs image parsing or analysis.

##### Main Components
a. Server Component:
- Main server (referenced from cmd/server/main.go) that starts the application.
- How it accepts incoming requests, potentially via an API or HTTP endpoints.

b. Configuration Module:
- Configuration management via config files (config/config.yml) and internal/configs.

c. Kafka Integration:
- Dedicated Kafka package (pkg/kafka) and how Kafka brokers/queues are used.
- Messaging interactions, such as publishing image processing tasks or receiving processed data.

d. Data Processing / Image Handling Unit:
- Although not explicitly subdivided into separate directories, the presence of mockData and the different image directories (e.g., im_sketch, final_image, openpose_json) implies components that process the input images, transform data, and may interact with external vision libraries.

e. External Dependencies or Services:
- If there are additional services (for instance, a database or third-party image processing APIs), include placeholders. The docker-compose.yml suggests this project might be containerized and may interact with other services.

##### Relationships and Interactions
- From the Server to the Configuration Module on startup.
- From the Server to the Kafka module when pushing or receiving messages.
- From Kafka/processing modules to data storage or external service (if applicable) based on the sequence flows.
- Flow of image data from input (mockData) to processing units.

- Which components are core (server, config management, Kafka integration) and which ones are auxiliary or used for testing/demonstration (mockData).

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Core Service"
        Server["API Server"]:::server
        subgraph "Configuration Module"
            ConfigFile["Config File"]:::config
            ConfigLoader["Internal Config Loader"]:::config
        end
        Kafka["Kafka Messaging Module"]:::kafka
    end

    subgraph "Processing"
        ImageProcessing["Image Processing Unit"]:::processing
    end

    subgraph "External Services"
        Compose["Docker Compose"]:::external
        Doc["High Level Design Doc"]:::external
    end

    Server -->|"loads"| ConfigFile
    Server -->|"loads"| ConfigLoader
    Server -->|"publishes/consumes"| Kafka
    Server -->|"triggers"| ImageProcessing
    Kafka -->|"routesMessageTo"| ImageProcessing
    Compose -.->|"providesInfrastructure"| Server
    Compose -.->|"orchestrates"| Kafka
    Doc -.->|"designInfo"| Server

    click Server "https://github.com/triminh12042002/mgd-main-be/blob/master/cmd/server/main.go"
    click ConfigFile "https://github.com/triminh12042002/mgd-main-be/blob/master/config/config.yml"
    click ConfigLoader "https://github.com/triminh12042002/mgd-main-be/tree/master/internal/configs"
    click Kafka "https://github.com/triminh12042002/mgd-main-be/tree/master/pkg/kafka"
    click ImageProcessing "https://github.com/triminh12042002/mgd-main-be/tree/master/mockData/MGD"
    click Compose "https://github.com/triminh12042002/mgd-main-be/blob/master/docker-compose.yml"
    click Doc "https://github.com/triminh12042002/mgd-main-be/blob/master/doc/MGDAppHighLevelDesign.pdf"

    classDef server fill:#f9f,stroke:#333,stroke-width:2px;
    classDef config fill:#bbf,stroke:#333,stroke-width:2px;
    classDef kafka fill:#ff9,stroke:#333,stroke-width:2px;
    classDef processing fill:#9f9,stroke:#333,stroke-width:2px;
    classDef external fill:#f99,stroke:#333,stroke-width:2px;
```
