# doriandarren/node-generator architecture

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

- Interactive diagram: https://gitdiagram.com/doriandarren/node-generator
- Repository: https://github.com/doriandarren/node-generator

## Overview

- Scaffolding new projects or modules in Node.js, PHP, React
- AI integrations (ChatGPT API, Ollama local model)
- Miscellaneous utilities (ADB control, CLI helpers, file helpers)

##### Main Components
- 1.1 CLI Layer (Entry point)
- app.js
- 1.2 Controller Layer (Command handlers under src/controllers)
- addkit
- ai (chatGPT & Ollama sub-controllers)
- database (to_generate, to_list)
- export_diagrams
- import_diagrams
- node (to_create_module + to_create_project)
- php (to_create_module + to_create_project)
- react (to_create_module_crud, to_create_module_single, to_create_project)
- 1.3 Shared Utilities
- src/helpers (file, string, date, inquirer wrappers)
- src/models/Prompt.js
- src/controllers/database/helpers (DB connection factory)
- 1.4 Infrastructure Services
- Database: MySQL (via sequelize + mysql2)
- AI Services:
– ChatGPT API (external HTTP call)
– Ollama local model service
- ADB (adbkit)
- 1.5 File System
- public/ (static assets, Postman collection)
- src/scripts (dbTestConnection.js, dbAlter.js)

##### Relationships and Data Flows
- CLI Layer → Controller Layer
- Controller Layer → Shared Utilities
- Calls helpers for file I/O, string/date formatting, prompting.
- Controller Layer → Infrastructure Services
- Database controllers → Sequelize → MySQL
- AI controllers → HTTP client → ChatGPT API or local Ollama
- export_diagrams → xmlbuilder2 → produces .drawio XML
- node/php/react controllers → FS write → generated project/module files
- addkit controllers → ADB via adbkit
- Scripts → Database
- DB test / alteration scripts use the same connection helper.
- public/ static → optional web UI (if enabled via Handlebars)

##### Architectural Patterns
- Modular Monolith: each language/framework generator lives in its own subfolder under src/controllers.
- Command Pattern: each controller exports a “main” function invoked by the CLI dispatcher.
- Layered Architecture:
- Presentation (CLI)
- Application (Controllers)
- Domain/Utilities (Helpers, Models)
- Infrastructure (DB, AI, XML, ADB)

