# hamin/jlq architecture

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

- Interactive diagram: https://gitdiagram.com/hamin/jlq
- Repository: https://github.com/hamin/jlq

## Overview

##### Main Components

a) Input Layer:
- JSON Log Files Handler
- Command Line Interface (CLI) Parser

b) Processing Layer:
- SQLite Engine Interface
- JSON Processing Module
- File Tailing System

c) Storage Layer:
- In-Memory SQLite Storage
- On-Disk SQLite Storage

##### Component Relationships

**Input -> Processing -> Storage/Output**

##### Specific Implementation Details

- Rectangles: Core processing components
- Parallelograms: Input/Output components
- Diamonds: Decision points (e.g., in-memory vs. on-disk storage)

- Blue: Input components
- Green: Processing components
- Orange: Storage components
- Gray: External dependencies (SQLite)

##### Detailed Component Breakdown

**[Input Layer]**
- JSON Log Files (Input) → File Reader
- CLI Arguments → Args Parser
- Query Parameters
- Flags (-t, -m, -v, -d)

**[Processing Layer]**
- SQLite Query Executor
- JSON1 Extension Functions
- File Tailing System (when -t flag is used)
- JSON Parser

**[Storage Layer]**
- In-Memory SQLite (-m flag)
- On-Disk SQLite (default: jql.db)

##### Important Flows to Highlight

- Main data flow:
1. JSON log files → Parser → SQLite Storage
2. Query execution path
3. Tailing mechanism for real-time monitoring

##### Additional Elements

- Version information (0.1.0)
- Dependencies (SQLite, Rust)
- Async operations (file tailing)

##### Technical Details

- SQLite JSON1 extension integration
- File watching mechanism for tail mode
- Memory management for in-memory vs. on-disk modes
- Query execution flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Input Layer
    subgraph Input
        JSON[JSON Log Files]:::input
        CLI[CLI Arguments]:::input
        FlagT["-t (tail)"]:::flag
        FlagM["-m (memory)"]:::flag
        FlagV["-v (verbose)"]:::flag
        FlagD["-d (debug)"]:::flag
    end

    %% Processing Layer
    subgraph Processing
        FileReader[File Reader]:::process
        ArgsParser[Args Parser]:::process
        SQLExecutor[SQLite Query Executor]:::process
        JSONParser[JSON Parser]:::process
        FileTail[File Tailing System]:::process
        JSON1[JSON1 Extension]:::process
    end

    %% Storage Layer
    subgraph Storage
        InMem[(In-Memory SQLite)]:::storage
        OnDisk[(On-Disk SQLite)]:::storage
    end

    %% Relationships
    JSON --> FileReader
    CLI --> ArgsParser
    FlagT --> ArgsParser
    FlagM --> ArgsParser
    FlagV --> ArgsParser
    FlagD --> ArgsParser
    
    FileReader --> JSONParser
    JSONParser --> SQLExecutor
    ArgsParser --> SQLExecutor
    FileTail --> FileReader
    JSON1 --> SQLExecutor
    
    SQLExecutor --> InMem
    SQLExecutor --> OnDisk

    %% Click Events
    click ArgsParser "https://github.com/hamin/jlq/blob/main/src/main.rs"
    click FileReader "https://github.com/hamin/jlq/blob/main/src/main.rs"
    click SQLExecutor "https://github.com/hamin/jlq/blob/main/src/main.rs"
    click JSONParser "https://github.com/hamin/jlq/blob/main/src/main.rs"
    click FileTail "https://github.com/hamin/jlq/blob/main/src/main.rs"

    %% Styles
    classDef input fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef process fill:#90EE90,stroke:#333,stroke-width:2px
    classDef storage fill:#FFB347,stroke:#333,stroke-width:2px
    classDef flag fill:#D3D3D3,stroke:#333,stroke-width:1px

    %% Legend
    subgraph Legend
        L1[Input Components]:::input
        L2[Processing Components]:::process
        L3[(Storage Components)]:::storage
        L4[Flag Options]:::flag
    end
```
