COREY

Architecture

Main boundaries in the viewer, runtime, and optional backend.

COREY has two supported operating modes.

Local-First Mode

Users choose an IFC file from disk. The browser reads the file, creates the That Open runtime inside IfcViewport, and keeps review state in React and browser storage. Model bytes do not leave the browser in this mode.

Self-Hosted Backend Mode

The backend stores model metadata in Postgres and model bytes in S3-compatible object storage. Server-backed models use stable model ids for drafts, rule templates, Excel compute, and IFC writeback.

Main Boundaries

  • src/app/page.tsx: app entry for the viewer
  • src/features/viewer/components/viewer-shell.tsx: top-level React state and workflow orchestration
  • src/features/viewer/components/ifc-viewport.tsx: That Open, WebGL, worker, WASM, and tool lifecycle boundary
  • src/features/viewer/lib/model-source.ts: local and remote model-loading abstraction
  • src/features/viewer/lib/ifc-data.ts: tree, selection, category, table, and formatting helpers
  • src/features/rules/*: validation clause UI, provider, worker, and shared evaluator
  • src/server/*: Prisma, S3, model, draft, and rule-template stores
  • src/app/api/*: supported self-hosted API routes
  • src/mcp/*: companion HTTP MCP service, stored-model adapter, and browser-session broker
  • src/features/viewer/mcp/*: shared MCP contracts, bounded query/edit engine, and browser bridge

MCP Companion

The optional MCP process owns Streamable HTTP transport, OAuth discovery, and a WebSocket bridge. Deployment-wide enablement, hashed API credentials, OAuth clients, and rotating tokens live in Postgres and are managed from the administrator MCP dialog. The companion introspects credentials through a shared-secret internal app API, so disable and rotation take effect without a restart.

Active-tab commands execute against normalized React state in the browser, so local IFC bytes remain in the tab. Stored targets use the same owner-scoped model, draft, and rules APIs as the web app and build a bounded headless WebIFC index of the latest model version.

MCP targets are always explicit: either a connected viewer session id or a stored model id. Elements use stable IFC GlobalId values at the public boundary. Draft edits are atomic, optimistic, and reversible.

Design Rules

  • Keep That Open and WebGL code client-only.
  • Keep IfcViewport as the imperative runtime boundary.
  • Keep ordinary React state in ViewerShell.
  • Preserve the ModelSource abstraction for local and remote model sources.
  • Preserve the single-model assumption unless multi-model workflows are explicitly designed.