How fedecarles/polars-gui works
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: app.rs app · main.rs main · lib.rs lib · container.rs container
Components 18
Runtimes
Execution targets and entrypoints
UI Shell
Immediate-mode interface and app state
- egui/eframe · Immediate-mode GUI runtime
- app · Main application state and interaction flow
src/app.rs
Data Model
Dataset storage and shared helpers
Transforms
Polars-backed dataframe operations
Web Deploy
Browser build and PWA support
- Trunk · WASM build and local web serving
Trunk.toml - index.html · Browser entry document
index.html - PWA assets · Service worker and manifest
- Pages deploy · GitHub Pages publishing workflow
.github/workflows/pages.yml
Connections 24
- 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