# fedecarles/polars-gui architecture

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

- Interactive diagram: https://gitdiagram.com/fedecarles/polars-gui
- Repository: https://github.com/fedecarles/polars-gui

## Overview

1. **What this repo is**
   - `polars-gui` is a desktop/browser GUI for working with **Polars DataFrame** data in Rust.
   - The core architecture is a single interactive app built with **egui/eframe**, with Polars handling the tabular data operations.

2. **Top-level runtime boundary**
   - The app runs in two modes: **native Rust binary** and **WASM/browser**.
   - `src/main.rs` is the entry/bootstrap point, while `Trunk.toml`, `index.html`, and `.github/workflows/pages.yml` support the browser build and GitHub Pages deployment.
   - `assets/sw.js` and `assets/manifest.json` indicate browser-side PWA/service-worker support.

3. **UI shell and app state**
   - `src/app.rs` is the main application layer and likely owns the UI state, window layout, and user interaction flow.
   - This is the place where DataFrame metadata, selected dataset, and current transformation mode are coordinated.

4. **Data model and dataset management**
   - `src/container.rs` appears to be the central data-holding layer for loaded datasets.
   - It likely acts as the boundary between UI state and Polars objects, tracking one or more DataFrames plus their names/selection state.
   - This is the main place where “load multiple files” support would be organized.

5. **Transformation subsystems**
   - The repo separates major DataFrame operations into dedicated modules:
     - `src/filter.rs` for row filtering
     - `src/aggregate.rs` for group/aggregation workflows
     - `src/melt.rs` for reshape/unpivot operations
     - `src/join.rs` for merge/join operations
   - This modular split suggests each transformation has its own UI controls and Polars execution path, with the app orchestrating them.

6. **Shared helpers and cross-cutting logic**
   - `src/utils.rs` likely contains shared helpers used by multiple modules, such as column/type inspection, parsing, error handling, or UI utilities.
   - `src/lib.rs` probably re-exports the modules so the app can be built as a reusable crate as well as an executable.

7. **Main data flow**
   - User loads CSV files into the app.
   - The load step populates the container/state with one or more Polars DataFrames.
   - The user then chooses an operation type in the UI, configures parameters, and the corresponding module applies the transformation.
   - Results are displayed back through the egui interface, replacing or augmenting the active dataset.

8. **File ingestion boundary**
   - The README explicitly says current input support is **CSV only**.
   - That makes CSV parsing the main external data ingestion path, and it is likely the only file-format boundary the app currently exposes.

9. **UI rendering and interaction model**
   - The app uses **egui + eframe**, which means the UI is immediate-mode rather than component/stateful DOM-based.
   - Architecture-wise, this keeps the core loop centered on “render current state, accept user input, mutate app state, recompute data views.”

10. **Build and packaging**
   - `Cargo.toml` and `Cargo.lock` define the Rust crate dependencies and exact versions.
   - `check.sh` suggests a local validation script for formatting/build checks.
   - `src/.app.rs.rustfmt` implies some code formatting customization or exclusion around the main app file.

11. **Browser deployment path**
   - Web support is not just incidental: the project is configured to compile to WASM and run in the browser via `trunk serve`.
   - `pages.yml` indicates the browser build is also used for publishing, so the architecture includes a deployable frontend artifact even though the business logic remains Rust.

12. **How to draw the diagram**
   - The central box should be the **egui app/state layer**.
   - Connect that to a **DataFrame container/model** and then fan out to the four operation modules: **filter, aggregate, melt, join**.
   - Place **CSV import** as the inbound data source.
   - Show two execution targets from the same codebase: **native binary** and **WASM/browser**.
   - Keep Polars as the computation engine beneath the transformation modules, and egui/eframe as the presentation layer above them.

