# opengeometry-io/opengeometry architecture

> Architecture diagram of the GitHub repository opengeometry-io/opengeometry, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/opengeometry-io/opengeometry
- Repository: https://github.com/opengeometry-io/opengeometry

## Overview

##### Project type and purpose
- This is a multi-package, cross-platform CAD Kernel library for the Web (“OpenGeometry”).
- The core is written in Rust (a CAD kernel with primitives, B-Rep, operations).
- There are multiple JavaScript/TypeScript bindings and render-integration packages: Three.js, Babylon.js, raw WebGL.
- Bundlers (Rollup, Vite) at the root build and package these modules for web consumption.

##### File structure
- Top-level:
- package.json, rollup.config.js, vite.config.js, tsconfig.json → configuration for building/publishing JS modules.
- main/opengeometry (Rust crate with Cargo.toml, source in src/) → core CAD kernel.
- main/opengeometry-three (TS wrapper targeting Three.js)
- main/opengeometry-babylon (TS wrapper targeting Babylon.js)
- main/opengeometry-webgl (TS wrapper with raw WebGL)
- test/index.html → simple test harness.
- Each “opengeometry-xxx” folder has its own package.json, source code, and likely imports the compiled WASM.

##### README for additional insights
- The library is under active development.
- Documentation and demos exist externally.
- It’s meant to be a drop-in CAD kernel with multiple rendering backends.

##### Elements
- from Rust Core → TS Binding (WASM import)
- from TS Binding → each integration package
- from each integration package → Bundler
- from Bundler → Web App (runtime).
- TS layers in another
- external engines (Three.js, Babylon.js, WebGL) in a third
- build tools in a fourth.

##### Detail
- Flow of artifacts (cargo build → .wasm/.js → npm publish → rollup input → browser bundle).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Compute Layer
    subgraph "Core Compute"
        Rust["Rust Core (WASM)"]:::core
    end
    Rust -->|"wasm-pack build"| TS["TS Glue (wasm-pack)"]:::ts

    %% Integration Packages Layer
    subgraph "Integration Packages"
        OG3["OpenGeometry-Three"]:::tsExt
        OGb["OpenGeometry-Babylon"]:::tsExt
        OGw["OpenGeometry-WebGL"]:::tsExt
    end
    TS -->|"imports websocket glue"| OG3
    TS -->|"imports websocket glue"| OGb
    TS -->|"imports websocket glue"| OGw

    %% Build Toolchain Layer
    subgraph "Build Tools"
        Rollup["Rollup Bundler"]:::build
        Vite["Vite Bundler"]:::build
    end
    OG3 -->|"input module"| Rollup
    OGb -->|"input module"| Rollup
    OGw -->|"input module"| Rollup
    OG3 -->|"input module"| Vite
    OGb -->|"input module"| Vite
    OGw -->|"input module"| Vite

    %% Configuration
    RootPkg["Monorepo Root Config"]:::config
    RootPkg -->|uses| Rollup
    RootPkg -->|uses| Vite
    RootPkg -->|defines TS config| TS

    %% Application Layer
    WebApp["Web App (test/index.html)"]:::app
    Rollup -->|"browser bundle"| WebApp
    Vite -->|"dev bundle"| WebApp

    %% Click Events
    click Rust "https://github.com/opengeometry-io/opengeometry/blob/main/main/opengeometry/Cargo.toml"
    click TS "https://github.com/opengeometry-io/opengeometry/blob/main/tsconfig.json"
    click OG3 "https://github.com/opengeometry-io/opengeometry/blob/main/main/opengeometry-three/index.ts"
    click OGb "https://github.com/opengeometry-io/opengeometry/blob/main/main/opengeometry-babylon/package.json"
    click OGw "https://github.com/opengeometry-io/opengeometry/blob/main/main/opengeometry-webgl/package.json"
    click Rollup "https://github.com/opengeometry-io/opengeometry/blob/main/rollup.config.js"
    click Vite "https://github.com/opengeometry-io/opengeometry/blob/main/vite.config.js"
    click RootPkg "https://github.com/opengeometry-io/opengeometry/blob/main/package.json"
    click WebApp "https://github.com/opengeometry-io/opengeometry/blob/main/test/index.html"

    %% Styles
    classDef core fill:#FDEBD0,stroke:#D35400,color:#000
    classDef ts fill:#D6EAF8,stroke:#2874A6,color:#000
    classDef tsExt fill:#AED6F1,stroke:#1B4F72,color:#000
    classDef build fill:#D5F5E3,stroke:#229954,color:#000
    classDef config fill:#E8DAEF,stroke:#8E44AD,color:#000
    classDef app fill:#F9E79F,stroke:#B7950B,color:#000
```
