# hugomartinet/scriptools architecture

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

- Interactive diagram: https://gitdiagram.com/hugomartinet/scriptools
- Repository: https://github.com/hugomartinet/scriptools

## Overview

##### Component Details

Runner Module:
- Input: Function (sync/async)
- Output: Process management/exit handling
- To Logger for potential error handling

Logger Module (Central Component):
- Four log level channels: INFO, SUCCESS, WARN, ERROR
- Internal journal storage
- Two output modes: Immediate and Delayed printing
- Configuration options component

Timer Module:
- Function wrapper mechanism
- To Logger for time reporting

##### Data Flow Representation
- Circular data flow in Logger's journal system

##### Specific Implementation Details
- TypeScript type annotations on interfaces
- External process interaction points
- Configuration injection points

##### Elements
- ⬡ Singleton Component
- □ Standard Component
- → Direct Method Call
- ⇢ Optional Interaction
- 🔄 Data Flow
- ⚙️ Configuration Point

##### Integration Points
- How the library integrates with user scripts
- Entry points for each utility
- Configuration injection points

- The modular nature of the tools
- The central role of the Logger
- The interaction between components
- The configuration options
- The data flow through the system

Keep the abstraction level focused on the architectural patterns while showing enough implementation detail to understand the utility's functionality. This balance is crucial as the library is meant to be integrated into other projects as a development tool.

##### Final output/cleanup

This will help developers understand both the architecture and the practical application of the library.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Standard Component]
        L2[/Input/Output/]
        L3{{Singleton}}
        L4[("Configuration")]
        L5>Process]

        style L1 fill:#blue
        style L2 fill:#gray
        style L3 fill:#purple
        style L4 fill:#yellow
        style L5 fill:#green
    end

    subgraph Core["Core Library Components"]
        Runner["Runner Module"]
        Logger{{Logger Module}}
        Timer["Timer Module"]
        Entry["Entry Point"]

        click Runner "https://github.com/hugomartinet/scriptools/blob/main/src/runner.ts"
        click Logger "https://github.com/hugomartinet/scriptools/blob/main/src/logger.ts"
        click Timer "https://github.com/hugomartinet/scriptools/blob/main/src/timer.ts"
        click Entry "https://github.com/hugomartinet/scriptools/blob/main/src/index.ts"
    end

    subgraph Configuration
        TSConfig[("TypeScript Config")]
        PackageConfig[("Package Config")]
        LintConfig[("ESLint Config")]
        StyleConfig[("Prettier Config")]
        Pipeline[("Build Pipeline")]

        click TSConfig "https://github.com/hugomartinet/scriptools/blob/main/tsconfig.json"
        click PackageConfig "https://github.com/hugomartinet/scriptools/blob/main/package.json"
        click LintConfig "https://github.com/hugomartinet/scriptools/blob/main/.eslintrc"
        click StyleConfig "https://github.com/hugomartinet/scriptools/blob/main/.prettierrc"
        click Pipeline "https://github.com/hugomartinet/scriptools/blob/main/.github/workflows/release.yml"
    end

    subgraph LoggerSystem["Logger Components"]
        LogLevels[/"Log Levels"/]
        Journal[("Journal Storage")]
        PrintModes[/"Output Modes"/]
    end

    subgraph RunnerSystem["Runner Components"]
        ProcessMgmt>Process Management]
        ExitHandler>Exit Handling]
        FuncWrapper[/"Function Wrapper"/]
    end

    subgraph TimerSystem["Timer Components"]
        TimeTracker[/"Time Tracking"/]
        PerfMetrics[/"Performance Metrics"/]
    end

    %% Connections
    Entry --> Runner
    Entry --> Logger
    Entry --> Timer

    Runner --> ProcessMgmt
    Runner --> ExitHandler
    Runner --> FuncWrapper

    Logger --> LogLevels
    Logger --> Journal
    Logger --> PrintModes

    Timer --> TimeTracker
    Timer --> PerfMetrics
    Timer -.-> Logger

    Runner -.-> Logger

    %% Styling
    classDef default fill:#blue,stroke:#333,stroke-width:2px
    classDef config fill:#yellow,stroke:#333,stroke-width:2px
    classDef process fill:#green,stroke:#333,stroke-width:2px
    classDef io fill:#gray,stroke:#333,stroke-width:2px
    classDef singleton fill:#purple,stroke:#333,stroke-width:2px

    class Runner,Timer,Entry default
    class Logger singleton
    class TSConfig,PackageConfig,LintConfig,StyleConfig,Pipeline config
    class ProcessMgmt,ExitHandler process
    class LogLevels,PrintModes,FuncWrapper,TimeTracker,PerfMetrics io
```
