# red1oon/bim-ootb architecture

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

- Interactive diagram: https://gitdiagram.com/red1oon/bim-ootb
- Repository: https://github.com/red1oon/bim-ootb

## Overview

#### Purpose and Entry Points
BIM OOTB is a static, browser-native BIM + ERP platform: IFC/model data is queried, rendered, scheduled, costed, and linked to an event-sourced ERP without an application server. Primary entry points are the gallery/import landing page (`index.html`), launcher (`index2.html`), BIM viewer (`viewer/viewer.html`), DAGeVu BIM authoring surface (`modeller/modeller.html`), and ERP clients (`erp/erp.html`, `erp/idempiere.html`).

#### BIM Viewer Runtime
The viewer bootstraps a Three.js scene, camera, picking, panels, and navigation, then loads model/database-backed geometry. Core orchestration and rendering are in `viewer/main.js`, `viewer/scene.js`, and `viewer/streaming.js`. The viewer is primarily read-oriented: it turns BIM SQLite rows and IFC-derived assets into streamed meshes, selectable scene objects, and analysis/UI state.

#### Model Data and Import Boundary
BIM state is represented by SQLite model databases, including committed sample databases and SQL patch sets (`modeller/Duplex_extracted.db`, `buildings/patches/Clinic_extracted.db.sql`, `viewer/schema_5table.sql`). Remote building databases are range-read through HTTP VFS; imported IFC/mesh work occurs in workers and is persisted locally. The import boundary is `viewer/import.js`, `viewer/import_worker.js`, and `viewer/import_db_builder.js`; IFC parsing uses bundled web-ifc (`viewer/lib/web-ifc.wasm`).

#### BIM Analysis and Planning
The viewer derives BOM, quantities, costs, schedules, clashes, and construction playback from model data. BOM logic resides in `viewer/bom_engine/bom_tree.js`, `viewer/bom_extract.js`, and `viewer/bom_walker.js`. Scheduling is authored, computed, and synchronized through `viewer/schedule_engine.js`, `viewer/schedule_author.js`, and `viewer/cpm_schedule.js`. Cost/rate computation uses `viewer/rates.js`, country templates such as `viewer/rates/rsmeans2024_us.json`, and 4D/5D exports. Clash and coordination functions center on `viewer/measure.js` and `viewer/mep_coordination.js`.

#### DAGeVu Authoring
DAGeVu is a separate authoring surface that treats a signed operation log as the feature tree and deterministically folds operations into geometry. The UI/runtime entry is `modeller/modeller.html`; authoring kernel coordination is `modeller/bonsai_kernel.js` with worker execution in `modeller/bonsai_kernel_worker.js`. It uses OpenCascade WASM (`modeller/lib/kernel/occt-wasm.wasm`) and a Planegcs constraint solver (`modeller/lib/planegcs/planegcs.wasm`) for B-rep, sketch, grid, and component/assembly workflows.

#### Kernel-ERP
Kernel-ERP renders an Application Dictionary over SQLite WASM, but operational truth is replayed from signed events rather than mutable application records. The fold/runtime is `erp/erp_kernel.js`; verbs are defined in `erp/kernel_ops.js`; ledger signing is in `erp/erp_signer.js`. The AD UI renderer is `erp/ad_ui.js`, and rule/lifecycle validation is a data-driven fold in `erp/rule_fold.js`. ERP document processes are deterministic derivations in `erp/ad_process.js`. Exact monetary arithmetic relies on `erp/bigdecimal.js`.

#### Shared Op-Log and Cross-Surface Context
The principal integration boundary is the shared signed op-log: BIM edits, ERP facts, and reversible history are folded independently by their respective surfaces. Cross-surface selection, timeline, and identity propagation is implemented by `viewer/connect_scene.js`; common history primitives are in `common/history_bar.js` and `common/whole_history.js`. Teams extends this into branch/presence/replay collaboration via `teams/engine.js`, `teams/protocol.js`, and `teams/transport.js`.

