# winminsoe/cohesion architecture

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

- Interactive diagram: https://gitdiagram.com/winminsoe/cohesion
- Repository: https://github.com/winminsoe/cohesion

## Overview

##### Project Type and Purpose
- This is a small, open-source command-line tool (written in Go) that inspects a relational database’s schema and emits a JSON “table dependency” report.
- It connects to a MySQL (or compatible) database via a DSN, queries foreign-key metadata, then streams JSON objects to stdout (often piped into jq for pretty-printing).

##### File-Structure Analysis
- README.md at top level describes purpose and usage.
- main.go is the CLI entry point: reads DB_DSN, invokes the query logic, and writes JSON to stdout.
- query/query.go houses the data-access and dependency-resolution code (the “core” package).

##### Key Insights from README
- The tool’s only external dependency at runtime is the database.
- There is no web frontend or multi-service split—everything lives in one binary.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    User["User/Terminal"]:::external

    %% CLI Application Modules
    subgraph "CLI Application"
        ConfigLoader["Config Loader\n(main.go)"]:::internal
        DependencyEngine["Dependency Engine\n(query/query.go)"]:::internal
        JSONEncoder["JSON Encoder\n(main.go)"]:::internal
    end

    %% External Dependencies
    DB[(MySQL Database)]:::external
    JQ["jq (JSON Consumer)"]:::external

    %% Data Flow
    Stdout[/stdout/]:::flow

    %% Connections
    User -->|"invoke CLI"| ConfigLoader
    ConfigLoader -->|"DB_DSN"| DependencyEngine
    DependencyEngine -->|"SELECT query"| DB
    DB -->|"rows result"| DependencyEngine
    DependencyEngine -->|"model data"| JSONEncoder
    JSONEncoder -->|"JSON output"| Stdout
    Stdout -->|"pipe"| JQ

    %% Click Events
    click ConfigLoader "https://github.com/winminsoe/cohesion/blob/master/main.go"
    click JSONEncoder "https://github.com/winminsoe/cohesion/blob/master/main.go"
    click DependencyEngine "https://github.com/winminsoe/cohesion/blob/master/query/query.go"

    %% Styles
    classDef internal fill:#c8e6c9 stroke:#2e7d32
    classDef external fill:#bbdefb stroke:#0d47a1
    classDef flow fill:#ffe0b2 stroke:#e65100
```
