How azat/chdig works
Main Components
• Entry Point & Core Library:
• Main entry point (src/main.rs) and the core library (src/lib.rs), which bootstraps the application.
• TUI/View Layer:
• TUI interface driven by multiple view modules (located in src/view, such as log_view, text_log_view, process_view, query_result_view, etc.) that render different data perspectives.
• Interpreter/Business Logic Layer:
– Background Runner (background_runner.rs): handling asynchronous/background tasks.
– ClickHouse Connector (clickhouse.rs and clickhouse_quirks.rs): managing the communication with the ClickHouse server.
– Query Processing (query_process.rs & options.rs): parsing options and processing query results.
– Flamegraph Generation (flamegraph.rs): converting performance data into flamegraph representations.
• Action Handling:
• Actions module (src/actions.rs), which likely maps user commands—triggered by the TUI—to business logic operations.
• Utility & Common Modules:
• A utilities block (src/utils.rs) and common components (src/common/stopwatch.rs, etc.) that support shared functions and timing utilities.
• External Systems:
• External ClickHouse server, which the application communicates with to fetch system and query log data.
• Configuration & Build/Deployment:
• Although not the application runtime, note the existence of configuration files (Cargo.toml, Cargo.lock, rustfmt.toml) and workflows (in .github/workflows) that indicate continuous integration/deployment pipelines.
Relationships and Interactions
• That the application’s entry point initializes the core components and wires up the TUI (view layer) with the interpreter.
• That the interpreter connects with the ClickHouse connector module which, in turn, communicates externally with the ClickHouse server.
• Optionally, include lines connecting shared utilities (from common and utils) with the interpreter and the TUI, as supporting infrastructure for time measurements, logging, or view data formatting.
Architectural Patterns and Design Principles
• Separation of Concerns:
• Modular Design:
• Each view (for logs, queries, metrics) is implemented as a distinct module under src/view, implying that the system can be extended by adding new views or modifying existing ones.
• Asynchronous/Background Processing:
• Role of the background_runner and worker modules in handling asynchronous query execution or updates.
• External Integration: