# gayathri1462/csvdatavisualizationtool architecture

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

- Interactive diagram: https://gitdiagram.com/gayathri1462/csvdatavisualizationtool
- Repository: https://github.com/gayathri1462/csvdatavisualizationtool

## Overview

##### Project Type and Purpose
- This is a single-page React application for visualizing and editing CSV data.
- Key purpose: upload CSV, view/edit via spreadsheet UI, generate/download charts (bar, line, pie, stacked bar), and export CSV/chart images.

##### File Structure Analysis
- Top-level:
- public/: static HTML entry point (index.html).
- src/: all React-specific code.
- README, package.json: project metadata & dependencies.
- src/components/: reusable UI pieces (charts, buttons, dropdowns, search).
- src/screens/: page views or “routes” (CsvUpload, Dashboard, SpreadSheet, Steps).
- src/redux/: state management (slices, rootReducer, store).
- src/utils/: helper functions (CSV conversion, data formatting, chart data extraction).
- Styling: .scss or .module.scss per component/screen, plus global styles.css.

a. Frontend UI Layer
- Screens: CsvUpload, SpreadSheet, Dashboard, Steps
- Components: BarChart, LineChart, DonutChart, StackedBarChart, DownloadBtn, DropDown, Search
b. State Management Layer
- Redux Toolkit slices: csvDataSlice, stepsSlice
- Middleware: Redux Saga (for any async side-effects), redux-persist (for saving state to local storage)
c. Data Processing Layer
- Utils: convertToCSV, formatCSVToDataArray, getChartDataByLabel, etc.
d. Third-Party Libraries
- React Spreadsheet (grid editing)
- Chart.js (rendering charts)
- Ant Design (UI primitives)
e. External Systems (none in this project; axios is available but not used—if it were, show API calls)

##### Relationships and Interactions
- User uploads CSV → CsvUpload screen invokes utils to parse CSV → dispatch(csvDataSlice.actions.setData).
- Redux persisted store holds raw CSV & processing steps.
- SpreadSheet screen reads csvData from store → displays via React Spreadsheet → dispatch updates on edit.
- Dashboard reads processed data → utils produce chart-ready datasets → Chart.js components render visuals.
- DownloadBtn uses utils (convertToCSV, downloadCSV) or Chart.js export features for saving files.

##### Architectural Patterns and Principles
- Separation of Concerns: UI vs state vs data processing.
- Unidirectional Data Flow: React → Redux → components → utils → store.
- Modular Components: each chart type and UI element in its own folder.
- Single Source of Truth: Redux store for CSV and step state; persisted across reloads.

