# sorenholsthansen/runtime-lint architecture

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

- Interactive diagram: https://gitdiagram.com/sorenholsthansen/runtime-lint
- Repository: https://github.com/sorenholsthansen/runtime-lint

## Overview

##### Main Components Identification

a) Core Runtime Linter
- Three main rule processors as sub-components:
- OverFetching Detector
- QueryInLoop Detector
- DuplicateResponses Detector

b) Integration Layer
- How it integrates with the host application
- Fetch API interception mechanism
- Configuration intake system

##### Component Details

For each major component, include:

Runtime Linter Core:
- Configuration processor
- Fetch API interceptor
- Rule orchestrator

Rule Processors (show as parallel components):
- OverFetching Analyzer
- Response tracker
- Usage statistics collector
- Heuristic evaluator
- QueryInLoop Detector
- URL pattern analyzer
- Threshold checker
- Debounce mechanism
- DuplicateResponses Checker
- Response cache
- Comparison engine

##### Technical Details

Annotations for:
- Default timeouts (e.g., msTillCheck: 1000ms)
- Thresholds (e.g., QueryInLoop threshold: 3)
- Callback interfaces
- Configuration options

##### Integration Points

Highlight:
- Host application entry point
- Fetch API integration
- Callback system
- Configuration interface

##### Bottom: Rule Processors and Callbacks

Remember to:
- Keep the main components visually distinct
- Version information
- Performance considerations
- Example configuration blocks

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Host["Host Application Layer"]
        App[Application]
        FetchAPI[Fetch API]
    end

    subgraph Core["Runtime Linter Core"]
        direction TB
        RuntimeLinter[("Runtime Linter")]:::core
        ConfigProcessor[Configuration Processor]:::core
        FetchInterceptor[Fetch Interceptor]:::core
        RuleOrchestrator[Rule Orchestrator]:::core
    end

    subgraph Rules["Rule Processors"]
        direction TB
        OverFetch[OverFetching Detector]:::rule
        QueryLoop[QueryInLoop Detector]:::rule
        DupCheck[DuplicateResponses Checker]:::rule
    end

    subgraph Utils["Utility Components"]
        direction TB
        URLAnalyzer[URL Pattern Analyzer]:::util
        DeepCompare[Deep Comparison Engine]:::util
        StatsCollector[Object Statistics Collector]:::util
        ModLoader[Module Loader]:::util
    end

    subgraph Examples["Example Implementations"]
        direction TB
        ExOverFetch[OverFetching Example]:::example
        ExQueryLoop[QueryInLoop Example]:::example
        ExDupResp[DuplicateResponses Example]:::example
    end

    subgraph TestEnv["Test Environment"]
        direction TB
        APITest[API Test Environment]:::test
        TestData[Test Data]:::test
    end

    %% Connections
    App --> FetchAPI
    FetchAPI --> FetchInterceptor
    App --> ConfigProcessor
    ConfigProcessor --> RuntimeLinter
    FetchInterceptor --> RuntimeLinter
    RuntimeLinter --> RuleOrchestrator
    RuleOrchestrator --> OverFetch & QueryLoop & DupCheck
    
    %% Utility Connections
    URLAnalyzer --> QueryLoop
    DeepCompare --> DupCheck
    StatsCollector --> OverFetch
    ModLoader --> RuntimeLinter

    %% Example Connections
    ExOverFetch -.-> OverFetch
    ExQueryLoop -.-> QueryLoop
    ExDupResp -.-> DupCheck

    %% Test Environment Connections
    APITest -.-> FetchAPI
    TestData -.-> APITest

    %% Click Events
    click RuntimeLinter "https://github.com/SorenHolstHansen/runtime-lint/blob/main/packages/runtime-lint/src/index.ts"
    click OverFetch "https://github.com/SorenHolstHansen/runtime-lint/blob/main/packages/runtime-lint/src/rules/overFetching/overFetching.ts"
    click QueryLoop "https://github.com/SorenHolstHansen/runtime-lint/blob/main/packages/runtime-lint/src/rules/queriesInLoops/queriesInLoops.ts"
    click URLAnalyzer "https://github.com/SorenHolstHansen/runtime-lint/blob/main/packages/runtime-lint/src/utils/detectUrlFamilies.ts"
    click DeepCompare "https://github.com/SorenHolstHansen/runtime-lint/blob/main/packages/runtime-lint/src/utils/deepEqual.ts"
    click StatsCollector "https://github.com/SorenHolstHansen/runtime-lint/blob/main/packages/runtime-lint/src/utils/objectStats.ts"
    click ModLoader "https://github.com/SorenHolstHansen/runtime-lint/blob/main/packages/runtime-lint/src/utils/loader.ts"
    click ExOverFetch "https://github.com/SorenHolstHansen/runtime-lint/blob/main/examples/nextjs-client/src/app/over-fetching/page.tsx"
    click ExQueryLoop "https://github.com/SorenHolstHansen/runtime-lint/blob/main/examples/nextjs-client/src/app/queries-in-a-loop/page.tsx"
    click ExDupResp "https://github.com/SorenHolstHansen/runtime-lint/blob/main/examples/nextjs-client/src/app/duplicate-responses/page.tsx"
    click APITest "https://github.com/SorenHolstHansen/runtime-lint/blob/main/packages/runtime-lint/test-api/api.js"
    click TestData "https://github.com/SorenHolstHansen/runtime-lint/blob/main/packages/runtime-lint/test-api/todos.json"

    %% Styling
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef rule fill:#ff7f50,stroke:#ff7f50,color:#fff
    classDef util fill:#95b8d1,stroke:#95b8d1,color:#fff
    classDef example fill:#8fb339,stroke:#8fb339,color:#fff
    classDef test fill:#b8b8ff,stroke:#b8b8ff,color:#fff

    %% Legend
    subgraph Legend
        direction TB
        L1[Core Components]:::core
        L2[Rule Processors]:::rule
        L3[Utility Components]:::util
        L4[Example Components]:::example
        L5[Test Components]:::test
    end
```
