# obsidiannnn/low_type architecture

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

- Interactive diagram: https://gitdiagram.com/obsidiannnn/low_type
- Repository: https://github.com/obsidiannnn/low_type

## Overview

LowType is a Ruby runtime type-expression gem: it interprets type annotations in method definitions and checks arguments and return values, with additional support for typed instance accessors, runtime local variables, enumerable and union syntax, and a Sinatra adapter. The main flow begins when a class includes LowType: it locates and parses the class’s source, evaluates annotations, then prepends wrappers that validate calls. The README documents capabilities whose implementation was not excerpted; those are represented where the tree supports a path, with uncertain links omitted.

Main entry points: [`lib/low_type.rb`](https://github.com/obsidiannnn/low_type/blob/main/lib/low_type.rb) (LowType entry), [`lib/definitions/evaluator.rb`](https://github.com/obsidiannnn/low_type/blob/main/lib/definitions/evaluator.rb) (Annotation evaluator), [`lib/definitions/redefiner.rb`](https://github.com/obsidiannnn/low_type/blob/main/lib/definitions/redefiner.rb) (Method wrappers), [`lib/expressions/type_expression.rb`](https://github.com/obsidiannnn/low_type/blob/main/lib/expressions/type_expression.rb) (Type expressions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Integration and setup"]
  node_lowtype["LowType entry<br/>[low_type.rb]"]
  node_file_query["Source lookup<br/>[file_query.rb]"]
  node_lowkey["Lowkey parser"]
  node_adapter_loader["Adapter loader<br/>[adapter_loader.rb]"]
  node_sinatra["Sinatra adapter<br/>[sinatra_adapter.rb]"]
end

subgraph group_expressions["Type expressions"]
  node_evaluator["Annotation evaluator<br/>[evaluator.rb]"]
  node_type_expr["Type expressions<br/>[type_expression.rb]"]
  node_value_expr["Value expressions"]
  node_expr_helpers["Expression helpers"]
  node_syntax["Enumerable syntax<br/>[syntax.rb]"]
  node_union_syntax["Union syntax<br/>[union_types.rb]"]
  node_type_query["Type recognition<br/>[type_query.rb]"]
end

subgraph group_checking["Runtime checking"]
  node_redefiner["Method wrappers<br/>[redefiner.rb]"]
  node_param_proxy["Parameter metadata<br/>[param_proxy.rb]"]
  node_return_proxy["Return metadata<br/>[return_proxy.rb]"]
  node_local_proxy["Local assignment proxy<br/>[local_proxy.rb]"]
  node_error_handling["Error reporting<br/>[error_handling.rb]"]
end

subgraph group_extensions["User-facing extensions"]
  node_type_accessors["Typed accessors<br/>[type_accessors.rb]"]
  node_complex_types["Complex type catalog<br/>[complex_types.rb]"]
  node_status["HTTP status types<br/>[status.rb]"]
end

node_ruby_class(("Including class"))

node_ruby_class -->|"includes"| node_lowtype
node_lowtype -->|"locates source"| node_file_query
node_lowtype -->|"loads source"| node_lowkey
node_lowtype -->|"evaluates annotations"| node_evaluator
node_lowtype -->|"adds helpers"| node_expr_helpers
node_lowtype -->|"adds accessors"| node_type_accessors
node_lowtype -->|"prepends wrappers"| node_redefiner
node_lowtype -->|"loads adapter"| node_adapter_loader
node_evaluator -->|"builds expressions"| node_type_expr
node_evaluator -->|"uses syntax"| node_syntax
node_evaluator -->|"uses types"| node_complex_types
node_evaluator -->|"uses status"| node_status
node_type_expr -->|"classifies types"| node_type_query
node_syntax -->|"classifies syntax"| node_type_query
node_redefiner -->|"unwraps values"| node_value_expr
node_redefiner -->|"validates arguments"| node_param_proxy
node_redefiner -->|"validates returns"| node_return_proxy
node_type_expr -->|"reports validation errors"| node_param_proxy
node_param_proxy -->|"formats errors"| node_error_handling
node_return_proxy -->|"formats errors"| node_error_handling
node_local_proxy -->|"formats errors"| node_error_handling
node_expr_helpers -->|"supports local typing"| node_local_proxy
node_lowtype -.->|"configures integration"| node_sinatra
node_sinatra -->|"checks route returns"| node_return_proxy
node_type_accessors -->|"uses annotations"| node_type_expr
node_complex_types -->|"includes status type"| node_status

click node_lowtype "https://github.com/obsidiannnn/low_type/blob/main/lib/low_type.rb"
click node_file_query "https://github.com/obsidiannnn/low_type/blob/main/lib/queries/file_query.rb"
click node_adapter_loader "https://github.com/obsidiannnn/low_type/blob/main/lib/adapters/adapter_loader.rb"
click node_sinatra "https://github.com/obsidiannnn/low_type/blob/main/lib/adapters/sinatra_adapter.rb"
click node_evaluator "https://github.com/obsidiannnn/low_type/blob/main/lib/definitions/evaluator.rb"
click node_type_expr "https://github.com/obsidiannnn/low_type/blob/main/lib/expressions/type_expression.rb"
click node_value_expr "https://github.com/obsidiannnn/low_type/blob/main/lib/expressions/value_expression.rb"
click node_expr_helpers "https://github.com/obsidiannnn/low_type/blob/main/lib/expressions/expression_helpers.rb"
click node_syntax "https://github.com/obsidiannnn/low_type/blob/main/lib/syntax/syntax.rb"
click node_union_syntax "https://github.com/obsidiannnn/low_type/blob/main/lib/syntax/union_types.rb"
click node_type_query "https://github.com/obsidiannnn/low_type/blob/main/lib/queries/type_query.rb"
click node_redefiner "https://github.com/obsidiannnn/low_type/blob/main/lib/definitions/redefiner.rb"
click node_param_proxy "https://github.com/obsidiannnn/low_type/blob/main/lib/proxies/param_proxy.rb"
click node_return_proxy "https://github.com/obsidiannnn/low_type/blob/main/lib/proxies/return_proxy.rb"
click node_local_proxy "https://github.com/obsidiannnn/low_type/blob/main/lib/proxies/local_proxy.rb"
click node_error_handling "https://github.com/obsidiannnn/low_type/blob/main/lib/interfaces/error_handling.rb"
click node_type_accessors "https://github.com/obsidiannnn/low_type/blob/main/lib/definitions/type_accessors.rb"
click node_complex_types "https://github.com/obsidiannnn/low_type/blob/main/lib/types/complex_types.rb"
click node_status "https://github.com/obsidiannnn/low_type/blob/main/lib/types/status.rb"

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_lowtype,node_file_query,node_lowkey,node_adapter_loader,node_sinatra toneBlue
class node_evaluator,node_type_expr,node_value_expr,node_expr_helpers,node_syntax,node_union_syntax,node_type_query toneAmber
class node_redefiner,node_param_proxy,node_return_proxy,node_local_proxy,node_error_handling toneMint
class node_type_accessors,node_complex_types,node_status toneRose
class node_ruby_class toneIndigo
```

## Components

### Integration and setup

- [LowType entry](https://github.com/obsidiannnn/low_type/blob/main/lib/low_type.rb): `lib/low_type.rb`
- [Source lookup](https://github.com/obsidiannnn/low_type/blob/main/lib/queries/file_query.rb): `lib/queries/file_query.rb`
- **Lowkey parser**
- [Adapter loader](https://github.com/obsidiannnn/low_type/blob/main/lib/adapters/adapter_loader.rb): `lib/adapters/adapter_loader.rb`
- [Sinatra adapter](https://github.com/obsidiannnn/low_type/blob/main/lib/adapters/sinatra_adapter.rb): `lib/adapters/sinatra_adapter.rb`

### Type expressions

- [Annotation evaluator](https://github.com/obsidiannnn/low_type/blob/main/lib/definitions/evaluator.rb): `lib/definitions/evaluator.rb`
- [Type expressions](https://github.com/obsidiannnn/low_type/blob/main/lib/expressions/type_expression.rb): `lib/expressions/type_expression.rb`
- [Value expressions](https://github.com/obsidiannnn/low_type/blob/main/lib/expressions/value_expression.rb): `lib/expressions/value_expression.rb`
- [Expression helpers](https://github.com/obsidiannnn/low_type/blob/main/lib/expressions/expression_helpers.rb): `lib/expressions/expression_helpers.rb`
- [Enumerable syntax](https://github.com/obsidiannnn/low_type/blob/main/lib/syntax/syntax.rb): `lib/syntax/syntax.rb`
- [Union syntax](https://github.com/obsidiannnn/low_type/blob/main/lib/syntax/union_types.rb): `lib/syntax/union_types.rb`
- [Type recognition](https://github.com/obsidiannnn/low_type/blob/main/lib/queries/type_query.rb): `lib/queries/type_query.rb`

### Runtime checking

- [Method wrappers](https://github.com/obsidiannnn/low_type/blob/main/lib/definitions/redefiner.rb): `lib/definitions/redefiner.rb`
- [Parameter metadata](https://github.com/obsidiannnn/low_type/blob/main/lib/proxies/param_proxy.rb): `lib/proxies/param_proxy.rb`
- [Return metadata](https://github.com/obsidiannnn/low_type/blob/main/lib/proxies/return_proxy.rb): `lib/proxies/return_proxy.rb`
- [Local assignment proxy](https://github.com/obsidiannnn/low_type/blob/main/lib/proxies/local_proxy.rb): `lib/proxies/local_proxy.rb`
- [Error reporting](https://github.com/obsidiannnn/low_type/blob/main/lib/interfaces/error_handling.rb): `lib/interfaces/error_handling.rb`

### User-facing extensions

- [Typed accessors](https://github.com/obsidiannnn/low_type/blob/main/lib/definitions/type_accessors.rb): `lib/definitions/type_accessors.rb`
- [Complex type catalog](https://github.com/obsidiannnn/low_type/blob/main/lib/types/complex_types.rb): `lib/types/complex_types.rb`
- [HTTP status types](https://github.com/obsidiannnn/low_type/blob/main/lib/types/status.rb): `lib/types/status.rb`

### Other components

- **Including class**

## Connections

- Including class → LowType entry: includes
- LowType entry → Source lookup: locates source (evidence: `lib/low_type.rb`)
- LowType entry → Lowkey parser: loads source (evidence: `lib/low_type.rb`)
- LowType entry → Annotation evaluator: evaluates annotations (evidence: `lib/low_type.rb`)
- LowType entry → Expression helpers: adds helpers (evidence: `lib/low_type.rb`)
- LowType entry → Typed accessors: adds accessors (evidence: `lib/low_type.rb`)
- LowType entry → Method wrappers: prepends wrappers (evidence: `lib/low_type.rb`)
- LowType entry → Adapter loader: loads adapter (evidence: `lib/low_type.rb`)
- Annotation evaluator → Type expressions: builds expressions (evidence: `lib/definitions/evaluator.rb`)
- Annotation evaluator → Enumerable syntax: uses syntax (evidence: `lib/definitions/evaluator.rb`)
- Annotation evaluator → Complex type catalog: uses types (evidence: `lib/definitions/evaluator.rb`)
- Annotation evaluator → HTTP status types: uses status (evidence: `lib/definitions/evaluator.rb`)
- Type expressions → Type recognition: classifies types (evidence: `lib/expressions/type_expression.rb`)
- Enumerable syntax → Type recognition: classifies syntax (evidence: `lib/syntax/syntax.rb`)
- Method wrappers → Value expressions: unwraps values (evidence: `lib/definitions/redefiner.rb`)
- Method wrappers → Parameter metadata: validates arguments (evidence: `lib/definitions/redefiner.rb`)
- Method wrappers → Return metadata: validates returns (evidence: `lib/definitions/redefiner.rb`)
- Type expressions → Parameter metadata: reports validation errors (evidence: `lib/expressions/type_expression.rb`)
- Parameter metadata → Error reporting: formats errors (evidence: `lib/proxies/param_proxy.rb`)
- Return metadata → Error reporting: formats errors (evidence: `lib/proxies/return_proxy.rb`)
- Local assignment proxy → Error reporting: formats errors (evidence: `lib/proxies/local_proxy.rb`)
- Expression helpers → Local assignment proxy: supports local typing (evidence: `lib/expressions/expression_helpers.rb`)
- LowType entry → Sinatra adapter: configures integration
- Sinatra adapter → Return metadata: checks route returns (evidence: `lib/adapters/sinatra_adapter.rb`)
- Typed accessors → Type expressions: uses annotations (evidence: `lib/definitions/type_accessors.rb`)
- Complex type catalog → HTTP status types: includes status type (evidence: `lib/types/complex_types.rb`)
