# liemle3893/csv2json architecture

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

- Interactive diagram: https://gitdiagram.com/liemle3893/csv2json
- Repository: https://github.com/liemle3893/csv2json

## Overview

- Input → Processing → Output
- [CSV Files] → [Config] → [Parser] → [Converter] → [JSON Output]

##### Component Details

a. Input Section:
- CSV source files
- HCL configuration file

- Config Parser: Reads HCL configuration
- Directory Handler: Manages file traversal
- CSV Parser: Reads and validates CSV content
- Type Converter: Transforms data types
- JSON Generator: Creates JSON structure

c. Output Section:
- JSON files

- Directory-based processing
- Column type conversion
- Path mapping for JSON structure
- Exclusion/Inclusion patterns
- Custom separators
- Default values
- Additional columns

- Parser package: CSV parsing logic
- Converter package: Type conversion
- JSON package: JSON generation
- Util package: File operations
- Config package: Configuration management

**[Input Section] → [Processing Section] → [Output Section]**
- ↓                    ↓                    ↓
**[CSV Files]     [Configuration Layer]    [JSON Files]**
**[Config.hcl] →  [Parser Layer]       →   [Structured]**
- [Converter Layer]         [Output]
- [JSON Generator]

##### Configuration validation flow

This design should capture both the high-level architecture and the important implementation details without becoming too cluttered. The focus should be on showing how the tool processes files through its pipeline while maintaining configurability and extensibility.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        CSV[("CSV Files")]:::input
        HCL[("HCL Config")]:::input
        click HCL "https://github.com/liemle3893/csv2json/blob/master/samples/config.hcl"
        click CSV "https://github.com/liemle3893/csv2json/blob/master/samples/user_action/test.csv"
    end

    subgraph "Command Layer"
        MAIN["Main Entry Point"]:::cmd
        ROOT["Root Command"]:::cmd
        VER["Version Command"]:::cmd
        click MAIN "https://github.com/liemle3893/csv2json/blob/master/main.go"
        click ROOT "https://github.com/liemle3893/csv2json/blob/master/cmd/root.go"
        click VER "https://github.com/liemle3893/csv2json/blob/master/cmd/version.go"
    end

    subgraph "Configuration Layer"
        CONF["Config Parser"]:::config
        VALID["Config Validator"]:::config
        DIRSET["Directory Settings"]:::config
        COLMAP["Column Mappings"]:::config
        click CONF "https://github.com/liemle3893/csv2json/blob/master/config/config.go"
    end

    subgraph "Processing Pipeline"
        CSVP["CSV Parser"]:::process
        TCONV["Type Converter"]:::process
        JGEN["JSON Generator"]:::process
        FSH["File System Handler"]:::process
        DIRH["Directory Handler"]:::process
        PATT["Pattern Matcher"]:::process
        click CSVP "https://github.com/liemle3893/csv2json/blob/master/parser/parser.go"
        click TCONV "https://github.com/liemle3893/csv2json/blob/master/converter/converter.go"
        click JGEN "https://github.com/liemle3893/csv2json/blob/master/json/json.go"
        click FSH "https://github.com/liemle3893/csv2json/blob/master/util/file.go"
        click DIRH "https://github.com/liemle3893/csv2json/blob/master/converter/directory.go"
        click PATT "https://github.com/liemle3893/csv2json/blob/master/util/matcher.go"
    end

    subgraph Output
        JSON[("JSON Files")]:::output
        VALID_JSON["JSON Validator"]:::output
        click VALID_JSON "https://github.com/liemle3893/csv2json/blob/master/testing/assert/json.go"
    end

    %% Connections
    CSV --> MAIN
    HCL --> MAIN
    MAIN --> ROOT
    MAIN --> VER
    ROOT --> CONF
    CONF --> VALID
    VALID --> DIRSET
    VALID --> COLMAP
    DIRSET --> DIRH
    COLMAP --> CSVP
    DIRH --> FSH
    FSH --> CSVP
    CSVP --> TCONV
    TCONV --> JGEN
    PATT --> FSH
    JGEN --> JSON
    JSON --> VALID_JSON

    %% Styles
    classDef input fill:#2374ab
    classDef cmd fill:#048ba8
    classDef config fill:#f18f01
    classDef process fill:#99c24d
    classDef output fill:#8c1c13

    %% Legend
    subgraph Legend
        L1[Input Components]:::input
        L2[Command Components]:::cmd
        L3[Configuration Components]:::config
        L4[Processing Components]:::process
        L5[Output Components]:::output
    end
```
