# maddymadhesh77/hotreload architecture

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

- Interactive diagram: https://gitdiagram.com/maddymadhesh77/hotreload
- Repository: https://github.com/maddymadhesh77/hotreload

## Overview

hotreload is a Go CLI that watches a project, filters and debounces file changes, then rebuilds and restarts the configured server. Its CLI resolves explicit build/run settings or infers a runnable Go target; the engine owns the rebuild lifecycle and invokes the watcher, builder, and runner. The graph also preserves platform-specific process control. Relationships are based on the README and excerpted source; the demo server is an example application, not part of the hotreload runtime.

Main entry points: [`internal/engine/engine.go`](https://github.com/maddymadhesh77/hotreload/blob/main/internal/engine/engine.go) (Lifecycle engine), [`internal/watcher/watcher.go`](https://github.com/maddymadhesh77/hotreload/blob/main/internal/watcher/watcher.go) (Recursive watcher), [`internal/runner/runner.go`](https://github.com/maddymadhesh77/hotreload/blob/main/internal/runner/runner.go) (Server process manager), [`internal/builder/builder.go`](https://github.com/maddymadhesh77/hotreload/blob/main/internal/builder/builder.go) (Build command runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI configuration"]
  node_cli["CLI and target resolution<br/>[main.go]"]
end

subgraph group_watching["Change detection"]
  node_watcher["Recursive watcher<br/>[watcher.go]"]
  node_filter["Path filter<br/>[filter.go]"]
  node_debouncer["Event debouncer<br/>[debouncer.go]"]
end

subgraph group_lifecycle["Rebuild lifecycle"]
  node_engine["Lifecycle engine<br/>[engine.go]"]
  node_builder["Build command runner<br/>[builder.go]"]
  node_runner["Server process manager<br/>[runner.go]"]
end

subgraph group_process["Process management"]
  node_buildproc["Build process setup<br/>[process_unix.go]"]
  node_rununix["Unix process control<br/>[process_unix.go]"]
  node_runwindows["Windows process control<br/>[process_windows.go]"]
end

node_user(("Project developer"))

node_user -->|"edits watched files"| node_watcher
node_cli -->|"configures and starts"| node_engine
node_engine -->|"creates and starts"| node_watcher
node_watcher -->|"checks paths"| node_filter
node_watcher -->|"emits file events"| node_engine
node_engine -->|"triggers and receives"| node_debouncer
node_engine -->|"runs rebuilds"| node_builder
node_engine -->|"stops and starts server"| node_runner
node_builder -->|"sets process group"| node_buildproc
node_runner -->|"delegates process control"| node_rununix
node_runner -->|"delegates process control"| node_runwindows

click node_cli "https://github.com/maddymadhesh77/hotreload/blob/main/cmd/hotreload/main.go"
click node_engine "https://github.com/maddymadhesh77/hotreload/blob/main/internal/engine/engine.go"
click node_watcher "https://github.com/maddymadhesh77/hotreload/blob/main/internal/watcher/watcher.go"
click node_filter "https://github.com/maddymadhesh77/hotreload/blob/main/internal/filter/filter.go"
click node_debouncer "https://github.com/maddymadhesh77/hotreload/blob/main/internal/debouncer/debouncer.go"
click node_builder "https://github.com/maddymadhesh77/hotreload/blob/main/internal/builder/builder.go"
click node_buildproc "https://github.com/maddymadhesh77/hotreload/blob/main/internal/builder/process_unix.go"
click node_runner "https://github.com/maddymadhesh77/hotreload/blob/main/internal/runner/runner.go"
click node_rununix "https://github.com/maddymadhesh77/hotreload/blob/main/internal/runner/process_unix.go"
click node_runwindows "https://github.com/maddymadhesh77/hotreload/blob/main/internal/runner/process_windows.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli toneBlue
class node_watcher,node_filter,node_debouncer toneAmber
class node_engine,node_builder,node_runner toneMint
class node_buildproc,node_rununix,node_runwindows toneRose
class node_user toneIndigo
```

## Components

### CLI configuration

- [CLI and target resolution](https://github.com/maddymadhesh77/hotreload/blob/main/cmd/hotreload/main.go): `cmd/hotreload/main.go`

### Change detection

- [Recursive watcher](https://github.com/maddymadhesh77/hotreload/blob/main/internal/watcher/watcher.go): `internal/watcher/watcher.go`
- [Path filter](https://github.com/maddymadhesh77/hotreload/blob/main/internal/filter/filter.go): `internal/filter/filter.go`
- [Event debouncer](https://github.com/maddymadhesh77/hotreload/blob/main/internal/debouncer/debouncer.go): `internal/debouncer/debouncer.go`

### Rebuild lifecycle

- [Lifecycle engine](https://github.com/maddymadhesh77/hotreload/blob/main/internal/engine/engine.go): `internal/engine/engine.go`
- [Build command runner](https://github.com/maddymadhesh77/hotreload/blob/main/internal/builder/builder.go): `internal/builder/builder.go`
- [Server process manager](https://github.com/maddymadhesh77/hotreload/blob/main/internal/runner/runner.go): `internal/runner/runner.go`

### Process management

- [Build process setup](https://github.com/maddymadhesh77/hotreload/blob/main/internal/builder/process_unix.go): `internal/builder/process_unix.go`
- [Unix process control](https://github.com/maddymadhesh77/hotreload/blob/main/internal/runner/process_unix.go): `internal/runner/process_unix.go`
- [Windows process control](https://github.com/maddymadhesh77/hotreload/blob/main/internal/runner/process_windows.go): `internal/runner/process_windows.go`

### Other components

- **Project developer**

## Connections

- Project developer → Recursive watcher: edits watched files (evidence: `README.md`)
- CLI and target resolution → Lifecycle engine: configures and starts (evidence: `cmd/hotreload/main.go`)
- Lifecycle engine → Recursive watcher: creates and starts (evidence: `internal/engine/engine.go`)
- Recursive watcher → Path filter: checks paths (evidence: `internal/watcher/watcher.go`)
- Recursive watcher → Lifecycle engine: emits file events (evidence: `internal/engine/engine.go`)
- Lifecycle engine → Event debouncer: triggers and receives (evidence: `internal/engine/engine.go`)
- Lifecycle engine → Build command runner: runs rebuilds (evidence: `internal/engine/engine.go`)
- Lifecycle engine → Server process manager: stops and starts server (evidence: `internal/engine/engine.go`)
- Build command runner → Build process setup: sets process group (evidence: `internal/builder/builder.go`)
- Server process manager → Unix process control: delegates process control (evidence: `internal/runner/runner.go`)
- Server process manager → Windows process control: delegates process control (evidence: `internal/runner/runner.go`)
