# ziqian-huang0607/devchart architecture

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

- Interactive diagram: https://gitdiagram.com/ziqian-huang0607/devchart
- Repository: https://github.com/ziqian-huang0607/devchart

## Overview

##### Main Components
- Table Module – This component is responsible for rendering data as formatted tables. It includes logic for setting headers, data, and configurable options such as border style, text alignment, and cell padding.
- Graph Module – This splits into two sub-components:
◦ Bar Graph – Handles vertical bar graph generation with customizations (width, bar character).
◦ Line Graph – Handles line graph generation with customizations (width, height, point character).
- Options – Both the Table component and the Graph components have dedicated “Options” structures (for table options, bar graph options, and line graph options) which configure rendering details.

##### Relationships and Data Flow
- The client code (a command-line application or any Go program) imports DevChart. It creates instances via constructors (e.g. NewTable, NewBarGraph, and NewLineGraph).
- The client sets data, options, and then calls a render method (Print or Render) to output the chart/table to the terminal.
- Data flows from the input provided by the user (in the client’s code) through the configuration components (options) and into the rendering engine of each module.

##### Architectural Patterns and Design Principles
- Modularity: The project is separated into two main packages (“table” and “graph”) which encapsulate distinct functionalities.
- Configurability: Both charting components use “Options” structs to allow customizable behavior.
- Separation of Concerns: Each module is responsible for only one output type (table or graph), making the library flexible and easy to extend.
- Simplicity: Given it is targeted for terminal output, the internal architecture remains straightforward with one main flow: configuration ➜ data setting ➜ rendering.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client Code"]:::client

    subgraph "Table Module"
        TableObj["Table Object"]:::module
        TableOpt["Table Options"]:::options
        TableOpt -->|"configures"| TableObj
    end

    subgraph "Graph Module"
        GraphOpt["Graph Options"]:::options
        BG["Bar Graph Module"]:::module
        LG["Line Graph Module"]:::module
        GraphOpt -->|"configures"| BG
        GraphOpt -->|"configures"| LG
    end

    Term["Terminal Output"]:::terminal

    A -->|"NewTable"| TableObj
    A -->|"NewBarGraph"| BG
    A -->|"NewLineGraph"| LG

    TableObj -->|"Render"| Term
    BG -->|"Render"| Term
    LG -->|"Render"| Term

    click TableObj "https://github.com/ziqian-huang0607/devchart/blob/main/table/table.go"
    click TableOpt "https://github.com/ziqian-huang0607/devchart/blob/main/table/options.go"
    click BG "https://github.com/ziqian-huang0607/devchart/blob/main/graph/bar.go"
    click LG "https://github.com/ziqian-huang0607/devchart/blob/main/graph/line.go"
    click GraphOpt "https://github.com/ziqian-huang0607/devchart/blob/main/graph/options.go"

    classDef client fill:#aaf,stroke:#333,stroke-width:2px;
    classDef module fill:#bbf,stroke:#333,stroke-width:2px;
    classDef options fill:#cfc,stroke:#333,stroke-width:2px;
    classDef terminal fill:#fdd,stroke:#333,stroke-width:2px;
```