#### Infrastructure and Delivery
This is vanilla JavaScript served as static files: no framework, build server, or required backend. GitHub Pages is deployed by `.github/workflows/deploy-pages.yml`; CI/release automation is under `.github/workflows/ci.yml` and `.github/workflows/release-please.yml`. OCI Object Storage hosts large building DBs externally. Offline operation is provided by service workers (`viewer/sw.js`, `erp/sw.js`), IndexedDB, Web Workers, and browser-native BroadcastChannel. Major browser/WASM dependencies include Three.js, sql.js/SQLite, HTTP VFS, web-ifc, OpenCascade, and Planegcs.

Main entry points: [`common/whole_history.js`](https://github.com/red1oon/bim-ootb/blob/main/common/whole_history.js) (Signed op-log), [`.github/workflows/deploy-pages.yml`](https://github.com/red1oon/bim-ootb/blob/main/.github/workflows/deploy-pages.yml) (Static Pages delivery), [`viewer/main.js`](https://github.com/red1oon/bim-ootb/blob/main/viewer/main.js) (Scene runtime), [`viewer/viewer.html`](https://github.com/red1oon/bim-ootb/blob/main/viewer/viewer.html) (Viewer entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_viewer["BIM Viewer"]
  node_viewer_entry["Viewer entry<br/>static entry<br/>[viewer.html]"]
  node_viewer_runtime["Scene runtime<br/>Three.js runtime<br/>[main.js]"]
  node_geometry_streaming["Geometry streaming<br/>mesh loader<br/>[streaming.js]"]
  node_model_databases[("BIM model databases<br/>SQLite data")]
  node_import_pipeline["IFC import pipeline<br/>worker pipeline<br/>[import.js]"]
  node_bim_analysis["BOM &amp; planning<br/>analysis engine<br/>[bom_extract.js]"]
  node_cross_surface_context["Cross-surface context<br/>selection bridge<br/>[connect_scene.js]"]
end

subgraph group_authoring["DAGeVu Authoring"]
  node_modeller_entry["DAGeVu entry<br/>static entry<br/>[modeller.html]"]
  node_authoring_kernel["Feature-tree kernel<br/>authoring runtime<br/>[bonsai_kernel.js]"]
  node_kernel_worker["Geometry kernel worker<br/>WASM worker"]
end

subgraph group_erp["Kernel-ERP"]
  node_erp_entry["ERP client entry<br/>static entry<br/>[erp.html]"]
  node_erp_fold["ERP event fold<br/>event-sourced runtime<br/>[erp_kernel.js]"]
  node_erp_verbs["ERP verbs &amp; rules<br/>domain fold<br/>[kernel_ops.js]"]
  node_ad_ui["Application Dictionary UI<br/>SQLite WASM UI<br/>[ad_ui.js]"]
end

subgraph group_shared["Shared History &amp; Teams"]
  node_signed_oplog[("Signed op-log<br/>shared event ledger<br/>[whole_history.js]")]
  node_history_ui["History controls<br/>shared UI<br/>[history_bar.js]"]
  node_teams["Teams collaboration<br/>collaboration engine<br/>[engine.js]"]
end

node_gallery["Gallery &amp; import landing<br/>static entry<br/>[index.html]"]
node_launcher["Surface launcher<br/>static entry<br/>[index2.html]"]
node_static_delivery{{"Static Pages delivery<br/>deployment<br/>[deploy-pages.yml]"}}

node_gallery -->|"opens"| node_viewer_entry
node_launcher -->|"launches"| node_viewer_entry
node_launcher -->|"launches"| node_modeller_entry
node_launcher -->|"launches"| node_erp_entry
node_viewer_entry -->|"boots"| node_viewer_runtime
node_viewer_runtime -->|"loads meshes"| node_geometry_streaming
node_geometry_streaming -->|"reads rows"| node_model_databases
node_import_pipeline -->|"persists imports"| node_model_databases
node_viewer_runtime -->|"drives analysis"| node_bim_analysis
node_viewer_runtime -->|"publishes context"| node_cross_surface_context
node_modeller_entry -->|"boots"| node_authoring_kernel
node_authoring_kernel -->|"executes geometry"| node_kernel_worker
node_authoring_kernel -->|"folds edits from"| node_signed_oplog
node_erp_entry -->|"boots"| node_ad_ui
node_ad_ui -->|"renders folded state"| node_erp_fold
node_erp_fold -->|"applies verbs and rules"| node_erp_verbs
node_erp_fold -->|"replays facts from"| node_signed_oplog
node_cross_surface_context -->|"uses history"| node_signed_oplog
node_history_ui -->|"navigates"| node_signed_oplog
node_teams -->|"branches and replays"| node_signed_oplog
node_static_delivery -->|"serves"| node_gallery
node_static_delivery -->|"serves"| node_viewer_entry
node_static_delivery -->|"serves"| node_modeller_entry
node_static_delivery -->|"serves"| node_erp_entry

click node_gallery "https://github.com/red1oon/bim-ootb/blob/main/index.html"
click node_launcher "https://github.com/red1oon/bim-ootb/blob/main/index2.html"
click node_viewer_entry "https://github.com/red1oon/bim-ootb/blob/main/viewer/viewer.html"
click node_viewer_runtime "https://github.com/red1oon/bim-ootb/blob/main/viewer/main.js"
click node_geometry_streaming "https://github.com/red1oon/bim-ootb/blob/main/viewer/streaming.js"
click node_model_databases "https://github.com/red1oon/bim-ootb/blob/main/modeller/Duplex_extracted.db"
click node_import_pipeline "https://github.com/red1oon/bim-ootb/blob/main/viewer/import.js"
click node_bim_analysis "https://github.com/red1oon/bim-ootb/blob/main/viewer/bom_extract.js"
click node_cross_surface_context "https://github.com/red1oon/bim-ootb/blob/main/viewer/connect_scene.js"
click node_modeller_entry "https://github.com/red1oon/bim-ootb/blob/main/modeller/modeller.html"
click node_authoring_kernel "https://github.com/red1oon/bim-ootb/blob/main/modeller/bonsai_kernel.js"
click node_kernel_worker "https://github.com/red1oon/bim-ootb/blob/main/modeller/bonsai_kernel_worker.js"
click node_erp_entry "https://github.com/red1oon/bim-ootb/blob/main/erp/erp.html"
click node_erp_fold "https://github.com/red1oon/bim-ootb/blob/main/erp/erp_kernel.js"
click node_erp_verbs "https://github.com/red1oon/bim-ootb/blob/main/erp/kernel_ops.js"
click node_ad_ui "https://github.com/red1oon/bim-ootb/blob/main/erp/ad_ui.js"
click node_signed_oplog "https://github.com/red1oon/bim-ootb/blob/main/common/whole_history.js"
click node_history_ui "https://github.com/red1oon/bim-ootb/blob/main/common/history_bar.js"
click node_teams "https://github.com/red1oon/bim-ootb/blob/main/teams/engine.js"
click node_static_delivery "https://github.com/red1oon/bim-ootb/blob/main/.github/workflows/deploy-pages.yml"

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_viewer_entry,node_viewer_runtime,node_geometry_streaming,node_model_databases,node_import_pipeline,node_bim_analysis,node_cross_surface_context toneBlue
class node_modeller_entry,node_authoring_kernel,node_kernel_worker toneAmber
class node_erp_entry,node_erp_fold,node_erp_verbs,node_ad_ui toneMint
class node_signed_oplog,node_history_ui,node_teams toneRose
class node_gallery,node_launcher,node_static_delivery toneNeutral
```

## Components

### BIM Viewer

- [Viewer entry](https://github.com/red1oon/bim-ootb/blob/main/viewer/viewer.html): static entry · `viewer/viewer.html`
- [Scene runtime](https://github.com/red1oon/bim-ootb/blob/main/viewer/main.js): Three.js runtime · Bootstraps rendering, picking, navigation, and panels. · `viewer/main.js`
- [Geometry streaming](https://github.com/red1oon/bim-ootb/blob/main/viewer/streaming.js): mesh loader · Turns model rows into streamed selectable meshes. · `viewer/streaming.js`
- [BIM model databases](https://github.com/red1oon/bim-ootb/blob/main/modeller/Duplex_extracted.db): SQLite data · SQLite model state and schema patches. · `modeller/Duplex_extracted.db`
- [IFC import pipeline](https://github.com/red1oon/bim-ootb/blob/main/viewer/import.js): worker pipeline · Parses IFC or mesh imports and persists local model data. · `viewer/import.js`
- [BOM & planning](https://github.com/red1oon/bim-ootb/blob/main/viewer/bom_extract.js): analysis engine · Derives quantities, costs, schedules, clashes, and playback. · `viewer/bom_extract.js`
- [Cross-surface context](https://github.com/red1oon/bim-ootb/blob/main/viewer/connect_scene.js): selection bridge · Propagates selection, identity, and timeline context. · `viewer/connect_scene.js`

### DAGeVu Authoring

- [DAGeVu entry](https://github.com/red1oon/bim-ootb/blob/main/modeller/modeller.html): static entry · `modeller/modeller.html`
- [Feature-tree kernel](https://github.com/red1oon/bim-ootb/blob/main/modeller/bonsai_kernel.js): authoring runtime · Deterministically folds signed operations into geometry. · `modeller/bonsai_kernel.js`
- [Geometry kernel worker](https://github.com/red1oon/bim-ootb/blob/main/modeller/bonsai_kernel_worker.js): WASM worker · Runs OpenCascade and constraint-solving workflows. · `modeller/bonsai_kernel_worker.js`

### Kernel-ERP

- [ERP client entry](https://github.com/red1oon/bim-ootb/blob/main/erp/erp.html): static entry · `erp/erp.html`
- [ERP event fold](https://github.com/red1oon/bim-ootb/blob/main/erp/erp_kernel.js): event-sourced runtime · Replays signed facts as operational truth. · `erp/erp_kernel.js`
- [ERP verbs & rules](https://github.com/red1oon/bim-ootb/blob/main/erp/kernel_ops.js): domain fold · Defines operations and lifecycle validation. · `erp/kernel_ops.js`
- [Application Dictionary UI](https://github.com/red1oon/bim-ootb/blob/main/erp/ad_ui.js): SQLite WASM UI · Renders ERP application dictionary and deterministic processes. · `erp/ad_ui.js`

### Shared History & Teams

- [Signed op-log](https://github.com/red1oon/bim-ootb/blob/main/common/whole_history.js): shared event ledger · Common reversible history for BIM edits and ERP facts. · `common/whole_history.js`
- [History controls](https://github.com/red1oon/bim-ootb/blob/main/common/history_bar.js): shared UI · `common/history_bar.js`
- [Teams collaboration](https://github.com/red1oon/bim-ootb/blob/main/teams/engine.js): collaboration engine · Adds branching, presence, and replay. · `teams/engine.js`

### Other components

- [Gallery & import landing](https://github.com/red1oon/bim-ootb/blob/main/index.html): static entry · `index.html`
- [Surface launcher](https://github.com/red1oon/bim-ootb/blob/main/index2.html): static entry · `index2.html`
- [Static Pages delivery](https://github.com/red1oon/bim-ootb/blob/main/.github/workflows/deploy-pages.yml): deployment · GitHub Pages serves browser-native clients and assets. · `.github/workflows/deploy-pages.yml`

## Connections

- Gallery & import landing → Viewer entry: opens
- Surface launcher → Viewer entry: launches
- Surface launcher → DAGeVu entry: launches
- Surface launcher → ERP client entry: launches
- Viewer entry → Scene runtime: boots
- Scene runtime → Geometry streaming: loads meshes
- Geometry streaming → BIM model databases: reads rows
- IFC import pipeline → BIM model databases: persists imports
- Scene runtime → BOM & planning: drives analysis
- Scene runtime → Cross-surface context: publishes context
- DAGeVu entry → Feature-tree kernel: boots
- Feature-tree kernel → Geometry kernel worker: executes geometry
- Feature-tree kernel → Signed op-log: folds edits from
- ERP client entry → Application Dictionary UI: boots
- Application Dictionary UI → ERP event fold: renders folded state
- ERP event fold → ERP verbs & rules: applies verbs and rules
- ERP event fold → Signed op-log: replays facts from
- Cross-surface context → Signed op-log: uses history
- History controls → Signed op-log: navigates
- Teams collaboration → Signed op-log: branches and replays
- Static Pages delivery → Gallery & import landing: serves
- Static Pages delivery → Viewer entry: serves
- Static Pages delivery → DAGeVu entry: serves
- Static Pages delivery → ERP client entry: serves
