# Architecture

`moonbit-ifc` is intentionally split into a syntax layer and an IFC semantic
layer.

1. `scanner.mbt` walks the ISO 10303-21 physical-file text without allocating a
   token stream.
2. `parser.mbt` builds a compact `Entity` table and preserves unknown EXPRESS
   values as `Value` trees. This is important because IFC schemas grow faster
   than any single application.
3. `index.mbt` builds stable id/name indexes and provides safe reference lookup.
4. `product.mbt`, `properties.mbt`, `geometry.mbt`, `topology.mbt`, and
   `spatial.mbt` interpret only well-known IFC relationships. Unknown entities
   remain available through the generic table.
5. `json.mbt` is a small deterministic serializer for browser and WebAssembly
   consumers. It has no runtime dependency on a JSON package.

The semantic readers are deliberately tolerant: a consumer can load a model
with an unfamiliar schema, inspect the generic entities, and still extract the
parts that are known. Malformed syntax and invalid references are reported as
checked errors rather than panics.