##### Detailed Coverage
- Every slice, screen, and core util is represented.
- Data flow when uploading, editing, rendering, and downloading.
- Middleware (Saga) even if minimal, to indicate async handling capability.
- Chart generation path: raw CSV → formatted data → Chart.js component → canvas/download.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Container
    subgraph "Browser (SPA)"
        direction TB

        %% Presentation/UI Layer
        subgraph "Presentation Layer"
            direction TB
            %% Screens
            subgraph "Screens" 
                direction TB
                CsvUpload["CsvUpload Screen"]:::ui
                SpreadSheet["SpreadSheet Screen"]:::ui
                Dashboard["Dashboard Screen"]:::ui
                Steps["Steps Screen"]:::ui
            end

            %% Components
            subgraph "Components"
                direction TB
                BarChart["BarChart Component"]:::ui
                LineChart["LineChart Component"]:::ui
                DonutChart["DonutChart Component"]:::ui
                StackedBarChart["StackedBarChart Component"]:::ui
                DownloadBtn["DownloadBtn Component"]:::ui
                DropDown["DropDown Component"]:::ui
                Search["Search Component"]:::ui
            end
        end

        %% State Management Layer
        subgraph "State Management Layer"
            direction TB
            RootStore["Store Configuration"]:::state
            RootReducer["Root Reducer"]:::state
            CsvDataSlice["csvDataSlice"]:::state
            StepsSlice["stepsSlice"]:::state
            Persist["redux-persist (LocalStorage)"]:::state
            Saga["Redux Saga (Middleware)"]:::state
        end

        %% Data Processing/Utility Layer
        subgraph "Data Processing Layer"
            direction TB
            UtilsIndex["Utils Index"]:::util
            ConvertCSV["convertToCSV"]:::util
            DownloadCSV["downloadCSV"]:::util
            FormatCSV["formatCSVToDataArray"]:::util
            ChartData["getChartDataByLabel"]:::util
            StackData["getProcessedStackBarData"]:::util
            UniqueHeaders["getUniqueHeaders"]:::util
            DropOptions["dropDownOptions"]:::util
        end

        %% Third-Party Libraries
        subgraph "Third-Party Libraries"
            direction TB
            SpreadsheetLib["React Spreadsheet"]:::lib
            ChartJSLib["Chart.js"]:::lib
            Antd["Ant Design"]:::lib
        end

        %% Entry Points
        HTML["public/index.html"]:::html
        App["Main App Component"]:::ui
    end

    %% Connections: UI to State
    CsvUpload -->|"dispatch setData"| CsvDataSlice
    SpreadSheet -->|"reads csvData"| CsvDataSlice
    SpreadSheet -->|"dispatch update"| CsvDataSlice
    Dashboard -->|"reads processed data"| CsvDataSlice
    Steps -->|"dispatch step actions"| StepsSlice
    App --> RootStore

    %% Store internals
    RootStore --> RootReducer
    RootReducer --> CsvDataSlice
    RootReducer --> StepsSlice
    RootStore --> Persist
    RootStore --> Saga

    %% Utils usage
    CsvUpload -->|"parse CSV"| FormatCSV
    CsvUpload -->|"format CSV"| ConvertCSV
    Dashboard -->|"extract chart data"| ChartData
    Dashboard -->|"extract stack data"| StackData
    DownloadBtn -->|"export CSV"| DownloadCSV
    DownloadBtn -->|"convert to CSV"| ConvertCSV

    %% Components rendering
    Dashboard --> BarChart
    Dashboard --> LineChart
    Dashboard --> DonutChart
    Dashboard --> StackedBarChart
    CsvUpload --> DropDown
    SpreadSheet --> Search

    %% Third-party usage
    SpreadSheet --> SpreadsheetLib
    Dashboard --> ChartJSLib
    CsvUpload --> Antd
    DropDown --> Antd
    Search --> Antd

    %% Entry point flows
    HTML --> App
    App --> CsvUpload
    App --> SpreadSheet
    App --> Dashboard
    App --> Steps

    %% Click Events
    click CsvUpload "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/screens/csvUpload/CsvUpload.jsx"
    click SpreadSheet "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/screens/spreadSheet/SpreadSheet.jsx"
    click Dashboard "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/screens/dashboard/Dashboard.jsx"
    click Steps "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/screens/steps/Steps.jsx"
    click BarChart "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/components/barChart/BarChart.jsx"
    click LineChart "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/components/lineChart/LineChart.jsx"
    click DonutChart "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/components/donutChart/DonutChart.jsx"
    click StackedBarChart "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/components/stackedBarChart/StackedBarChart.jsx"
    click DownloadBtn "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/components/downloadBtn/DownloadBtn.jsx"
    click DropDown "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/components/dropdownBtn/DropDown.jsx"
    click Search "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/components/search/Search.jsx"
    click CsvDataSlice "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/redux/csvData/csvDataSlice.jsx"
    click StepsSlice "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/redux/steps/stepsSlice.jsx"
    click RootReducer "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/redux/rootReducer.jsx"
    click RootStore "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/redux/rootStore.jsx"
    click ConvertCSV "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/utils/convertToCSV.jsx"
    click DownloadCSV "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/utils/downloadCSV.jsx"
    click FormatCSV "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/utils/formatCSVToDataArray.jsx"
    click ChartData "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/utils/getChartDataByLabel.jsx"
    click StackData "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/utils/getProcessedStackBarData.jsx"
    click UniqueHeaders "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/utils/getUniqueHeaders.jsx"
    click DropOptions "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/utils/dropDownOptions.jsx"
    click UtilsIndex "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/utils/index.jsx"
    click App "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/src/App.jsx"
    click HTML "https://github.com/gayathri1462/csvdatavisualizationtool/blob/main/public/index.html"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#1E70BF,stroke-width:1px
    classDef state fill:#DFFFE0,stroke:#2E8B57,stroke-width:1px
    classDef util fill:#FFE8B0,stroke:#CC8400,stroke-width:1px
    classDef lib fill:#E0E0E0,stroke:#888888,stroke-width:1px
    classDef html fill:#F0F0F0,stroke:#AAAAAA,stroke-width:1px
```
