# hhacker1999/reload architecture

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

- Interactive diagram: https://gitdiagram.com/hhacker1999/reload
- Repository: https://github.com/hhacker1999/reload

## Overview

##### Main Components

A. File System Monitor
- Represents the file watching system
- Handles recursive directory monitoring
- Located in `internal/reload/files.go`

B. Build System
- Manages Go compilation process
- Handles binary management
- Found in `internal/reload/binary.go`

C. Runner System
- Controls process execution
- Manages application lifecycle
- Implemented in `internal/runner/runner.go`

D. Core Coordinator
- Orchestrates the reload process
- Main logic in `internal/reload/reload.go`

##### Component Relationships

**File System Monitor -> Core Coordinator -> Build System -> Runner System**
- ^                    |
- v
- User's Go App <-------- Binary

##### Detailed Component Breakdown

File System Monitor:
**┌─ File Watcher ─┐**
- CWD scanning │
- Change       │
- detection    │
- File filters │
- ┘

Build System:
**┌─ Builder ──────┐**
- Compilation  │
- Binary mgmt  │
- Error        │
- handling     │
- ┘

Runner System:
**┌─ Runner ───────┐**
- Process      │
- management   │
- Lifecycle    │
- control      │
- ┘

##### Additional Elements

A status indicator system showing:
- Active monitoring state
- Build status
- Running application state

##### Implementation Details to Highlight

- Error handling paths
- Binary preservation for fault tolerance
- File change detection mechanisms
- Process management flow

##### Notes for Implementation

- The tool's non-intrusive nature
- Fault tolerance mechanism
- Hot reload workflow
- Clear separation between the tool and user's application

This system design should clearly communicate how the tool achieves its primary goal of providing seamless hot reloading functionality for Go applications while maintaining fault tolerance and ease of use.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef file fill:#2ecc71,stroke:#27ae60,color:white
    classDef build fill:#e67e22,stroke:#d35400,color:white
    classDef user fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef process fill:#9b59b6,stroke:#8e44ad,color:white
    classDef init fill:#1abc9c,stroke:#16a085,color:white
    classDef cli fill:#34495e,stroke:#2c3e50,color:white

    %% Main Components
    EP["Entry Point"]:::core
    CC["Core Coordinator"]:::core
    FSM["File System Monitor"]:::file
    BS["Build System"]:::build
    RS["Runner System"]:::process
    POH["Process Output Handler"]:::process
    CLP["Command Line Parser"]:::cli
    IS["Initialization System"]:::init
    FCH["File Change Handler"]:::file

    %% User Application Components
    UA["User's Go App"]:::user
    BIN[("Binary")]:::build

    %% Relationships
    EP --> CLP
    CLP --> IS
    IS --> CC
    CC --> FSM
    CC --> BS
    CC --> RS
    FSM --> FCH
    FCH --> CC
    BS --> BIN
    BIN --> RS
    RS --> POH
    RS --> UA
    UA -.-> POH

    %% Click Events
    click FSM "https://github.com/hhacker1999/reload/blob/main/internal/reload/files.go"
    click BS "https://github.com/hhacker1999/reload/blob/main/internal/reload/binary.go"
    click RS "https://github.com/hhacker1999/reload/blob/main/internal/runner/runner.go"
    click CC "https://github.com/hhacker1999/reload/blob/main/internal/reload/reload.go"
    click POH "https://github.com/hhacker1999/reload/blob/main/pkg/capture/capture.go"
    click CLP "https://github.com/hhacker1999/reload/blob/main/internal/args/args.go"
    click IS "https://github.com/hhacker1999/reload/blob/main/internal/reload/initialise.go"
    click FCH "https://github.com/hhacker1999/reload/blob/main/internal/reload/reload_file.go"
    click EP "https://github.com/hhacker1999/reload/blob/main/cmd/server/main.go"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["File System Components"]:::file
        L3["Build Components"]:::build
        L4["User Components"]:::user
        L5["Process Components"]:::process
        L6["Initialization"]:::init
        L7["CLI Components"]:::cli
    end
```
