# dekobon/bunyan-view architecture

> Architecture diagram of the GitHub repository dekobon/bunyan-view, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dekobon/bunyan-view
- Repository: https://github.com/dekobon/bunyan-view

## Overview

##### Main Components

a) Input Processing Layer
- File Input Handler (supporting single/multiple files)
- Stream Input Handler (for piped input)
- GZip Decompression Handler

b) Core Processing Components
- Log Parser
- Condition Filter Engine
- Time Conversion Module
- Level Filter

c) Output Formatting Layer
- Multiple Format Renderers:
- Bunyan (0-indented JSON)
- Inspect
- JSON (configurable indent)
- Long Format
- Short Format
- Simple Format
- Pager Integration

**[Input Sources] → [Input Processing Layer] → [Core Processing] → [Output Formatting] → [Display]**

##### Specific Implementation Details to Highlight

a) Input Flow:
- Multiple input sources converging into the input processing layer
- GZip decompression as an optional preprocessing step

b) Core Processing:
- Modular filter system (condition_filter.rs)
- Date processing (date_deserializer.rs)
- Error handling flow (errors.rs)

c) Output Flow:
- Multiple formatting options as parallel paths
- How the divider_writer.rs integrates
- Pager integration as an optional output path

##### Key Architectural Patterns

- Pipeline Processing Pattern: Show the linear flow of log data through the system
- Filter Chain Pattern: Represent how multiple filters can be applied
- Strategy Pattern: Illustrate how different output formats are handled

##### Technical Details

- Rust-specific components (mark with Rust logo or notation)
- File format handling capabilities
- Memory efficiency considerations
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        F[File Input]
        S[Stream Input]
        G[GZip Input]
    end

    subgraph Processing
        direction TB
        PH[Input Handler]
        LP["Log Parser"]:::core
        CF["Condition Filter Engine"]:::core
        TC["Time Conversion Module"]:::core
        LF["Level Filter"]:::core
        EH["Error Handler"]:::core
    end

    subgraph Formatting
        direction TB
        GF["General Formatter"]:::format
        subgraph Renderers
            direction TB
            BF["Bunyan Format"]
            IF["Inspect Format"]:::format
            JF["JSON Format"]
            LGF["Long Format"]:::format
            SF["Short Format"]:::format
            SPF["Simple Format"]:::format
        end
        DW["Divider Writer"]:::format
        CP[Color Processor]
    end

    subgraph Output
        PG[Pager]
        DS[Direct Stream]
    end

    subgraph Core
        direction TB
        ME["Main Entry"]:::core
        LB["Library"]:::core
        MC["Macros"]:::core
    end

    %% Input Flow
    F --> PH
    S --> PH
    G --> PH

    %% Processing Flow
    PH --> LP
    LP --> CF
    CF --> TC
    TC --> LF
    LF --> EH

    %% Formatting Flow
    EH --> GF
    GF --> BF
    GF --> IF
    GF --> JF
    GF --> LGF
    GF --> SF
    GF --> SPF
    BF & IF & JF & LGF & SF & SPF --> DW
    DW --> CP

    %% Output Flow
    CP --> PG
    CP --> DS

    %% Core Integration
    ME --> PH
    LB --> PH
    MC --> PH

    %% Styling
    classDef core fill:#90EE90
    classDef format fill:#FFE4B5
    classDef filter fill:#FFB6C1

    %% Click Events
    click CF "https://github.com/dekobon/bunyan-view/blob/master/src/condition_filter.rs"
    click TC "https://github.com/dekobon/bunyan-view/blob/master/src/date_deserializer.rs"
    click EH "https://github.com/dekobon/bunyan-view/blob/master/src/errors.rs"
    click IF "https://github.com/dekobon/bunyan-view/blob/master/src/inspect_logger.rs"
    click GF "https://github.com/dekobon/bunyan-view/blob/master/src/formatting_logger.rs"
    click DW "https://github.com/dekobon/bunyan-view/blob/master/src/divider_writer.rs"
    click ME "https://github.com/dekobon/bunyan-view/blob/master/src/main.rs"
    click LB "https://github.com/dekobon/bunyan-view/blob/master/src/lib.rs"
    click MC "https://github.com/dekobon/bunyan-view/blob/master/src/macros.rs"
    click IF "https://github.com/dekobon/bunyan-view/tree/master/tests/expectations/inspect/"
    click LGF "https://github.com/dekobon/bunyan-view/tree/master/tests/expectations/long/"
    click SF "https://github.com/dekobon/bunyan-view/tree/master/tests/expectations/short/"
    click SPF "https://github.com/dekobon/bunyan-view/tree/master/tests/expectations/simple/"
```
