How shshemi/tabiew works
Project Type and Purpose
• Tabiew is a TUI application written in Rust. Its core purpose is to allow users to view and query various tabular data files (CSV, Parquet, JSON, SQLite, etc.) using features such as Vim-style keybindings, SQL querying, and fuzzy search.
• The project is structured as a monolithic, modular application that separates concerns into distinct layers: user interface, event handling/command processing, data access (readers/writers), and application core logic.
Analyzing the File Structure
• Top-level Files: You see configuration/build files (Cargo.toml, Cargo.lock, build.rs, .github workflows) that are standard in Rust projects.
• The src Directory: This is where the bulk of the logic resides. Key modules include:
• Core Application:
• main.rs – the entry point.
• lib.rs – exposes the library’s API for the rest of the application.
• app.rs and config.rs – responsible for initializing and managing the overall application state and configuration.
• Command-Line and Event Handling:
• args.rs – responsible for parsing command-line arguments.
• The handler subdirectory – includes modules such as action.rs, command.rs, event.rs, key.rs. These collectively process user input (keys/commands) and dispatch them appropriately.
• Data Access/Processing:
• reader/ – contains modules for reading various file types (fwf.rs for fixed-width files, sqlite.rs, mod.rs). This layer abstracts the file format-specific logic.
• writer/ – for any eventual operations that output or modify data.
• SQL and Search Operations:
• sql.rs and search.rs appear to add SQL and fuzzy search functionality, tying data processing with user queries.
• TUI Components:
• The tui subdirectory – holds UI widgets and components (command_pallete, data_frame_table, input, search_bar, status_bar, tabs, terminal, theme, etc.). This is the visual layer that interacts directly with the end-user.
• Utilities:
• The utils directory – includes helper functions and extensions (history, iter_ext, polars_ext, type_ext) to support various operations across the application.
Key Insights from the README
• The README confirms that Tabiew offers multiple themes, a tutorial, and detail on keyboard shortcuts. This underscores the importance of the TUI layer and command/event processing mechanics.
• It also emphasizes key user interactions (querying, filtering, ordering) which interact with the SQL and data processing layers.
a. Main Components to Include:
• Application Entry Point:
• Main (src/main.rs) which then loads configuration (src/config.rs) and initializes the application state (src/app.rs).
• Command/Event Handler:
• Modules in src/handler (action, command, event, key) that capture and interpret user input.
• TUI Module:
• Components in src/tui (terminal, command pallete, data frame table, search bar, tabs, etc.) that render the interface and interact with the handler.
• Data Processing Layer:
• Reader modules (from src/reader) that load and parse various file formats.
• The SQL module (src/sql.rs) and search module (src/search.rs) that execute queries and perform fuzzy search operations.
• Utility/Support Modules:
• Utility functions (in src/utils) and writer modules (src/writer) available across layers.
b. Relationships and Data Flow:
• User Input (via TUI) → TUI Components capture keystrokes and commands.
• TUI Components send events to the Event Handlers (handler/* modules).
• Command Handlers then call upon Core Application logic (app.rs/config.rs) as needed.
• For querying data:
• The SQL and search modules are invoked.
• Data readers (src/reader) load/parses the requested files.
• Processed data is then forwarded back to TUI Components for rendering.
• Utilities act as supporting modules that can be called from different layers.
c. Architectural Patterns and Principles:
• Layered Architecture: Separating UI, business logic, and data access.
• Modular Design: Each folder/module focuses on a single responsibility (e.g., tui, reader, handler) which makes components easily testable and replaceable.
• Event-Driven Flow: The command and event handler modules indicate an event-driven approach for user interactions.
d. Relevant Technologies & Frameworks:
• Rust as the programming language.
• Cargo for package management and building.
• Terminal UI libraries (likely leveraging Rust TUI crates, as seen via the tui/ directory).
• SQL parsing and fuzzy search implementations as part of the business logic, interacting with CSV/Parquet readers.