# izure1/undoit architecture

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

- Interactive diagram: https://gitdiagram.com/izure1/undoit
- Repository: https://github.com/izure1/undoit

## Overview

Undoit is a small TypeScript undo/redo library. Callers submit actions to synchronous or asynchronous history managers; actions invoke paired do/undo callbacks, and the managers maintain undo and redo stacks. StateHistory wraps the synchronous manager to provide push/undo/redo over a value. The README also documents the asynchronous busy-state capability. Edges reflect the supplied source excerpts and README; no external service or persistent store is involved.

Main entry points: [`src/index.ts`](https://github.com/izure1/undoit/blob/master/src/index.ts) (Public exports), [`src/execute/UndoRedo.ts`](https://github.com/izure1/undoit/blob/master/src/execute/UndoRedo.ts) (Sync manager), [`src/execute/AsyncUndoRedo.ts`](https://github.com/izure1/undoit/blob/master/src/execute/AsyncUndoRedo.ts) (Async manager), [`src/helpers/StateHistory.ts`](https://github.com/izure1/undoit/blob/master/src/helpers/StateHistory.ts) (Value history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_actions["Action callbacks"]
  node_action["Sync action<br/>[Action.ts]"]
  node_async_action["Async action<br/>[AsyncAction.ts]"]
  node_action_base["Action callbacks<br/>[DefaultAction.ts]"]
end

subgraph group_history["Undo redo"]
  node_sync_history["Sync manager<br/>[UndoRedo.ts]"]
  node_async_history["Async manager<br/>[AsyncUndoRedo.ts]"]
  node_history_base["Stack storage<br/>[DefaultUndoRedo.ts]"]
end

subgraph group_state["State history"]
  node_state_history["Value history<br/>[StateHistory.ts]"]
end

node_caller(("Library caller"))
node_api["Public exports<br/>[index.ts]"]

node_caller -->|"imports API"| node_api
node_api -->|"exports"| node_action
node_api -->|"exports"| node_async_action
node_api -->|"exports"| node_sync_history
node_api -->|"exports"| node_async_history
node_api -->|"exports"| node_state_history
node_action -->|"extends"| node_action_base
node_async_action -->|"extends"| node_action_base
node_sync_history -->|"extends"| node_history_base
node_async_history -->|"extends"| node_history_base
node_sync_history -->|"executes callbacks"| node_action
node_async_history -->|"awaits callbacks"| node_async_action
node_state_history -->|"delegates history"| node_sync_history
node_state_history -->|"creates actions"| node_action
node_caller -->|"submits actions"| node_sync_history
node_caller -->|"submits async actions"| node_async_history
node_caller -->|"changes values"| node_state_history

click node_api "https://github.com/izure1/undoit/blob/master/src/index.ts"
click node_action "https://github.com/izure1/undoit/blob/master/src/action/Action.ts"
click node_async_action "https://github.com/izure1/undoit/blob/master/src/action/AsyncAction.ts"
click node_action_base "https://github.com/izure1/undoit/blob/master/src/action/DefaultAction.ts"
click node_sync_history "https://github.com/izure1/undoit/blob/master/src/execute/UndoRedo.ts"
click node_async_history "https://github.com/izure1/undoit/blob/master/src/execute/AsyncUndoRedo.ts"
click node_history_base "https://github.com/izure1/undoit/blob/master/src/execute/DefaultUndoRedo.ts"
click node_state_history "https://github.com/izure1/undoit/blob/master/src/helpers/StateHistory.ts"

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_action,node_async_action,node_action_base toneBlue
class node_sync_history,node_async_history,node_history_base toneAmber
class node_state_history toneMint
class node_caller toneIndigo
class node_api toneTeal
```

## Components

### Action callbacks

- [Sync action](https://github.com/izure1/undoit/blob/master/src/action/Action.ts): `src/action/Action.ts`
- [Async action](https://github.com/izure1/undoit/blob/master/src/action/AsyncAction.ts): `src/action/AsyncAction.ts`
- [Action callbacks](https://github.com/izure1/undoit/blob/master/src/action/DefaultAction.ts): `src/action/DefaultAction.ts`

### Undo redo

- [Sync manager](https://github.com/izure1/undoit/blob/master/src/execute/UndoRedo.ts): `src/execute/UndoRedo.ts`
- [Async manager](https://github.com/izure1/undoit/blob/master/src/execute/AsyncUndoRedo.ts): `src/execute/AsyncUndoRedo.ts`
- [Stack storage](https://github.com/izure1/undoit/blob/master/src/execute/DefaultUndoRedo.ts): `src/execute/DefaultUndoRedo.ts`

### State history

- [Value history](https://github.com/izure1/undoit/blob/master/src/helpers/StateHistory.ts): `src/helpers/StateHistory.ts`

### Other components

- **Library caller**
- [Public exports](https://github.com/izure1/undoit/blob/master/src/index.ts): `src/index.ts`

## Connections

- Library caller → Public exports: imports API (evidence: `README.md`)
- Public exports → Sync action: exports (evidence: `src/index.ts`)
- Public exports → Async action: exports (evidence: `src/index.ts`)
- Public exports → Sync manager: exports (evidence: `src/index.ts`)
- Public exports → Async manager: exports (evidence: `src/index.ts`)
- Public exports → Value history: exports (evidence: `src/index.ts`)
- Sync action → Action callbacks: extends (evidence: `src/action/Action.ts`)
- Async action → Action callbacks: extends (evidence: `src/action/AsyncAction.ts`)
- Sync manager → Stack storage: extends (evidence: `src/execute/UndoRedo.ts`)
- Async manager → Stack storage: extends (evidence: `src/execute/AsyncUndoRedo.ts`)
- Sync manager → Sync action: executes callbacks (evidence: `src/execute/UndoRedo.ts`)
- Async manager → Async action: awaits callbacks (evidence: `src/execute/AsyncUndoRedo.ts`)
- Value history → Sync manager: delegates history (evidence: `src/helpers/StateHistory.ts`)
- Value history → Sync action: creates actions (evidence: `src/helpers/StateHistory.ts`)
- Library caller → Sync manager: submits actions (evidence: `README.md`)
- Library caller → Async manager: submits async actions (evidence: `README.md`)
- Library caller → Value history: changes values (evidence: `README.md`)
