# fuse441/generatorswag architecture

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

- Interactive diagram: https://gitdiagram.com/fuse441/generatorswag
- Repository: https://github.com/fuse441/generatorswag

## Overview

##### Project type and purpose
- This is an open-source CLI/HTTP tool (“Generator Swagger”) built on Node.js (runs under bun) that reads XLSX files and produces Swagger-compatible YAML. It reduces manual work in creating API docs by converting a spreadsheet spec into documentation.

##### File structure
- Top-level files
- app.js – entrypoint, wires up web server (Express/Koa) and routing.
- DockerFile & compose.yaml – containerization and orchestration.
- public/ – static assets (logo, maybe a minimal upload UI).
- src/
- routes – defines HTTP endpoints (e.g., POST /generate).
- controllers – request handlers (generateController).
- services – business logic for parsing XLSX and orchestrating builders.
- builders – modules that translate parsed sheets into Swagger Schema and OpenAPI definitions.
- Helper, utils, libs – cross-cutting utilities (formatting, error handling, constants, logging, general functions).
- middlewares – error handling and request logging.
- configs – environment/configuration management.

##### README insights
- The README confirms it transforms XLSX → Swagger YAML, supports XML, nested arrays/objects, and is versioned (1.1.0).
- Installation uses bun and nodemon; run app.js to start a watchable server.

- Rounded rectangles for layers (Router, Controller, Service).
- Rectangles for modules (Builders, Utils, Configs).
- XLSX → HTTP POST → Router → … → YAML → HTTP Response or File Export.
- Blue: Web/API layer (app.js, routes, controllers).
- Green: Business logic (services, builders).
- Yellow: Utilities & helpers.
- Gray: Infrastructure (Docker, configs, middlewares).

##### Detail
- Which modules depend on which (e.g., services reference builders and utils).
- Docker container boundary and the host environment (NODE_ENV, .env).

## Diagram (Mermaid)

```mermaid
flowchart TB
    Client["Client (CLI/Web UI)"]:::external
    subgraph "Docker Container"
        direction TB
        App["app.js (HTTP Server)"]:::api
        click App "https://github.com/fuse441/generatorswag/blob/main/app.js"
        MWLogger["logger.js (Middleware)"]:::infra
        click MWLogger "https://github.com/fuse441/generatorswag/blob/main/src/middlewares/logger.js"
        MWError["error.handler.js (Middleware)"]:::infra
        click MWError "https://github.com/fuse441/generatorswag/blob/main/src/middlewares/error.handler.js"
        Config["configs/index.js"]:::infra
        click Config "https://github.com/fuse441/generatorswag/blob/main/src/configs/index.js"
        subgraph "API Layer"
            direction TB
            Router["generateBE.js (Router)"]:::api
            click Router "https://github.com/fuse441/generatorswag/blob/main/src/routes/generateBE.js"
            Controller["generateController.js (Controller)"]:::api
            click Controller "https://github.com/fuse441/generatorswag/blob/main/src/controllers/generateController.js"
        end
        subgraph "Business Layer"
            direction TB
            Service["generateService.js (Service)"]:::business
            click Service "https://github.com/fuse441/generatorswag/blob/main/src/services/generateService.js"
            subgraph "Builders"
                direction TB
                SchemaB["SchemaBuilder.js"]:::business
                click SchemaB "https://github.com/fuse441/generatorswag/blob/main/src/builders/SchemaBuilder.js"
                OpenAPIB["openAPIBuilder.js"]:::business
                click OpenAPIB "https://github.com/fuse441/generatorswag/blob/main/src/builders/openAPIBuilder.js"
            end
        end
        subgraph "Utilities"
            direction TB
            GenUtil["general.js"]:::util
            click GenUtil "https://github.com/fuse441/generatorswag/blob/main/src/utils/general.js"
            MainFn["mainFunction.js"]:::util
            click MainFn "https://github.com/fuse441/generatorswag/blob/main/src/utils/mainFunction.js"
            FuncHelper["FuncHelper.js"]:::util
            click FuncHelper "https://github.com/fuse441/generatorswag/blob/main/src/Helper/FuncHelper.js"
            Const["constant.method.js"]:::util
            click Const "https://github.com/fuse441/generatorswag/blob/main/src/libs/constant/constant.method.js"
            Formatter["http.response-formatter.js"]:::util
            click Formatter "https://github.com/fuse441/generatorswag/blob/main/src/libs/api/http.response-formatter.js"
            ExValidation["error.validation.js"]:::util
            click ExValidation "https://github.com/fuse441/generatorswag/blob/main/src/libs/exception/error.validation.js"
        end
        App --> MWLogger --> Router
        Router --> Controller
        Controller --> Service
        Service --> MainFn
        MainFn --> SchemaB
        MainFn --> OpenAPIB
        SchemaB --> FuncHelper
        OpenAPIB --> FuncHelper
        Service --> Formatter
        Service --> Const
        Service --> ExValidation
        Controller --> Formatter
        App --> Config
    end
    publicUI["public/ (Static Assets)"]:::infra
    click publicUI "https://github.com/fuse441/generatorswag/tree/main/public/"
    Client -->|"POST /generate"| App
    App --> publicUI
    Service -->|"Produces YAML"| Output["Swagger YAML File"]:::storage

    classDef api fill:#cce5ff,stroke:#004085,color:#004085;
    classDef business fill:#d4edda,stroke:#155724,color:#155724;
    classDef util fill:#fff3cd,stroke:#856404,color:#856404;
    classDef infra fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24;
    classDef storage fill:#d1ecf1,stroke:#0c5460,color:#0c5460;
```
