# zmactep/patinae architecture

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

- Interactive diagram: https://gitdiagram.com/zmactep/patinae
- Repository: https://github.com/zmactep/patinae

## Overview

Patinae is a GPU-first molecular viewer and toolkit for interactive research, structural analysis, scripting, and embedding. Its principal workflow is to load molecular structures, manipulate and analyze them through commands and selections, then display, inspect, and save the resulting scene or session. The repository separates molecular I/O, domain and scene state, command execution, analysis, rendering, and plugin integration, with native, Python, and web entry points. Several implementation details are not shown in the excerpts; links below rely on the README or explicit SOURCE INDEX references.

Main entry points: [`crates/patinae-cmd/src/executor.rs`](https://github.com/zmactep/patinae/blob/main/crates/patinae-cmd/src/executor.rs) (Command runtime), [`crates/patinae-plugin-host/src/host.rs`](https://github.com/zmactep/patinae/blob/main/crates/patinae-plugin-host/src/host.rs) (Plugin host), [`patinae/src/app.rs`](https://github.com/zmactep/patinae/blob/main/patinae/src/app.rs) (Desktop app), [`crates/patinae-io/src/traits.rs`](https://github.com/zmactep/patinae/blob/main/crates/patinae-io/src/traits.rs) (Structure I/O)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Core workflow"]
  node_commands["Command runtime<br/>[executor.rs]"]
  node_framework["Application kernel<br/>[kernel.rs]"]
  node_io["Structure I/O<br/>[traits.rs]"]
  node_formats["Format readers<br/>[parser.rs]"]
  node_sessions["Session interchange<br/>[prs.rs]"]
end

subgraph group_science["Molecular science"]
  node_molecule["Molecular model<br/>[molecule.rs]"]
  node_selection["Selection language<br/>[parser.rs]"]
  node_analysis["Structure analysis<br/>[kabsch.rs]"]
  node_symmetry["Crystal symmetry<br/>[crystal.rs]"]
  node_mechanics["Molecular mechanics<br/>[energy.rs]"]
end

subgraph group_visual["Scene and rendering"]
  node_scene["Scene session<br/>[session.rs]"]
  node_renderer["GPU renderer<br/>[context.rs]"]
end

subgraph group_extensions["Extensions"]
  node_pluginhost["Plugin host<br/>[host.rs]"]
  node_plugin_sdk["Plugin SDK<br/>[registrar.rs]"]
  node_raytracer["Raytracer plugin<br/>[pipeline.rs]"]
  node_ai["AI plugin<br/>[worker.rs]"]
end

subgraph group_clients["User interfaces"]
  node_native["Desktop app<br/>[app.rs]"]
  node_web["Web viewer<br/>[bridge.rs]"]
  node_python["Python API<br/>[lib.rs]"]
end

node_user(("Researcher"))

node_user -->|"uses"| node_native
node_user -->|"uses"| node_web
node_user -->|"scripts with"| node_python
node_native -->|"issues commands"| node_commands
node_commands -.->|"runs through"| node_framework
node_commands -->|"loads and saves"| node_io
node_io -->|"dispatches formats"| node_formats
node_formats -->|"parses structures"| node_molecule
node_commands -->|"evaluates selections"| node_selection
node_commands -->|"runs alignment"| node_analysis
node_commands -->|"expands symmetry"| node_symmetry
node_commands -.->|"uses mechanics"| node_mechanics
node_commands -.->|"changes scene"| node_scene
node_scene -->|"feeds viewport"| node_renderer
node_commands -->|"saves and loads"| node_sessions
node_native -->|"hosts plugins"| node_pluginhost
node_plugin_sdk -.->|"registers extensions"| node_pluginhost
node_pluginhost -->|"loads plugin"| node_raytracer
node_pluginhost -.->|"loads plugin"| node_ai

click node_native "https://github.com/zmactep/patinae/blob/main/patinae/src/app.rs"
click node_web "https://github.com/zmactep/patinae/blob/main/web/src/bridge.rs"
click node_python "https://github.com/zmactep/patinae/blob/main/python/src/lib.rs"
click node_commands "https://github.com/zmactep/patinae/blob/main/crates/patinae-cmd/src/executor.rs"
click node_framework "https://github.com/zmactep/patinae/blob/main/crates/patinae-framework/src/kernel.rs"
click node_io "https://github.com/zmactep/patinae/blob/main/crates/patinae-io/src/traits.rs"
click node_formats "https://github.com/zmactep/patinae/blob/main/crates/patinae-io/src/pdb/parser.rs"
click node_molecule "https://github.com/zmactep/patinae/blob/main/crates/patinae-mol/src/molecule.rs"
click node_selection "https://github.com/zmactep/patinae/blob/main/crates/patinae-select/src/parser.rs"
click node_analysis "https://github.com/zmactep/patinae/blob/main/crates/patinae-algos/src/align/kabsch.rs"
click node_symmetry "https://github.com/zmactep/patinae/blob/main/crates/patinae-algos/src/symmetry/crystal.rs"
click node_mechanics "https://github.com/zmactep/patinae/blob/main/crates/patinae-mm/src/energy.rs"
click node_scene "https://github.com/zmactep/patinae/blob/main/crates/patinae-scene/src/session.rs"
click node_renderer "https://github.com/zmactep/patinae/blob/main/crates/patinae-render/src/context.rs"
click node_sessions "https://github.com/zmactep/patinae/blob/main/crates/patinae-session/src/prs.rs"
click node_pluginhost "https://github.com/zmactep/patinae/blob/main/crates/patinae-plugin-host/src/host.rs"
click node_plugin_sdk "https://github.com/zmactep/patinae/blob/main/crates/patinae-plugin/src/registrar.rs"
click node_raytracer "https://github.com/zmactep/patinae/blob/main/plugins/raytracer/src/pipeline.rs"
click node_ai "https://github.com/zmactep/patinae/blob/main/plugins/ai/src/worker.rs"

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_commands,node_framework,node_io,node_formats,node_sessions toneBlue
class node_molecule,node_selection,node_analysis,node_symmetry,node_mechanics toneAmber
class node_scene,node_renderer toneMint
class node_pluginhost,node_plugin_sdk,node_raytracer,node_ai toneRose
class node_native,node_web,node_python,node_user toneIndigo
```

## Components

### Core workflow

- [Command runtime](https://github.com/zmactep/patinae/blob/main/crates/patinae-cmd/src/executor.rs): `crates/patinae-cmd/src/executor.rs`
- [Application kernel](https://github.com/zmactep/patinae/blob/main/crates/patinae-framework/src/kernel.rs): `crates/patinae-framework/src/kernel.rs`
- [Structure I/O](https://github.com/zmactep/patinae/blob/main/crates/patinae-io/src/traits.rs): `crates/patinae-io/src/traits.rs`
- [Format readers](https://github.com/zmactep/patinae/blob/main/crates/patinae-io/src/pdb/parser.rs): `crates/patinae-io/src/pdb/parser.rs`
- [Session interchange](https://github.com/zmactep/patinae/blob/main/crates/patinae-session/src/prs.rs): `crates/patinae-session/src/prs.rs`

### Molecular science

- [Molecular model](https://github.com/zmactep/patinae/blob/main/crates/patinae-mol/src/molecule.rs): `crates/patinae-mol/src/molecule.rs`
- [Selection language](https://github.com/zmactep/patinae/blob/main/crates/patinae-select/src/parser.rs): `crates/patinae-select/src/parser.rs`
- [Structure analysis](https://github.com/zmactep/patinae/blob/main/crates/patinae-algos/src/align/kabsch.rs): `crates/patinae-algos/src/align/kabsch.rs`
- [Crystal symmetry](https://github.com/zmactep/patinae/blob/main/crates/patinae-algos/src/symmetry/crystal.rs): `crates/patinae-algos/src/symmetry/crystal.rs`
- [Molecular mechanics](https://github.com/zmactep/patinae/blob/main/crates/patinae-mm/src/energy.rs): `crates/patinae-mm/src/energy.rs`

### Scene and rendering

- [Scene session](https://github.com/zmactep/patinae/blob/main/crates/patinae-scene/src/session.rs): `crates/patinae-scene/src/session.rs`
- [GPU renderer](https://github.com/zmactep/patinae/blob/main/crates/patinae-render/src/context.rs): `crates/patinae-render/src/context.rs`

### Extensions

- [Plugin host](https://github.com/zmactep/patinae/blob/main/crates/patinae-plugin-host/src/host.rs): `crates/patinae-plugin-host/src/host.rs`
- [Plugin SDK](https://github.com/zmactep/patinae/blob/main/crates/patinae-plugin/src/registrar.rs): `crates/patinae-plugin/src/registrar.rs`
- [Raytracer plugin](https://github.com/zmactep/patinae/blob/main/plugins/raytracer/src/pipeline.rs): `plugins/raytracer/src/pipeline.rs`
- [AI plugin](https://github.com/zmactep/patinae/blob/main/plugins/ai/src/worker.rs): `plugins/ai/src/worker.rs`

### User interfaces

- [Desktop app](https://github.com/zmactep/patinae/blob/main/patinae/src/app.rs): `patinae/src/app.rs`
- [Web viewer](https://github.com/zmactep/patinae/blob/main/web/src/bridge.rs): `web/src/bridge.rs`
- [Python API](https://github.com/zmactep/patinae/blob/main/python/src/lib.rs): `python/src/lib.rs`

### Other components

- **Researcher**

## Connections

- Researcher → Desktop app: uses (evidence: `README.md`)
- Researcher → Web viewer: uses (evidence: `README.md`)
- Researcher → Python API: scripts with (evidence: `README.md`)
- Desktop app → Command runtime: issues commands (evidence: `README.md`)
- Command runtime → Application kernel: runs through
- Command runtime → Structure I/O: loads and saves (evidence: `README.md`)
- Structure I/O → Format readers: dispatches formats (evidence: `crates/patinae-io/src/traits.rs`)
- Format readers → Molecular model: parses structures (evidence: `crates/patinae-io/src/pdb/parser.rs`)
- Command runtime → Selection language: evaluates selections (evidence: `README.md`)
- Command runtime → Structure analysis: runs alignment (evidence: `README.md`)
- Command runtime → Crystal symmetry: expands symmetry (evidence: `README.md`)
- Command runtime → Molecular mechanics: uses mechanics
- Command runtime → Scene session: changes scene
- Scene session → GPU renderer: feeds viewport (evidence: `README.md`)
- Command runtime → Session interchange: saves and loads (evidence: `README.md`)
- Desktop app → Plugin host: hosts plugins (evidence: `README.md`)
- Plugin SDK → Plugin host: registers extensions
- Plugin host → Raytracer plugin: loads plugin (evidence: `README.md`)
- Plugin host → AI plugin: loads plugin
