# rudra370/lazy_csv_viewer architecture

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

- Interactive diagram: https://gitdiagram.com/rudra370/lazy_csv_viewer
- Repository: https://github.com/rudra370/lazy_csv_viewer

## Overview

##### Project Type and Purpose
- This is a standalone desktop GUI application (“Lazy CSV Viewer”) built in Python using the Tkinter toolkit.
- Purpose: Efficiently load and page through large CSV files, with support for custom delimiters, adjustable page sizes, and column management.

##### High-Level Architectural Layers
- Presentation/UI Layer (Tkinter widgets)
- Application Logic Layer (pagination controller, column manager, navigation handler)
- Data Access Layer (CSV file reader/loader)
- (Optional) Packaging Layer (PyInstaller)

##### Main Components
a. UI Components
- Main Window
- Menu/Button Bar (Open CSV, Delimiter dropdown, Page Size input, Show/Hide Columns, Expand/Collapse Columns)
- Table/Grid View (display rows)
- Navigation Controls (Previous/Next Page buttons, keyboard shortcuts)
b. Controllers / Business Logic
- CSVLoader Module – opens file, reads only current page chunk
- PaginationController – tracks current page, page size, next/previous logic
- ColumnManager – maintains column visibility & width state
- NavigationHandler – maps button clicks and keyboard events to controller methods
c. Data Store
d. External/Platform Services
- Python Runtime (3.6+)
- Tkinter library
- (For distribution) PyInstaller bundler

##### Relationships and Data Flow
- User action → Tkinter Widget Event → NavigationHandler or ColumnManager → calls PaginationController → invokes CSVLoader to fetch data → returns row data → Table View updates
- Delimiter change or page-size update triggers Application Logic Layer to recalculate pages
- /Hide/Expand columns modifies Table View configuration
- Packaging step is orthogonal: takes main.py + dependencies → PyInstaller → standalone executable

##### Architectural Patterns / Principles
- Layered Architecture:
- UI layer is decoupled from file I/O.
- Single Responsibility: each module (loader, pagination, UI components) handles one concern.
- “Lazy Loading” / Pagination Pattern: only load needed rows from disk, minimizing memory usage.
- Event-Driven GUI: user events drive state changes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        MainWindow["Main Window"]:::ui
        MenuBar["Menu/Button Bar"]:::ui
        TableView["Table/Grid View"]:::ui
        NavControls["Navigation Controls"]:::ui
    end

    %% Application Logic Layer
    subgraph "Application Logic Layer"
        PaginationController["PaginationController"]:::logic
        ColumnManager["ColumnManager"]:::logic
        NavigationHandler["NavigationHandler"]:::logic
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        CSVLoader["CSVLoader"]:::data
        DataStore[(CSV File)]:::data
    end

    %% External Dependencies
    subgraph "External Dependencies"
        Python["Python Runtime (3.6+)"]:::external
        Tkinter["Tkinter Library"]:::external
        PyInstaller["PyInstaller Bundle"]:::external
    end

    %% Relationships
    MainWindow -->|user action| NavigationHandler
    MenuBar -->|delimiter/page-size change| ColumnManager
    NavControls -->|click/shortcut| NavigationHandler
    NavigationHandler -->|invoke| PaginationController
    PaginationController -->|"readPage(pageNumber,pageSize)"| CSVLoader
    CSVLoader -->|reads| DataStore
    CSVLoader -->|returns data| PaginationController
    PaginationController -->|return rows| TableView
    ColumnManager -->|update columns| TableView

    %% Packaging Flow
    subgraph Packaging
        MainModule["main.py + modules"]:::external
    end
    MainModule -->|bundle| PyInstaller

    %% Click Events
    click MainWindow "https://github.com/rudra370/lazy_csv_viewer/blob/main/main.py"
    click MenuBar "https://github.com/rudra370/lazy_csv_viewer/blob/main/main.py"
    click TableView "https://github.com/rudra370/lazy_csv_viewer/blob/main/main.py"
    click NavControls "https://github.com/rudra370/lazy_csv_viewer/blob/main/main.py"
    click CSVLoader "https://github.com/rudra370/lazy_csv_viewer/blob/main/main.py"
    click PaginationController "https://github.com/rudra370/lazy_csv_viewer/blob/main/main.py"
    click ColumnManager "https://github.com/rudra370/lazy_csv_viewer/blob/main/main.py"
    click NavigationHandler "https://github.com/rudra370/lazy_csv_viewer/blob/main/main.py"
    click PyInstaller "https://github.com/rudra370/lazy_csv_viewer/blob/main/README.md"

    %% Styles
    classDef ui fill:#add8e6,stroke:#000
    classDef logic fill:#90ee90,stroke:#000
    classDef data fill:#d3d3d3,stroke:#000
    classDef external fill:#dda0dd,stroke:#000
```
