# artonge/go-csv architecture

> Architecture diagram of the GitHub repository artonge/go-csv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/artonge/go-csv
- Repository: https://github.com/artonge/go-csv

## Overview

##### Main Components

a) Core Components:
- CSV Parser/Reader Module
- CSV Writer/Dumper Module
- Tag Processing Engine
- Type Conversion System

b) Input/Output Interfaces:
- File System I/O
- String I/O
- Reader/Writer I/O

**┌─────────────────────────────────────────────┐**
- Client Application             │
- ┘
- ↓   ↑
**┌─────────────────────────────────────────────┐**
- go-csv-tag Interface             │
- ┬──────────────┬───────────┤
- Load Module   │  Tag Parser  │   Dump    │
- Module    │
- ┴──────────────┴───────────┘
- ↓   ↑
**┌─────────────────────────────────────────────┐**
- I/O Handlers                   │
- ┬─────────────┬────────────────┤
- File I/O   │ String I/O  │  Reader/Writer │
- ┴─────────────┴────────────────┘

##### Component Details

a) Load Module:
- LoadFromPath
- LoadFromReader
- LoadFromString
- CSV parsing configuration
- Type conversion handling

b) Tag Parser:
- Struct tag processing
- Field mapping
- Type validation
- Error handling

c) Dump Module:
- DumpToFile
- DumpToWriter
- DumpToString
- CSV formatting

d) I/O Handlers:
- File system operations
- String manipulation
- Reader/Writer interfaces

##### Additional Elements
- Error handling paths
- Type conversion flows
- Supported data types (string, int, float64, etc.)

##### Important Notes
- Keep the focus on the core CSV processing functionality
- Struct tag integration
- Clear separation between loading and dumping operations
- Where error handling occurs
- Supported file formats and encoding (BOM support)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application"]
        CA[Client Code]
    end

    subgraph Interface["go-csv-tag Interface"]
        API["CSV Tag API"]:::api
    end

    subgraph Core["Core Processing Layer"]
        TP["Tag Processing Engine"]:::core
        click TP "https://github.com/artonge/go-csv/blob/master/csvtag.go"
        
        subgraph Input["Input Processing"]
            direction TB
            LP["CSV Parser/Reader"]:::input
            click LP "https://github.com/artonge/go-csv/blob/master/load.go"
        end

        subgraph Output["Output Processing"]
            direction TB
            DP["CSV Writer/Dumper"]:::output
            click DP "https://github.com/artonge/go-csv/blob/master/dump.go"
        end
    end

    subgraph IO["I/O Handlers"]
        direction TB
        FIO["File I/O"]:::io
        SIO["String I/O"]:::io
        RW["Reader/Writer"]:::io
    end

    subgraph Testing["Testing Components"]
        TS["Test Suite"]:::test
        click TS "https://github.com/artonge/go-csv/blob/master/csvtag_test.go"
        
        TD["Test Data"]:::test
        click TD "https://github.com/artonge/go-csv/tree/master/csv_files/"
    end

    subgraph Config["Project Configuration"]
        PC["Go Module Config"]:::config
        click PC "https://github.com/artonge/go-csv/blob/master/go.mod"
        
        CI["CI/CD Pipeline"]:::config
        click CI "https://github.com/artonge/go-csv/blob/master/.github/workflows/go.yml"
        
        CQ["Code Quality Analysis"]:::config
        click CQ "https://github.com/artonge/go-csv/blob/master/.github/workflows/codeql-analysis.yml"
    end

    %% Relationships
    CA --> API
    API --> TP
    TP --> LP
    TP --> DP
    LP --> FIO
    LP --> SIO
    LP --> RW
    DP --> FIO
    DP --> SIO
    DP --> RW

    %% Styles
    classDef api fill:#f9f,stroke:#333,stroke-width:2px
    classDef core fill:#bbf,stroke:#333,stroke-width:2px
    classDef input fill:#bfb,stroke:#333,stroke-width:2px
    classDef output fill:#fb8,stroke:#333,stroke-width:2px
    classDef io fill:#ddd,stroke:#333,stroke-width:2px
    classDef test fill:#ff9,stroke:#333,stroke-width:2px
    classDef config fill:#ddf,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["API Component"]:::api
        L2["Core Processing"]:::core
        L3["Input Processing"]:::input
        L4["Output Processing"]:::output
        L5["I/O Handlers"]:::io
        L6["Testing"]:::test
        L7["Configuration"]:::config
    end
```
