# norhan1995/impactgate architecture

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

- Interactive diagram: https://gitdiagram.com/norhan1995/impactgate
- Repository: https://github.com/norhan1995/impactgate

## Overview

ImpactGate turns a proposed destructive workspace action into a reviewable, guarded transaction: a human inspects a simulation, may adjust scope or reject it, and approved actions are checked against live state before execution. The backend persists simulations, outcomes, snapshots, and audit entries; the engine supplies the simulation, preflight, delete, and rollback logic. The UI excerpt is partial, so specific client wiring beyond its state refresh and the documented workflow is not inferred.

Main entry points: [`backend/local-server.mjs`](https://github.com/norhan1995/impactgate/blob/main/backend/local-server.mjs) (HTTP API), [`src/App.tsx`](https://github.com/norhan1995/impactgate/blob/main/src/App.tsx) (ImpactGate UI), [`core/engine.mjs`](https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs) (Blast-radius simulation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Review workflow"]
  node_ui["ImpactGate UI<br/>[App.tsx]"]
  node_intent["Action intent<br/>[App.tsx]"]
  node_preview["Effects and diff<br/>[App.tsx]"]
  node_decision["Approve, tweak, reject<br/>[App.tsx]"]
  node_outcome["Commit or block<br/>[App.tsx]"]
end

subgraph group_service["API and persistence"]
  node_api["HTTP API<br/>[local-server.mjs]"]
  node_store[("Persisted demo state<br/>[local-server.mjs]")]
  node_audit["Audit trail<br/>[local-server.mjs]"]
end

subgraph group_safety["Safety engine"]
  node_simulation["Blast-radius simulation<br/>[engine.mjs]"]
  node_fingerprint["State fingerprint<br/>[engine.mjs]"]
  node_preflight["Authoritative preflight<br/>[engine.mjs]"]
  node_delete["Workspace deletion<br/>[engine.mjs]"]
  node_snapshot["Rollback snapshot<br/>[engine.mjs]"]
  node_rollback["Rollback restore<br/>[engine.mjs]"]
end

node_agent(("Agent"))
node_human(("Human reviewer"))

node_agent -->|"proposes"| node_intent
node_intent -->|"enters intent"| node_ui
node_ui -->|"requests state"| node_api
node_api -->|"reads state"| node_store
node_store -->|"returns state"| node_api
node_ui -->|"requests simulation"| node_api
node_api -->|"calls simulate"| node_simulation
node_simulation -->|"computes fingerprint"| node_fingerprint
node_api -->|"saves simulation"| node_store
node_simulation -->|"returns effects"| node_preview
node_preview -->|"presents diff"| node_human
node_human -->|"decides scope"| node_decision
node_decision -->|"rejects or approves"| node_api
node_api -->|"loads simulation"| node_store
node_api -->|"calls execute"| node_delete
node_delete -->|"checks live state"| node_preflight
node_preflight -->|"recomputes fingerprint"| node_fingerprint
node_delete -->|"captures before delete"| node_snapshot
node_api -->|"saves outcome"| node_store
node_api -->|"records decision"| node_audit
node_api -->|"returns result"| node_outcome
node_outcome -->|"shows result"| node_human
node_ui -->|"requests rollback"| node_api
node_api -->|"calls restore"| node_rollback
node_rollback -->|"reads snapshot"| node_snapshot
node_api -->|"saves restored state"| node_store

click node_ui "https://github.com/norhan1995/impactgate/blob/main/src/App.tsx"
click node_intent "https://github.com/norhan1995/impactgate/blob/main/src/App.tsx"
click node_preview "https://github.com/norhan1995/impactgate/blob/main/src/App.tsx"
click node_decision "https://github.com/norhan1995/impactgate/blob/main/src/App.tsx"
click node_outcome "https://github.com/norhan1995/impactgate/blob/main/src/App.tsx"
click node_api "https://github.com/norhan1995/impactgate/blob/main/backend/local-server.mjs"
click node_store "https://github.com/norhan1995/impactgate/blob/main/backend/local-server.mjs"
click node_audit "https://github.com/norhan1995/impactgate/blob/main/backend/local-server.mjs"
click node_simulation "https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs"
click node_fingerprint "https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs"
click node_preflight "https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs"
click node_delete "https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs"
click node_snapshot "https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs"
click node_rollback "https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs"

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_ui,node_intent,node_preview,node_decision,node_outcome,node_human toneBlue
class node_api,node_store,node_audit toneAmber
class node_simulation,node_fingerprint,node_preflight,node_delete,node_snapshot,node_rollback toneMint
class node_agent toneIndigo
```

## Components

### Review workflow

- [ImpactGate UI](https://github.com/norhan1995/impactgate/blob/main/src/App.tsx): `src/App.tsx`
- [Action intent](https://github.com/norhan1995/impactgate/blob/main/src/App.tsx): `src/App.tsx`
- [Effects and diff](https://github.com/norhan1995/impactgate/blob/main/src/App.tsx): `src/App.tsx`
- [Approve, tweak, reject](https://github.com/norhan1995/impactgate/blob/main/src/App.tsx): `src/App.tsx`
- [Commit or block](https://github.com/norhan1995/impactgate/blob/main/src/App.tsx): `src/App.tsx`

### API and persistence

- [HTTP API](https://github.com/norhan1995/impactgate/blob/main/backend/local-server.mjs): `backend/local-server.mjs`
- [Persisted demo state](https://github.com/norhan1995/impactgate/blob/main/backend/local-server.mjs): `backend/local-server.mjs`
- [Audit trail](https://github.com/norhan1995/impactgate/blob/main/backend/local-server.mjs): `backend/local-server.mjs`

### Safety engine

- [Blast-radius simulation](https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs): `core/engine.mjs`
- [State fingerprint](https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs): `core/engine.mjs`
- [Authoritative preflight](https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs): `core/engine.mjs`
- [Workspace deletion](https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs): `core/engine.mjs`
- [Rollback snapshot](https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs): `core/engine.mjs`
- [Rollback restore](https://github.com/norhan1995/impactgate/blob/main/core/engine.mjs): `core/engine.mjs`

### Other components

- **Agent**
- **Human reviewer**

## Connections

- Agent → Action intent: proposes
- Action intent → ImpactGate UI: enters intent
- ImpactGate UI → HTTP API: requests state
- HTTP API → Persisted demo state: reads state
- Persisted demo state → HTTP API: returns state
- ImpactGate UI → HTTP API: requests simulation
- HTTP API → Blast-radius simulation: calls simulate
- Blast-radius simulation → State fingerprint: computes fingerprint
- HTTP API → Persisted demo state: saves simulation
- Blast-radius simulation → Effects and diff: returns effects
- Effects and diff → Human reviewer: presents diff
- Human reviewer → Approve, tweak, reject: decides scope
- Approve, tweak, reject → HTTP API: rejects or approves
- HTTP API → Persisted demo state: loads simulation
- HTTP API → Workspace deletion: calls execute
- Workspace deletion → Authoritative preflight: checks live state
- Authoritative preflight → State fingerprint: recomputes fingerprint
- Workspace deletion → Rollback snapshot: captures before delete
- HTTP API → Persisted demo state: saves outcome
- HTTP API → Audit trail: records decision
- HTTP API → Commit or block: returns result
- Commit or block → Human reviewer: shows result
- ImpactGate UI → HTTP API: requests rollback
- HTTP API → Rollback restore: calls restore
- Rollback restore → Rollback snapshot: reads snapshot
- HTTP API → Persisted demo state: saves restored state
