# soupuppy/eits architecture

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

- Interactive diagram: https://gitdiagram.com/soupuppy/eits
- Repository: https://github.com/soupuppy/eits

## Overview

EITS is a command-line REPL for a small HoTT/type-theory engine. A user enters commands through the REPL loop; command dispatch and built-in handlers provide definition, evaluation, type, context, and reset operations, while the engine parses expressions and maintains semantic context. The README also documents multiline editing and history. The graph preserves lexer, parser, syntax, runtime, and semantic stages; some links are documented or inferred because their implementation excerpts were not provided.

Main entry points: [`eits-hott/src/core/parser/parser.cpp`](https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/parser/parser.cpp) (Parser), [`eits-repl/src/main.cpp`](https://github.com/soupuppy/eits/blob/master/eits-repl/src/main.cpp) (REPL loop), [`eits-repl/src/repl/command_dispatch.cpp`](https://github.com/soupuppy/eits/blob/master/eits-repl/src/repl/command_dispatch.cpp) (Command dispatch), [`eits-hott/src/core/runtime/runtime.cpp`](https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/runtime/runtime.cpp) (Runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repl["REPL interface"]
  node_main["REPL loop<br/>[main.cpp]"]
  node_editor["Line editor<br/>[editor.cpp]"]
  node_history["Command history<br/>[history.cpp]"]
end

subgraph group_commands["Commands and state"]
  node_dispatch["Command dispatch"]
  node_registry["Command registry<br/>[registry.cpp]"]
  node_builtins["Built-in handlers"]
  node_editorcmd["Multiline editor<br/>[editor.cpp]"]
end

subgraph group_language["Language front end"]
  node_parser["Parser<br/>[parser.cpp]"]
  node_lexer["Lexer<br/>[lexer.cpp]"]
  node_strategies["Token strategies"]
  node_scanner["Character scanner<br/>[scanner.h]"]
  node_tokens["Tokens<br/>[token.h]"]
end

subgraph group_kernel["Type theory kernel"]
  node_runtime["Runtime<br/>[runtime.cpp]"]
  node_syntax["Expression syntax"]
  node_terms["Term forms<br/>[term.h]"]
  node_types["Type forms"]
  node_context["Semantic context<br/>[context.cpp]"]
  node_typecheck["Type checking<br/>[typecheck.cpp]"]
  node_evaluation["Evaluation and reduction"]
  node_display["Expression display<br/>[display.h]"]
end

node_user(("REPL user"))

node_user -->|"enters commands"| node_main
node_main -->|"reads lines"| node_editor
node_main -->|"gets prompt ID"| node_history
node_main -->|"dispatches input"| node_dispatch
node_dispatch -->|"looks up command"| node_registry
node_registry -.->|"registers handlers"| node_builtins
node_dispatch -->|"launches edit"| node_editorcmd
node_dispatch -.->|"records commands"| node_history
node_builtins -.->|"runs engine commands"| node_runtime
node_runtime -.->|"maintains context"| node_context
node_runtime -.->|"parses expressions"| node_parser
node_parser -->|"requests tokens"| node_lexer
node_lexer -->|"resolves lexemes"| node_strategies
node_strategies -->|"scans characters"| node_scanner
node_lexer -->|"produces tokens"| node_tokens
node_parser -->|"consumes tokens"| node_tokens
node_parser -->|"constructs expressions"| node_syntax
node_syntax -->|"contains term variants"| node_terms
node_syntax -->|"contains type variants"| node_types
node_parser -->|"checks annotations"| node_typecheck
node_typecheck -->|"looks up bindings"| node_context
node_runtime -.->|"evaluates terms"| node_evaluation
node_builtins -.->|"shows results"| node_display

click node_main "https://github.com/soupuppy/eits/blob/master/eits-repl/src/main.cpp"
click node_editor "https://github.com/soupuppy/eits/blob/master/eits-repl/src/editor/editor.cpp"
click node_history "https://github.com/soupuppy/eits/blob/master/eits-repl/src/history/history.cpp"
click node_dispatch "https://github.com/soupuppy/eits/blob/master/eits-repl/src/repl/command_dispatch.cpp"
click node_registry "https://github.com/soupuppy/eits/blob/master/eits-repl/src/registry/registry.cpp"
click node_builtins "https://github.com/soupuppy/eits/tree/master/eits-repl/src/registry/builtin"
click node_editorcmd "https://github.com/soupuppy/eits/blob/master/eits-repl/src/editor/editor.cpp"
click node_runtime "https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/runtime/runtime.cpp"
click node_parser "https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/parser/parser.cpp"
click node_lexer "https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/parser/lexer/lexer.cpp"
click node_strategies "https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/parser/lexer/stratagy_manager.cpp"
click node_scanner "https://github.com/soupuppy/eits/blob/master/eits-hott/include/HoTT/core/parser/lexer/scanner.h"
click node_tokens "https://github.com/soupuppy/eits/blob/master/eits-hott/include/HoTT/core/parser/lexer/token.h"
click node_syntax "https://github.com/soupuppy/eits/tree/master/eits-hott/src/core/syntax/expression"
click node_terms "https://github.com/soupuppy/eits/blob/master/eits-hott/include/HoTT/core/syntax/expression/term.h"
click node_types "https://github.com/soupuppy/eits/tree/master/eits-hott/src/core/syntax/expression/type"
click node_context "https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/runtime/context.cpp"
click node_typecheck "https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/semantics/typecheck.cpp"
click node_evaluation "https://github.com/soupuppy/eits/tree/master/eits-hott/src/core/semantics"
click node_display "https://github.com/soupuppy/eits/blob/master/eits-hott/src/internal/display/display.h"

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_main,node_editor,node_history,node_user toneBlue
class node_dispatch,node_registry,node_builtins,node_editorcmd toneAmber
class node_parser,node_lexer,node_strategies,node_scanner,node_tokens toneMint
class node_runtime,node_syntax,node_terms,node_types,node_context,node_typecheck,node_evaluation,node_display toneRose
```

## Components

### REPL interface

- [REPL loop](https://github.com/soupuppy/eits/blob/master/eits-repl/src/main.cpp): `eits-repl/src/main.cpp`
- [Line editor](https://github.com/soupuppy/eits/blob/master/eits-repl/src/editor/editor.cpp): `eits-repl/src/editor/editor.cpp`
- [Command history](https://github.com/soupuppy/eits/blob/master/eits-repl/src/history/history.cpp): `eits-repl/src/history/history.cpp`

### Commands and state

- [Command dispatch](https://github.com/soupuppy/eits/blob/master/eits-repl/src/repl/command_dispatch.cpp): `eits-repl/src/repl/command_dispatch.cpp`
- [Command registry](https://github.com/soupuppy/eits/blob/master/eits-repl/src/registry/registry.cpp): `eits-repl/src/registry/registry.cpp`
- [Built-in handlers](https://github.com/soupuppy/eits/tree/master/eits-repl/src/registry/builtin): `eits-repl/src/registry/builtin`
- [Multiline editor](https://github.com/soupuppy/eits/blob/master/eits-repl/src/editor/editor.cpp): `eits-repl/src/editor/editor.cpp`

### Language front end

- [Parser](https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/parser/parser.cpp): `eits-hott/src/core/parser/parser.cpp`
- [Lexer](https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/parser/lexer/lexer.cpp): `eits-hott/src/core/parser/lexer/lexer.cpp`
- [Token strategies](https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/parser/lexer/stratagy_manager.cpp): `eits-hott/src/core/parser/lexer/stratagy_manager.cpp`
- [Character scanner](https://github.com/soupuppy/eits/blob/master/eits-hott/include/HoTT/core/parser/lexer/scanner.h): `eits-hott/include/HoTT/core/parser/lexer/scanner.h`
- [Tokens](https://github.com/soupuppy/eits/blob/master/eits-hott/include/HoTT/core/parser/lexer/token.h): `eits-hott/include/HoTT/core/parser/lexer/token.h`

### Type theory kernel

- [Runtime](https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/runtime/runtime.cpp): `eits-hott/src/core/runtime/runtime.cpp`
- [Expression syntax](https://github.com/soupuppy/eits/tree/master/eits-hott/src/core/syntax/expression): `eits-hott/src/core/syntax/expression`
- [Term forms](https://github.com/soupuppy/eits/blob/master/eits-hott/include/HoTT/core/syntax/expression/term.h): `eits-hott/include/HoTT/core/syntax/expression/term.h`
- [Type forms](https://github.com/soupuppy/eits/tree/master/eits-hott/src/core/syntax/expression/type): `eits-hott/src/core/syntax/expression/type`
- [Semantic context](https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/runtime/context.cpp): `eits-hott/src/core/runtime/context.cpp`
- [Type checking](https://github.com/soupuppy/eits/blob/master/eits-hott/src/core/semantics/typecheck.cpp): `eits-hott/src/core/semantics/typecheck.cpp`
- [Evaluation and reduction](https://github.com/soupuppy/eits/tree/master/eits-hott/src/core/semantics): `eits-hott/src/core/semantics`
- [Expression display](https://github.com/soupuppy/eits/blob/master/eits-hott/src/internal/display/display.h): `eits-hott/src/internal/display/display.h`

### Other components

- **REPL user**

## Connections

- REPL user → REPL loop: enters commands
- REPL loop → Line editor: reads lines (evidence: `eits-repl/src/main.cpp`)
- REPL loop → Command history: gets prompt ID (evidence: `eits-repl/src/main.cpp`)
- REPL loop → Command dispatch: dispatches input (evidence: `eits-repl/src/main.cpp`)
- Command dispatch → Command registry: looks up command (evidence: `eits-repl/src/repl/command_dispatch.cpp`)
- Command registry → Built-in handlers: registers handlers
- Command dispatch → Multiline editor: launches edit (evidence: `eits-repl/src/repl/command_dispatch.cpp`)
- Command dispatch → Command history: records commands
- Built-in handlers → Runtime: runs engine commands
- Runtime → Semantic context: maintains context
- Runtime → Parser: parses expressions
- Parser → Lexer: requests tokens (evidence: `eits-hott/src/core/parser/parser.cpp`)
- Lexer → Token strategies: resolves lexemes (evidence: `eits-hott/src/core/parser/lexer/stratagy_manager.cpp`)
- Token strategies → Character scanner: scans characters (evidence: `eits-hott/src/core/parser/lexer/stratagy_manager.cpp`)
- Lexer → Tokens: produces tokens
- Parser → Tokens: consumes tokens (evidence: `eits-hott/src/core/parser/parser.cpp`)
- Parser → Expression syntax: constructs expressions (evidence: `eits-hott/src/core/parser/parser.cpp`)
- Expression syntax → Term forms: contains term variants
- Expression syntax → Type forms: contains type variants
- Parser → Type checking: checks annotations (evidence: `eits-hott/src/core/parser/parser.cpp`)
- Type checking → Semantic context: looks up bindings
- Runtime → Evaluation and reduction: evaluates terms
- Built-in handlers → Expression display: shows results
