# livia-tassel/tensorv architecture

> Architecture diagram of the GitHub repository livia-tassel/tensorv, 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/livia-tassel/tensorv
- Repository: https://github.com/livia-tassel/tensorv

## Overview

TensorV is a PyTorch tensor-inspection workspace: users edit or load Python code, run it, select recorded statement snapshots, and inspect tensor values, layout, and statistics. The browser frontend sends execution and slice requests to either the local HTTP service or the VS Code host bridge; the Python engine records bounded snapshots and diagnoses shape errors. Sharing and examples support the workspace, while the VS Code extension adds interpreter selection and live source binding. Public execution adds a sandboxed service path. Some subsystem links are based on README documentation because their implementation excerpts were not provided.

Main entry points: [`src/main.js`](https://github.com/livia-tassel/tensorv/blob/main/src/main.js) (Workspace controller), [`tensorv/engine.py`](https://github.com/livia-tassel/tensorv/blob/main/tensorv/engine.py) (Execution and snapshots), [`extensions/vscode/extension.cjs`](https://github.com/livia-tassel/tensorv/blob/main/extensions/vscode/extension.cjs) (Extension host), [`src/sharing.js`](https://github.com/livia-tassel/tensorv/blob/main/src/sharing.js) (Experiment sharing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace UI"]
  node_workspace["Workspace controller<br/>[main.js]"]
  node_scripts["Script manager<br/>[scripts.js]"]
  node_layout["Workspace layout<br/>[layout.js]"]
  node_examples["Example library<br/>[examples.js]"]
  node_sharing["Experiment sharing<br/>[sharing.js]"]
  node_experiments["Experiment format<br/>[experiments.js]"]
end

subgraph group_analysis["Tensor analysis"]
  node_engine["Execution and snapshots<br/>[engine.py]"]
  node_slice["Tensor slice inspection<br/>[engine.py]"]
  node_shapecheck["Shape diagnostics<br/>[diagnostics.py]"]
  node_ui_diagnostics["Diagnostic rendering<br/>[diagnostics.js]"]
end

subgraph group_execution["Execution services"]
  node_local_server["Local HTTP service<br/>[server.py]"]
  node_public_server["Public service<br/>[public_server.py]"]
  node_sandbox["Sandbox runner<br/>[sandbox.py]"]
  node_sandbox_worker["Sandbox worker<br/>[sandbox_worker.py]"]
end

subgraph group_vscode["VS Code integration"]
  node_vscode_extension["Extension host<br/>[extension.cjs]"]
  node_bridge_client["Python bridge client<br/>[bridge-client.cjs]"]
  node_source_binding["Source binding<br/>[source-binding.cjs]"]
  node_python_bridge["Python bridge<br/>[bridge.py]"]
end

node_user(("User"))

node_user -->|"edits and runs"| node_workspace
node_workspace -->|"requests execution"| node_local_server
node_workspace -->|"manages scripts"| node_scripts
node_workspace -->|"renders workspace"| node_layout
node_workspace -->|"loads examples"| node_examples
node_workspace -->|"opens sharing"| node_sharing
node_sharing -->|"encodes documents"| node_experiments
node_workspace -->|"renders diagnostics"| node_ui_diagnostics
node_local_server -->|"dispatches execution"| node_engine
node_engine -->|"requests diagnosis"| node_shapecheck
node_workspace -->|"requests slices"| node_slice
node_user -->|"runs editor code"| node_vscode_extension
node_vscode_extension -->|"starts bridge"| node_bridge_client
node_bridge_client -.->|"sends requests"| node_python_bridge
node_python_bridge -->|"dispatches actions"| node_engine
node_vscode_extension -->|"binds source"| node_source_binding
node_user -->|"uses public workspace"| node_public_server
node_public_server -->|"runs isolated code"| node_sandbox
node_sandbox -.->|"starts worker"| node_sandbox_worker
node_sandbox_worker -->|"executes snippets"| node_engine

click node_workspace "https://github.com/livia-tassel/tensorv/blob/main/src/main.js"
click node_scripts "https://github.com/livia-tassel/tensorv/blob/main/src/scripts.js"
click node_layout "https://github.com/livia-tassel/tensorv/blob/main/src/layout.js"
click node_examples "https://github.com/livia-tassel/tensorv/blob/main/src/examples.js"
click node_sharing "https://github.com/livia-tassel/tensorv/blob/main/src/sharing.js"
click node_experiments "https://github.com/livia-tassel/tensorv/blob/main/src/experiments.js"
click node_engine "https://github.com/livia-tassel/tensorv/blob/main/tensorv/engine.py"
click node_slice "https://github.com/livia-tassel/tensorv/blob/main/tensorv/engine.py"
click node_shapecheck "https://github.com/livia-tassel/tensorv/blob/main/tensorv/diagnostics.py"
click node_ui_diagnostics "https://github.com/livia-tassel/tensorv/blob/main/src/diagnostics.js"
click node_local_server "https://github.com/livia-tassel/tensorv/blob/main/tensorv/server.py"
click node_public_server "https://github.com/livia-tassel/tensorv/blob/main/tensorv/public_server.py"
click node_sandbox "https://github.com/livia-tassel/tensorv/blob/main/tensorv/sandbox.py"
click node_sandbox_worker "https://github.com/livia-tassel/tensorv/blob/main/tensorv/sandbox_worker.py"
click node_vscode_extension "https://github.com/livia-tassel/tensorv/blob/main/extensions/vscode/extension.cjs"
click node_bridge_client "https://github.com/livia-tassel/tensorv/blob/main/extensions/vscode/lib/bridge-client.cjs"
click node_source_binding "https://github.com/livia-tassel/tensorv/blob/main/extensions/vscode/lib/source-binding.cjs"
click node_python_bridge "https://github.com/livia-tassel/tensorv/blob/main/tensorv/bridge.py"

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_workspace,node_scripts,node_layout,node_examples,node_sharing,node_experiments,node_user toneBlue
class node_engine,node_slice,node_shapecheck,node_ui_diagnostics toneAmber
class node_local_server,node_public_server,node_sandbox,node_sandbox_worker toneMint
class node_vscode_extension,node_bridge_client,node_source_binding,node_python_bridge toneRose
```

## Components

### Workspace UI

- [Workspace controller](https://github.com/livia-tassel/tensorv/blob/main/src/main.js): `src/main.js`
- [Script manager](https://github.com/livia-tassel/tensorv/blob/main/src/scripts.js): `src/scripts.js`
- [Workspace layout](https://github.com/livia-tassel/tensorv/blob/main/src/layout.js): `src/layout.js`
- [Example library](https://github.com/livia-tassel/tensorv/blob/main/src/examples.js): `src/examples.js`
- [Experiment sharing](https://github.com/livia-tassel/tensorv/blob/main/src/sharing.js): `src/sharing.js`
- [Experiment format](https://github.com/livia-tassel/tensorv/blob/main/src/experiments.js): `src/experiments.js`

### Tensor analysis

- [Execution and snapshots](https://github.com/livia-tassel/tensorv/blob/main/tensorv/engine.py): `tensorv/engine.py`
- [Tensor slice inspection](https://github.com/livia-tassel/tensorv/blob/main/tensorv/engine.py): `tensorv/engine.py`
- [Shape diagnostics](https://github.com/livia-tassel/tensorv/blob/main/tensorv/diagnostics.py): `tensorv/diagnostics.py`
- [Diagnostic rendering](https://github.com/livia-tassel/tensorv/blob/main/src/diagnostics.js): `src/diagnostics.js`

### Execution services

- [Local HTTP service](https://github.com/livia-tassel/tensorv/blob/main/tensorv/server.py): `tensorv/server.py`
- [Public service](https://github.com/livia-tassel/tensorv/blob/main/tensorv/public_server.py): `tensorv/public_server.py`
- [Sandbox runner](https://github.com/livia-tassel/tensorv/blob/main/tensorv/sandbox.py): `tensorv/sandbox.py`
- [Sandbox worker](https://github.com/livia-tassel/tensorv/blob/main/tensorv/sandbox_worker.py): `tensorv/sandbox_worker.py`

### VS Code integration

- [Extension host](https://github.com/livia-tassel/tensorv/blob/main/extensions/vscode/extension.cjs): `extensions/vscode/extension.cjs`
- [Python bridge client](https://github.com/livia-tassel/tensorv/blob/main/extensions/vscode/lib/bridge-client.cjs): `extensions/vscode/lib/bridge-client.cjs`
- [Source binding](https://github.com/livia-tassel/tensorv/blob/main/extensions/vscode/lib/source-binding.cjs): `extensions/vscode/lib/source-binding.cjs`
- [Python bridge](https://github.com/livia-tassel/tensorv/blob/main/tensorv/bridge.py): `tensorv/bridge.py`

### Other components

- **User**

## Connections

- User → Workspace controller: edits and runs (evidence: `README.md`)
- Workspace controller → Local HTTP service: requests execution (evidence: `src/main.js`)
- Workspace controller → Script manager: manages scripts (evidence: `src/main.js`)
- Workspace controller → Workspace layout: renders workspace (evidence: `src/main.js`)
- Workspace controller → Example library: loads examples (evidence: `src/main.js`)
- Workspace controller → Experiment sharing: opens sharing (evidence: `src/main.js`)
- Experiment sharing → Experiment format: encodes documents (evidence: `src/sharing.js`)
- Workspace controller → Diagnostic rendering: renders diagnostics (evidence: `src/main.js`)
- Local HTTP service → Execution and snapshots: dispatches execution (evidence: `tensorv/server.py`)
- Execution and snapshots → Shape diagnostics: requests diagnosis (evidence: `tensorv/engine.py`)
- Workspace controller → Tensor slice inspection: requests slices (evidence: `README.md`)
- User → Extension host: runs editor code (evidence: `README.md`)
- Extension host → Python bridge client: starts bridge (evidence: `extensions/vscode/extension.cjs`)
- Python bridge client → Python bridge: sends requests
- Python bridge → Execution and snapshots: dispatches actions (evidence: `tensorv/bridge.py`)
- Extension host → Source binding: binds source (evidence: `extensions/vscode/extension.cjs`)
- User → Public service: uses public workspace (evidence: `README.md`)
- Public service → Sandbox runner: runs isolated code (evidence: `tensorv/public_server.py`)
- Sandbox runner → Sandbox worker: starts worker
- Sandbox worker → Execution and snapshots: executes snippets (evidence: `tensorv/sandbox_worker.py`)
