# gregorytravis/tmi architecture

> Architecture diagram of the GitHub repository gregorytravis/tmi, 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/gregorytravis/tmi
- Repository: https://github.com/gregorytravis/tmi

## Overview

##### Core Language Components Layer
- State.hs (State management)
- Stream.hs (FRP functionality)
- History.hs (Time-series database functionality)
- Internal.hs (Core implementations)

##### Language Features Layer
- Functional/Pure Components
- Relational Database System
- Bidirectional Transformations
- Lens System
- FRP (Functional Reactive Programming) System

##### Interface Layer
- Main.hs as the entry point
- TIO.hs for I/O operations
- Tmi.hs as the main language interface

##### Use a Layered Architecture Style
- [Interface Layer]
- ↑↓
- [Language Features Layer]
- ↑↓
- [Core Components Layer]
- ↑↓
- [Time-Series Database]

##### Time-Series Database Integration
- How History.hs interfaces with history.db
- Demonstrate the relationship between State.hs and History.hs

##### Feature Integration
- How Lens.hs provides bidirectional capabilities
- Stream.hs's role in FRP implementation
- Demonstrate how Hash.hs and Key.hs support the relational aspects

##### System Flow
- How Main.hs orchestrates the system
- How TIO.hs handles I/O operations
- Demonstrate the relationship between Tmi.hs and other components

Level of Detail:

- The FRP system
- The lens implementation
- The relational database system
- The time-series database implementation

Remember to emphasize:

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef interface fill:#FFA500,stroke:#333,stroke-width:2px
    classDef core fill:#4169E1,stroke:#333,stroke-width:2px
    classDef feature fill:#9370DB,stroke:#333,stroke-width:2px
    classDef database fill:#90EE90,stroke:#333,stroke-width:2px
    classDef default fill:#fff,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Interface Components]:::interface
        L2[Core Components]:::core
        L3[Language Features]:::feature
        L4[Database Components]:::database
        L5[("→ Direct Dependency")]
        L6[("⇢ Data Flow")]
        L7[("↔ Bidirectional")]
    end

    %% Interface Layer
    subgraph Interface
        Main[Main Entry Point]:::interface
        TIO[I/O Operations]:::interface
        TMI[Language Interface]:::interface
    end

    %% Language Features Layer
    subgraph Features
        FRP[FRP System]:::feature
        Lens[Lens System]:::feature
        BT[Bidirectional Transformations]:::feature
        RDB[Relational Database System]:::feature
        Dyno[Dynamic Operations]:::feature
        Lift[Lifting Operations]:::feature
    end

    %% Core Components Layer
    subgraph Core
        State[State Management]:::core
        Stream[Stream Processing]:::core
        Internal[Core Implementation]:::core
        Hash[Hash Functions]:::core
        Key[Key Management]:::core
        Util[Utility Functions]:::core
    end

    %% Database Layer
    subgraph Storage
        History[Time-series Database]:::database
        HistoryDB[(history.db)]:::database
    end

    %% Relationships
    Main --> TMI
    Main --> TIO
    TMI --> State
    TMI --> Stream
    TIO --> State
    State --> Internal
    Stream --> Internal
    Internal --> History
    History --> HistoryDB
    Hash --> RDB
    Key --> RDB
    FRP --> Stream
    Lens <--> BT
    RDB --> Hash
    RDB --> Key
    Dyno --> Internal
    Lift --> Internal
    Util --> Internal

    %% Click Events
    click Main "https://github.com/GregoryTravis/tmi/blob/master/src/Main.hs"
    click TIO "https://github.com/GregoryTravis/tmi/blob/master/src/TIO.hs"
    click TMI "https://github.com/GregoryTravis/tmi/blob/master/src/Tmi.hs"
    click State "https://github.com/GregoryTravis/tmi/blob/master/src/State.hs"
    click Stream "https://github.com/GregoryTravis/tmi/blob/master/src/Stream.hs"
    click Internal "https://github.com/GregoryTravis/tmi/blob/master/src/Internal.hs"
    click History "https://github.com/GregoryTravis/tmi/blob/master/src/History.hs"
    click Hash "https://github.com/GregoryTravis/tmi/blob/master/src/Hash.hs"
    click Key "https://github.com/GregoryTravis/tmi/blob/master/src/Key.hs"
    click Util "https://github.com/GregoryTravis/tmi/blob/master/src/Util.hs"
    click Dyno "https://github.com/GregoryTravis/tmi/blob/master/src/Dyno.hs"
    click Lift "https://github.com/GregoryTravis/tmi/blob/master/src/Lift.hs"
    click HistoryDB "https://github.com/GregoryTravis/tmi/blob/master/history.db"
```
