# krestenkrab/triq architecture

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

- Interactive diagram: https://gitdiagram.com/krestenkrab/triq
- Repository: https://github.com/krestenkrab/triq

## Overview

##### Main Components

a) Core Testing Engine Components:
- Property Generator (triq_dom.erl)
- Test Runner (triq.erl)
- Expression Evaluator (triq_expr.erl)
- State Machine Components (triq_statem.erl, triq_fsm.erl)

b) Application Infrastructure:
- Application Supervisor (triq_sup.erl)
- Application Controller (triq_app.erl)

c) Support Components:
- Auto-export Functionality (triq_autoexport.erl)
- Files/API Definitions (include/*.hrl)

**[User Code/Tests] --> [Triq API Layer]**

- v
- [Property Engine]

- ____________

- [Generators]  [Test Runner]

- v            v
- [Domain Types]  [Evaluator]

- v            v
- [State Machines/FSM Layer]

- v
- [Application Support]
- (OTP Supervision Tree)

##### Important Relationships to Highlight

a) Control Flow:
- How property definitions flow from user code through the API
- Test generation and execution pipeline
- Demonstrate the relationship between state machines and the core engine

b) Dependencies:
- OTP application structure
- How the supervision tree manages components
- Relationship between include files and implementation

##### Technical Details

- Erlang/OTP specific patterns (supervision, behaviors)
- Property definition syntax and flow
- Generator composition and domain types
- State machine and FSM integration points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph User
        UserCode[User Code/Tests]
    end

    subgraph API
        TriqAPI[Triq API Layer]:::api
        IncludeFiles[API Definitions]:::api
    end

    subgraph PropertyEngine
        PropGen[Property Generator]:::core
        TestRunner[Test Runner]:::core
        ExprEval[Expression Evaluator]:::core
    end

    subgraph StateMachines
        StateMachine[State Machine]:::core
        FSM[FSM]:::core
        FSMStub[FSM Stub]:::support
    end

    subgraph AppInfra
        AppController[Application Controller]:::infra
        AppSupervisor[Application Supervisor]:::infra
        AutoExport[Auto Export]:::support
    end

    %% Relationships
    UserCode --> TriqAPI
    TriqAPI --> PropGen
    TriqAPI --> TestRunner
    IncludeFiles --> TriqAPI

    PropGen --> ExprEval
    TestRunner --> ExprEval
    ExprEval --> StateMachine
    ExprEval --> FSM
    FSM --> FSMStub

    AppSupervisor --> TestRunner
    AppSupervisor --> PropGen
    AppController --> AppSupervisor
    AutoExport --> TriqAPI

    %% Styling
    classDef core fill:#2374f7,stroke:#000,stroke-width:2px
    classDef api fill:#47d147,stroke:#000,stroke-width:2px
    classDef infra fill:#ffcc00,stroke:#000,stroke-width:2px
    classDef support fill:#ff9933,stroke:#000,stroke-width:2px

    %% Click events
    click PropGen "https://github.com/krestenkrab/triq/blob/master/src/triq_dom.erl"
    click TestRunner "https://github.com/krestenkrab/triq/blob/master/src/triq.erl"
    click ExprEval "https://github.com/krestenkrab/triq/blob/master/src/triq_expr.erl"
    click StateMachine "https://github.com/krestenkrab/triq/blob/master/src/triq_statem.erl"
    click FSM "https://github.com/krestenkrab/triq/blob/master/src/triq_fsm.erl"
    click FSMStub "https://github.com/krestenkrab/triq/blob/master/src/triq_fsm_stub.erl"
    click AppSupervisor "https://github.com/krestenkrab/triq/blob/master/src/triq_sup.erl"
    click AppController "https://github.com/krestenkrab/triq/blob/master/src/triq_app.erl"
    click AutoExport "https://github.com/krestenkrab/triq/blob/master/src/triq_autoexport.erl"
    click IncludeFiles "https://github.com/krestenkrab/triq/tree/master/include"
```
