# athishsreeram/gogenetic architecture

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

- Interactive diagram: https://gitdiagram.com/athishsreeram/gogenetic
- Repository: https://github.com/athishsreeram/gogenetic

## Overview

##### Project type and purpose
- This is a code-generation CLI tool (written in Go) for scaffolding microservice projects in Go or Java. It reads business-entity TOML files and generates full microservice codebases in various architectural styles (CRUD, CQRS/ES, file-output, etc.).

##### File structure
Top-level components:
- arch/           – architecture definitions (Go/Java)
- config/         – configuration loader and TOML schemas
- data/           – internal data models (e.g., Clidata)
- gogenetic-cli/  – top-level CLI entrypoint and flag parsing
- gogfile/        – template engine, file writer, per-language/per-arch templates
- gogexec/        – subprocess execution support (e.g., for Liquibase scripts)
- gog.go / gog.sh – main runner scripts
- toml/           – sample business spec files
- Makefile / scripts / SQL – build and auxiliary scripts

##### README for additional insights
- Workflow: load TOML → load Go templates → merge data → generate scaffold
- Supported languages: Go, Java
- Supported architectures: CRUD, CRUD-object, ES (sync/async, with/without CQRS), file

##### Main components and their interactions
a. User / CLI Layer
- gogenetic-cli: parses command‐line flags (outDir, tomlFiles, lang, archType, templateFile)
- gog.go / gog.sh wrappers: shell entrypoints
b. Configuration Layer
- config: reads gogconfig.toml and individual business TOML specs
- data: maps TOML into in-memory business models
c. Architecture Resolver
- arch: based on lang & archType, selects the correct arch implementation (goarch or javaarch)
d. Template Engine & File Generator
- gogfile:
– Loads templates (under gogfile/template/<lang>/<archType>)
– Applies Go’s text/template on business data
– Writes files to outDir
e. Execution Layer (optional)
- gogexec: can call out to external tools (e.g., Liquibase via liquibase.sh)
f. Supporting assets
- SQL schema (GOGENETIC_SCHEMA.sql)
- Sample TOML specs (toml/)
- Shell scripts, Makefile

##### Architectural patterns and design principles
- Modular layering: CLI → Config → Arch Resolver → Template Engine → Output
- Language‐agnostic core interfaces in arch and config packages
- Separation of concerns: business model parsing vs. code generation vs. external execution

##### Final checklist
- Clear, unique labels for every component
- Notes for extension points (e.g., “add new lang here”)
- Boundary markers for OS‐level (shell scripts) vs. Go runtime

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI & Entrypoints Layer
    subgraph "CLI & Entrypoints"
        direction TB
        CLI["gogenetic-cli"]:::cli
        GogGo["gog.go"]:::cli
        GogSh["gog.sh"]:::cli
    end

    %% Configuration & Parsing Layer
    subgraph "Configuration & Parsing"
        direction TB
        ConfigLoader["Configuration Loader"]:::config
        TOMLParser["TOML Parser / Data Model"]:::config
    end

    %% Core Engine & Resolver Layer
    subgraph "Core Engine & Resolver"
        direction TB
        ArchResolver["Architecture Resolver"]:::core
        TemplateEngine["Template Engine & File Generator"]:::core
    end

    %% Templates & Assets Layer
    subgraph "Templates & Assets"
        direction TB
        TemplateRepo["Template Repository"]:::asset
        SampleSpecs["Sample Business Specs (toml/)"]:::asset
        SQLSchema["GOGENETIC_SCHEMA.sql"]:::asset
    end

    %% Output & Execution Layer
    subgraph "Output & Execution"
        direction TB
        FileOutput["File System Output"]:::output
        subgraph "Optional Execution" 
            direction TB
            Executor["External Executor"]:::exec
            LiquibaseScript["liquibase.sh"]:::exec
        end
    end

    %% Connections
    CLI -->|"invokes"| GogGo
    CLI -->|"invokes"| GogSh
    GogGo -->|"reads"| ConfigLoader
    CLI -->|"flags & files"| ConfigLoader
    ConfigLoader -->|"parses"| TOMLParser
    TOMLParser -->|"models"| ArchResolver
    ConfigLoader -->|"lang & archType"| ArchResolver
    ArchResolver -->|"selects templates"| TemplateEngine
    TemplateRepo -->|"provides templates"| TemplateEngine
    TemplateEngine -->|"generates code"| FileOutput
    FileOutput -->|"writes files"| FileOutput
    FileOutput -->|"optional migrations"| Executor
    Executor -->|"executes"| LiquibaseScript

    %% Click Events
    click CLI "https://github.com/athishsreeram/gogenetic/blob/master/gogenetic-cli/gogenetic-cli.go"
    click GogGo "https://github.com/athishsreeram/gogenetic/blob/master/gog.go"
    click GogSh "https://github.com/athishsreeram/gogenetic/blob/master/gog.sh"
    click ConfigLoader "https://github.com/athishsreeram/gogenetic/blob/master/config/configuration.go"
    click TOMLParser "https://github.com/athishsreeram/gogenetic/blob/master/data/clidata.go"
    click ArchResolver "https://github.com/athishsreeram/gogenetic/blob/master/arch/goarch.go"
    click ArchResolver "https://github.com/athishsreeram/gogenetic/blob/master/arch/javaarch.go"
    click TemplateEngine "https://github.com/athishsreeram/gogenetic/blob/master/gogfile/gogenetic-file.go"
    click TemplateEngine "https://github.com/athishsreeram/gogenetic/blob/master/gogfile/golang-util.go"
    click TemplateEngine "https://github.com/athishsreeram/gogenetic/blob/master/gogfile/javalang-util.go"
    click TemplateEngine "https://github.com/athishsreeram/gogenetic/blob/master/gogfile/liquibaselang-util.go"
    click TemplateRepo "https://github.com/athishsreeram/gogenetic/tree/master/gogfile/template/"
    click Executor "https://github.com/athishsreeram/gogenetic/blob/master/gogexec/gogexec.go"
    click LiquibaseScript "https://github.com/athishsreeram/gogenetic/blob/master/liquibase.sh"
    click SQLSchema "https://github.com/athishsreeram/gogenetic/blob/master/GOGENETIC_SCHEMA.sql"
    click SampleSpecs "https://github.com/athishsreeram/gogenetic/tree/master/toml/"

    %% Styles
    classDef cli fill:#add8e6,stroke:#000,stroke-width:1px
    classDef config fill:#ffa500,stroke:#000,stroke-width:1px
    classDef core fill:#90ee90,stroke:#000,stroke-width:1px
    classDef asset fill:#dda0dd,stroke:#000,stroke-width:1px
    classDef output fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef exec fill:#f0f0f0,stroke-dasharray: 5 5,stroke:#000,stroke-width:1px
```