Main entry points: [`src/app.rs`](https://github.com/fedecarles/polars-gui/blob/main/src/app.rs) (app), [`src/main.rs`](https://github.com/fedecarles/polars-gui/blob/main/src/main.rs) (main), [`src/lib.rs`](https://github.com/fedecarles/polars-gui/blob/main/src/lib.rs) (lib), [`src/container.rs`](https://github.com/fedecarles/polars-gui/blob/main/src/container.rs) (container)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtimes"]
  node_src_main_rs["main<br/>entrypoint<br/>[main.rs]"]
  node_src_lib_rs["lib<br/>crate root<br/>[lib.rs]"]
  node_native_binary(("Native app<br/>runtime target"))
  node_wasm_browser(("Browser app<br/>runtime target"))
end

subgraph group_ui["UI Shell"]
  node_egui_eframe["egui/eframe<br/>ui framework"]
  node_src_app_rs["app<br/>ui state<br/>[app.rs]"]
end

subgraph group_data["Data Model"]
  node_src_container_rs[("container<br/>dataset store<br/>[container.rs]")]
  node_src_utils_rs["utils<br/>shared helpers<br/>[utils.rs]"]
  node_csv_input["CSV import<br/>input boundary"]
  node_polars_engine[("Polars<br/>data engine")]
end

subgraph group_transforms["Transforms"]
  node_src_filter_rs["filter<br/>transform<br/>[filter.rs]"]
  node_src_aggregate_rs["aggregate<br/>transform<br/>[aggregate.rs]"]
  node_src_melt_rs["melt<br/>transform<br/>[melt.rs]"]
  node_src_join_rs["join<br/>transform<br/>[join.rs]"]
end

subgraph group_web["Web Deploy"]
  node_trunk_config["Trunk<br/>web build<br/>[Trunk.toml]"]
  node_index_html["index.html<br/>web shell<br/>[index.html]"]
  node_pwa_assets["PWA assets<br/>browser support"]
  node_gh_pages["Pages deploy<br/>deployment<br/>[pages.yml]"]
end

node_src_main_rs -->|"starts"| node_src_app_rs
node_src_app_rs -->|"renders"| node_egui_eframe
node_src_app_rs -->|"owns"| node_src_container_rs
node_src_app_rs -->|"uses"| node_src_utils_rs
node_src_container_rs -->|"loads"| node_csv_input
node_csv_input -->|"parses"| node_polars_engine
node_src_filter_rs -->|"executes"| node_polars_engine
node_src_aggregate_rs -->|"executes"| node_polars_engine
node_src_melt_rs -->|"executes"| node_polars_engine
node_src_join_rs -->|"executes"| node_polars_engine
node_src_app_rs -->|"orchestrates"| node_src_filter_rs
node_src_app_rs -->|"orchestrates"| node_src_aggregate_rs
node_src_app_rs -->|"orchestrates"| node_src_melt_rs
node_src_app_rs -->|"orchestrates"| node_src_join_rs
node_src_lib_rs -->|"re-exports"| node_src_app_rs
node_src_lib_rs -->|"re-exports"| node_src_container_rs
node_src_lib_rs -->|"re-exports"| node_src_utils_rs
node_src_main_rs -->|"builds"| node_native_binary
node_src_main_rs -->|"compiles to"| node_wasm_browser
node_trunk_config -->|"serves"| node_wasm_browser
node_index_html -->|"loads"| node_wasm_browser
node_pwa_assets -->|"supports"| node_wasm_browser
node_gh_pages -->|"publishes"| node_index_html
node_gh_pages -->|"uses"| node_trunk_config

click node_src_main_rs "https://github.com/fedecarles/polars-gui/blob/main/src/main.rs"
click node_src_lib_rs "https://github.com/fedecarles/polars-gui/blob/main/src/lib.rs"
click node_src_app_rs "https://github.com/fedecarles/polars-gui/blob/main/src/app.rs"
click node_src_container_rs "https://github.com/fedecarles/polars-gui/blob/main/src/container.rs"
click node_src_utils_rs "https://github.com/fedecarles/polars-gui/blob/main/src/utils.rs"
click node_src_filter_rs "https://github.com/fedecarles/polars-gui/blob/main/src/filter.rs"
click node_src_aggregate_rs "https://github.com/fedecarles/polars-gui/blob/main/src/aggregate.rs"
click node_src_melt_rs "https://github.com/fedecarles/polars-gui/blob/main/src/melt.rs"
click node_src_join_rs "https://github.com/fedecarles/polars-gui/blob/main/src/join.rs"
click node_trunk_config "https://github.com/fedecarles/polars-gui/blob/main/Trunk.toml"
click node_index_html "https://github.com/fedecarles/polars-gui/blob/main/index.html"
click node_gh_pages "https://github.com/fedecarles/polars-gui/blob/main/.github/workflows/pages.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_src_main_rs,node_src_lib_rs,node_native_binary,node_wasm_browser toneBlue
class node_egui_eframe,node_src_app_rs toneAmber
class node_src_container_rs,node_src_utils_rs,node_csv_input,node_polars_engine toneMint
class node_src_filter_rs,node_src_aggregate_rs,node_src_melt_rs,node_src_join_rs toneRose
class node_trunk_config,node_index_html,node_pwa_assets,node_gh_pages toneIndigo
```

## Components

### Runtimes

Execution targets and entrypoints

- [main](https://github.com/fedecarles/polars-gui/blob/main/src/main.rs): entrypoint · Bootstraps the application · `src/main.rs`
- [lib](https://github.com/fedecarles/polars-gui/blob/main/src/lib.rs): crate root · Module re-exports for library use · `src/lib.rs`
- **Native app**: runtime target · Desktop Rust executable
- **Browser app**: runtime target · WASM execution in the browser

### UI Shell

Immediate-mode interface and app state

- **egui/eframe**: ui framework · Immediate-mode GUI runtime
- [app](https://github.com/fedecarles/polars-gui/blob/main/src/app.rs): ui state · Main application state and interaction flow · `src/app.rs`

### Data Model

Dataset storage and shared helpers

- [container](https://github.com/fedecarles/polars-gui/blob/main/src/container.rs): dataset store · Loaded dataframe collection and selection state · `src/container.rs`
- [utils](https://github.com/fedecarles/polars-gui/blob/main/src/utils.rs): shared helpers · Cross-cutting helpers for UI and dataframe logic · `src/utils.rs`
- **CSV import**: input boundary · Current file ingestion path
- **Polars**: data engine · Tabular computation and dataframe operations

### Transforms

Polars-backed dataframe operations

- [filter](https://github.com/fedecarles/polars-gui/blob/main/src/filter.rs): transform · Row filtering workflow · `src/filter.rs`
- [aggregate](https://github.com/fedecarles/polars-gui/blob/main/src/aggregate.rs): transform · Grouping and aggregation workflow · `src/aggregate.rs`
- [melt](https://github.com/fedecarles/polars-gui/blob/main/src/melt.rs): transform · Reshape / unpivot workflow · `src/melt.rs`
- [join](https://github.com/fedecarles/polars-gui/blob/main/src/join.rs): transform · Merge / join workflow · `src/join.rs`

### Web Deploy

Browser build and PWA support

- [Trunk](https://github.com/fedecarles/polars-gui/blob/main/Trunk.toml): web build · WASM build and local web serving · `Trunk.toml`
- [index.html](https://github.com/fedecarles/polars-gui/blob/main/index.html): web shell · Browser entry document · `index.html`
- **PWA assets**: browser support · Service worker and manifest
- [Pages deploy](https://github.com/fedecarles/polars-gui/blob/main/.github/workflows/pages.yml): deployment · GitHub Pages publishing workflow · `.github/workflows/pages.yml`

## Connections

- main → app: starts · Main entry builds and launches the app
- app → egui/eframe: renders · App state is presented through egui/eframe
- app → container: owns · UI coordinates the active dataset state
- app → utils: uses · Shared helper logic supports the app
- container → CSV import: loads · Container is populated from CSV files
- CSV import → Polars: parses · CSV ingestion produces Polars dataframes
- filter → Polars: executes · Filtering is delegated to Polars
- aggregate → Polars: executes · Aggregation is delegated to Polars
- melt → Polars: executes · Reshape operations are delegated to Polars
- join → Polars: executes · Join operations are delegated to Polars
- app → filter: orchestrates · App dispatches filter workflows
- app → aggregate: orchestrates · App dispatches aggregation workflows
- app → melt: orchestrates · App dispatches reshape workflows
- app → join: orchestrates · App dispatches join workflows
- lib → app: re-exports · Library root exposes the app modules
- lib → container: re-exports · Library root exposes shared model modules
- lib → utils: re-exports · Library root exposes helper modules
- main → Native app: builds · Rust main drives the desktop executable
- main → Browser app: compiles to · Same codebase also targets WASM
- Trunk → Browser app: serves · Trunk is the browser build path
- index.html → Browser app: loads · Browser entry page hosts the app
- PWA assets → Browser app: supports · Service worker and manifest enable PWA behavior
- Pages deploy → index.html: publishes · Workflow deploys the browser artifact
- Pages deploy → Trunk: uses · Deployment depends on the web build configuration
