# aksem/libavoid-js architecture

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

- Interactive diagram: https://gitdiagram.com/aksem/libavoid-js
- Repository: https://github.com/aksem/libavoid-js

## Overview

libavoid-js exposes the Libavoid diagram-routing engine to JavaScript through browser and Node entry points. A consumer initializes the wrapper, then uses the bound Router and geometry/connector APIs to configure objects, process routing transactions, and inspect routes. The README documents both runtimes; typings and WebIDL identify the major API domains. Generated binding and WebAssembly internals were not sampled, so their runtime linkage is shown as unverified rather than asserted.

Main entry points: [`src/index.js`](https://github.com/aksem/libavoid-js/blob/master/src/index.js) (Browser entry), [`src/index-node.mjs`](https://github.com/aksem/libavoid-js/blob/master/src/index-node.mjs) (Node entry), [`src/common.js`](https://github.com/aksem/libavoid-js/blob/master/src/common.js) (Shared loader), [`src/generated/libavoid.js`](https://github.com/aksem/libavoid-js/blob/master/src/generated/libavoid.js) (Web bindings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["JavaScript entrypoints"]
  node_browser["Browser entry<br/>[index.js]"]
  node_node["Node entry<br/>[index-node.mjs]"]
  node_loader["Shared loader<br/>[common.js]"]
end

subgraph group_binding["Wasm binding"]
  node_webbinding["Web bindings<br/>[libavoid.js]"]
  node_nodebinding["Node bindings<br/>[libavoid.mjs]"]
  node_wasm["Routing engine<br/>[libavoid.wasm]"]
end

subgraph group_routing["Routing API"]
  node_router["Router<br/>[router.idl]"]
  node_transaction["Routing transaction<br/>[libavoid.d.ts]"]
end

subgraph group_geometry["Geometry and connections"]
  node_geometry["Points and polygons<br/>[geometry.idl]"]
  node_obstacles["Shapes and obstacles<br/>[shape.idl]"]
  node_connectors["Endpoints and routes<br/>[connector.idl]"]
  node_junctions["Junctions and pins<br/>[junction.idl]"]
end

node_consumer(("Library consumer"))

node_consumer -->|"imports for web"| node_browser
node_consumer -->|"imports for Node"| node_node
node_browser -->|"creates wrapper"| node_loader
node_node -->|"creates wrapper"| node_loader
node_browser -->|"imports bindings"| node_webbinding
node_node -->|"imports bindings"| node_nodebinding
node_loader -->|"initializes module"| node_webbinding
node_webbinding -.->|"loads engine"| node_wasm
node_nodebinding -.->|"loads engine"| node_wasm
node_consumer -->|"configures routing"| node_router
node_consumer -->|"processes routes"| node_transaction
node_consumer -->|"creates geometry"| node_geometry
node_consumer -->|"defines obstacles"| node_obstacles
node_consumer -->|"sets endpoints"| node_connectors
node_consumer -->|"creates connections"| node_junctions

click node_browser "https://github.com/aksem/libavoid-js/blob/master/src/index.js"
click node_node "https://github.com/aksem/libavoid-js/blob/master/src/index-node.mjs"
click node_loader "https://github.com/aksem/libavoid-js/blob/master/src/common.js"
click node_webbinding "https://github.com/aksem/libavoid-js/blob/master/src/generated/libavoid.js"
click node_nodebinding "https://github.com/aksem/libavoid-js/blob/master/src/generated/libavoid.mjs"
click node_wasm "https://github.com/aksem/libavoid-js/blob/master/src/generated/libavoid.wasm"
click node_router "https://github.com/aksem/libavoid-js/blob/master/webidl_definitions/libavoid/router.idl"
click node_transaction "https://github.com/aksem/libavoid-js/blob/master/typings/libavoid.d.ts"
click node_geometry "https://github.com/aksem/libavoid-js/blob/master/webidl_definitions/libavoid/geometry.idl"
click node_obstacles "https://github.com/aksem/libavoid-js/blob/master/webidl_definitions/libavoid/shape.idl"
click node_connectors "https://github.com/aksem/libavoid-js/blob/master/webidl_definitions/libavoid/connector.idl"
click node_junctions "https://github.com/aksem/libavoid-js/blob/master/webidl_definitions/libavoid/junction.idl"

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_browser,node_node,node_loader toneBlue
class node_webbinding,node_nodebinding,node_wasm toneAmber
class node_router,node_transaction toneMint
class node_geometry,node_obstacles,node_connectors,node_junctions toneRose
class node_consumer toneIndigo
```

## Components

### JavaScript entrypoints

- [Browser entry](https://github.com/aksem/libavoid-js/blob/master/src/index.js): `src/index.js`
- [Node entry](https://github.com/aksem/libavoid-js/blob/master/src/index-node.mjs): `src/index-node.mjs`
- [Shared loader](https://github.com/aksem/libavoid-js/blob/master/src/common.js): `src/common.js`

### Wasm binding

- [Web bindings](https://github.com/aksem/libavoid-js/blob/master/src/generated/libavoid.js): `src/generated/libavoid.js`
- [Node bindings](https://github.com/aksem/libavoid-js/blob/master/src/generated/libavoid.mjs): `src/generated/libavoid.mjs`
- [Routing engine](https://github.com/aksem/libavoid-js/blob/master/src/generated/libavoid.wasm): `src/generated/libavoid.wasm`

### Routing API

- [Router](https://github.com/aksem/libavoid-js/blob/master/webidl_definitions/libavoid/router.idl): `webidl_definitions/libavoid/router.idl`
- [Routing transaction](https://github.com/aksem/libavoid-js/blob/master/typings/libavoid.d.ts): `typings/libavoid.d.ts`

### Geometry and connections

- [Points and polygons](https://github.com/aksem/libavoid-js/blob/master/webidl_definitions/libavoid/geometry.idl): `webidl_definitions/libavoid/geometry.idl`
- [Shapes and obstacles](https://github.com/aksem/libavoid-js/blob/master/webidl_definitions/libavoid/shape.idl): `webidl_definitions/libavoid/shape.idl`
- [Endpoints and routes](https://github.com/aksem/libavoid-js/blob/master/webidl_definitions/libavoid/connector.idl): `webidl_definitions/libavoid/connector.idl`
- [Junctions and pins](https://github.com/aksem/libavoid-js/blob/master/webidl_definitions/libavoid/junction.idl): `webidl_definitions/libavoid/junction.idl`

### Other components

- **Library consumer**

## Connections

- Library consumer → Browser entry: imports for web (evidence: `README.md`)
- Library consumer → Node entry: imports for Node (evidence: `README.md`)
- Browser entry → Shared loader: creates wrapper (evidence: `src/index.js`)
- Node entry → Shared loader: creates wrapper (evidence: `src/index-node.mjs`)
- Browser entry → Web bindings: imports bindings (evidence: `src/index.js`)
- Node entry → Node bindings: imports bindings (evidence: `src/index-node.mjs`)
- Shared loader → Web bindings: initializes module (evidence: `src/common.js`)
- Web bindings → Routing engine: loads engine
- Node bindings → Routing engine: loads engine
- Library consumer → Router: configures routing
- Library consumer → Routing transaction: processes routes (evidence: `typings/libavoid.d.ts`)
- Library consumer → Points and polygons: creates geometry
- Library consumer → Shapes and obstacles: defines obstacles
- Library consumer → Endpoints and routes: sets endpoints
- Library consumer → Junctions and pins: creates connections