##### Detail Level
- That scripts under src/scripts reuse the same database connection path.
- Optionally, illustrate CLI dependencies (dotenv → loads .env).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        direction TB
        App["app.js"]:::cli
    end

    %% Controller Layer
    subgraph "Controller Layer"
        direction TB

        subgraph "Addkit"
            direction TB
            Addkit["controlPhoneFarm"]:::controllers
            click Addkit "https://github.com/doriandarren/node-generator/blob/main/src/controllers/addkit/controlPhoneFarm.js"
        end

        subgraph "AI Controllers"
            direction TB
            AIMain["aiMain"]:::controllers
            click AIMain "https://github.com/doriandarren/node-generator/blob/main/src/controllers/ai/aiMain.js"
            ChatGPT["chatGPTMain"]:::controllers
            click ChatGPT "https://github.com/doriandarren/node-generator/blob/main/src/controllers/ai/chatgpt/chatGPTMain.js"
            Ollama["startOllamaAI"]:::controllers
            click Ollama "https://github.com/doriandarren/node-generator/blob/main/src/controllers/ai/ollama/startOllamaAI.js"
        end

        subgraph "Database Controllers"
            direction TB
            DBMain["databaseMain"]:::controllers
            click DBMain "https://github.com/doriandarren/node-generator/blob/main/src/controllers/database/databaseMain.js"
            GenStart["startGenerate"]:::controllers
            click GenStart "https://github.com/doriandarren/node-generator/blob/main/src/controllers/database/to_generate/startGenerate.js"
            GenDiagrams["startGenerateDiagrams"]:::controllers
            click GenDiagrams "https://github.com/doriandarren/node-generator/blob/main/src/controllers/database/to_generate/startGenerateDiagrams.js"
            ListTables["listTables"]:::controllers
            click ListTables "https://github.com/doriandarren/node-generator/blob/main/src/controllers/database/to_list/listTables.js"
        end

        subgraph "Export Diagrams"
            direction TB
            ExportMain["exportDiagramsMain"]:::controllers
            click ExportMain "https://github.com/doriandarren/node-generator/blob/main/src/controllers/export_diagrams/exportDigramsMain.js"
            CreateDiagrams["createDiagrams"]:::controllers
            click CreateDiagrams "https://github.com/doriandarren/node-generator/blob/main/src/controllers/export_diagrams/createDiagrams.js"
            DiagramStruct["diagramStructure"]:::controllers
            click DiagramStruct "https://github.com/doriandarren/node-generator/blob/main/src/controllers/export_diagrams/diagramStructure.js"
            GenExport["generateExportDiagrams"]:::controllers
            click GenExport "https://github.com/doriandarren/node-generator/blob/main/src/controllers/export_diagrams/generateExportDiagrams.js"
        end

        subgraph "Import Diagrams"
            direction TB
            ImportMain["importDiagramsMain"]:::controllers
            click ImportMain "https://github.com/doriandarren/node-generator/blob/main/src/controllers/import_diagrams/importDiagramsMain.js"
            ParseDrawio["parseDrawioFile"]:::controllers
            click ParseDrawio "https://github.com/doriandarren/node-generator/blob/main/src/controllers/import_diagrams/parseDrawioFile.js"
        end

        subgraph "Node Generators"
            direction TB
            NodeMain["nodeMain"]:::controllers
            click NodeMain "https://github.com/doriandarren/node-generator/blob/main/src/controllers/node/nodeMain.js"
            NodeModule["to_create_module"]:::controllers
            click NodeModule "https://github.com/doriandarren/node-generator/tree/main/src/controllers/node/to_create_module/"
            NodeProject["to_create_project"]:::controllers
            click NodeProject "https://github.com/doriandarren/node-generator/tree/main/src/controllers/node/to_create_project/"
        end

        subgraph "PHP Generators"
            direction TB
            PHPMain["phpMain"]:::controllers
            click PHPMain "https://github.com/doriandarren/node-generator/blob/main/src/controllers/php/phpMain.js"
            PHPModule["to_create_module"]:::controllers
            click PHPModule "https://github.com/doriandarren/node-generator/tree/main/src/controllers/php/to_create_module/"
            PHPProject["to_create_project"]:::controllers
            click PHPProject "https://github.com/doriandarren/node-generator/tree/main/src/controllers/php/to_create_project/"
        end

        subgraph "React Generators"
            direction TB
            ReactMain["reactMain"]:::controllers
            click ReactMain "https://github.com/doriandarren/node-generator/blob/main/src/controllers/react/reactMain.js"
            HelperForm["helperFormGenerator"]:::controllers
            click HelperForm "https://github.com/doriandarren/node-generator/blob/main/src/controllers/react/helpers/helperFormGenerator.js"
            HelperRel["helperReactRelations"]:::controllers
            click HelperRel "https://github.com/doriandarren/node-generator/blob/main/src/controllers/react/helpers/helperReactRelations.js"
            ReactCrud["to_create_module_crud"]:::controllers
            click ReactCrud "https://github.com/doriandarren/node-generator/tree/main/src/controllers/react/to_create_module_crud/"
            ReactSingle["to_create_module_single"]:::controllers
            click ReactSingle "https://github.com/doriandarren/node-generator/tree/main/src/controllers/react/to_create_module_single/"
            ReactProject["to_create_project"]:::controllers
            click ReactProject "https://github.com/doriandarren/node-generator/tree/main/src/controllers/react/to_create_project/"
        end
    end

    %% Shared Utilities
    subgraph "Shared Utilities"
        direction TB
        FileHelper["helperFile.js"]:::utils
        click FileHelper "https://github.com/doriandarren/node-generator/blob/main/src/helpers/helperFile.js"
        StringHelper["helperString.js"]:::utils
        click StringHelper "https://github.com/doriandarren/node-generator/blob/main/src/helpers/helperString.js"
        DateHelper["helperDate.js"]:::utils
        click DateHelper "https://github.com/doriandarren/node-generator/blob/main/src/helpers/helperDate.js"
        InquirerWrap["inquirer.js"]:::utils
        click InquirerWrap "https://github.com/doriandarren/node-generator/blob/main/src/helpers/inquirer.js"
        PromptModel["Prompt.js"]:::utils
        click PromptModel "https://github.com/doriandarren/node-generator/blob/main/src/models/Prompt.js"
        DBConn["createConnection.js"]:::utils
        click DBConn "https://github.com/doriandarren/node-generator/blob/main/src/controllers/database/helpers/createConnection.js"
    end

    %% Infrastructure Services
    subgraph "Infrastructure Services"
        direction TB
        MySQL["MySQL (Sequelize)"]:::infra
        ChatGPTAPI["ChatGPT API"]:::infra
        OllamaService["Ollama Service"]:::infra
        XMLBuilder["xmlbuilder2"]:::infra
        ADB["ADB (adbkit)"]:::infra
    end

    %% Scripts
    subgraph "Scripts"
        direction TB
        DBTest["dbTestConnection.js"]:::scripts
        click DBTest "https://github.com/doriandarren/node-generator/blob/main/src/scripts/dbTestConnection.js"
        DBAlter["dbAlter.js"]:::scripts
        click DBAlter "https://github.com/doriandarren/node-generator/blob/main/src/scripts/dbAlter.js"
    end

    %% File System
    subgraph "File System"
        direction TB
        Public["public/"]:::fs
        Generated["Generated Output"]:::fs
    end

    %% Relations
    App -->|"dispatch"| Addkit
    App -->|"dispatch"| AIMain
    App -->|"dispatch"| DBMain
    App -->|"dispatch"| ExportMain
    App -->|"dispatch"| ImportMain
    App -->|"dispatch"| NodeMain
    App -->|"dispatch"| PHPMain
    App -->|"dispatch"| ReactMain

    Addkit -->|"calls"| ADB
    AIMain -->|"calls"| ChatGPTAPI
    AIMain -->|"calls"| OllamaService
    ChatGPT -->|"calls"| ChatGPTAPI
    Ollama -->|"calls"| OllamaService

    DBMain -->|"uses"| DBConn
    GenStart -->|"uses"| DBConn
    GenStart -->|"queries"| MySQL
    GenDiagrams -->|"uses"| DBConn
    GenDiagrams -->|"queries"| MySQL
    ListTables -->|"queries"| MySQL

    ExportMain -->|"calls"| XMLBuilder
    CreateDiagrams -->|"generates"| XMLBuilder

    ImportMain -->|"parses"| XMLBuilder

    NodeMain -->|"writes"| Generated
    PHPMain -->|"writes"| Generated
    ReactMain -->|"writes"| Generated

    FileHelper -->|"utility"| NodeMain
    StringHelper -->|"utility"| NodeMain
    DateHelper -->|"utility"| NodeMain
    InquirerWrap -->|"utility"| App
    PromptModel -->|"models"| AIMain

    DBTest -->|"uses"| DBConn
    DBTest -->|"connects"| MySQL
    DBAlter -->|"uses"| DBConn
    DBAlter -->|"alters"| MySQL

    Public -->|"serves"| App

    %% Styles
    classDef cli fill:#D0E6FF,stroke:#0366D6,color:#0366D6;
    classDef controllers fill:#E6F0FF,stroke:#0366D6,color:#0366D6;
    classDef utils fill:#FFF4CC,stroke:#D4A017,color:#D4A017;
    classDef infra fill:#E6FFEA,stroke:#22863A,color:#22863A;
    classDef scripts fill:#F0F0F0,stroke:#6A737D,color:#6A737D;
    classDef fs fill:#F6F8FA,stroke:#959DA5,color:#959DA5;
```
