Skip to content

Architecture ​

This section specifies how source programs, compilation, sessions and views fit together. Message shapes belong to Communication; serialized records belong to Exchange formats.

Responsibilities and boundaries ​

OwnerResponsibilityBoundary
@pcbjs/coreDesign vocabulary, types, identities, canonical model and shared protocol declarationsShared contracts must not depend on an editor or viewer implementation
@pcbjs/compileEvaluate and flatten a design, place, route, finish geometry and run checksProduces board data; does not own a VS Code tab or canvas
@pcbjs/exportConvert compiled results into viewer facets and manufacturing artifactsExported SVG is a representation of the board, not the canonical model to parse back
CLI project runtime and sessionLoad projects, own source authority, schedule compilation and distribute stateEach checkout has its own session identity; projects have their own compile state
@pcbjs/ui and viewerRender facets and implement selection, cameras and editing gesturesA local preview is not a committed source change
Editor and agent clientsSupply source buffers, request operations and present resultsRequests retain the originating project, board and target through asynchronous work
Platform and browser workerProvide host services and execute supported compilation in memoryBrowser caches and Node caches remain separate

The package dependency table describes the packages in detail. The dependency-free protocol declarations are shared by session, editor, language server and viewers.

Source-to-view flow ​

  1. Resolve project config and registered entries. Evaluate config before entries so defaults are available.
  2. Transform TSX and source ranges, then evaluate the design in its project realm.
  3. Flatten components into the canonical Board: absolute board geometry, nets, footprints, references and source provenance.
  4. Run the stage plan required by the requested views. Manual copper precedes automatic routing; tuning and finishing precede the relevant checks.
  5. Export and stream named facets. A complete compile can commit a snapshot; a partial compile serves its requested views without claiming a full snapshot.
  6. Clients apply results for the correct project, board, target and run. They refuse stale editing targets and request resynchronization when needed.

The full stage table, facet dependencies, cancellation and cache keys are in Compiler and canonical model. Its implementation is STAGE_DEFS, executed by the runner.

Ownership invariants ​

  • The canonical board uses absolute millimetres with y increasing downward. JSX and SVG-like vocabulary are inputs; exporters all read the compiled model.
  • Parts, nets, defaults and source mapping belong to a project realm. Runtime branding identifies values across loader copies; class identity cannot be assumed across them.
  • A source edit is applied through the session's source authority and version checks. A renderer cannot infer write permission from a visible object.
  • Shared selection carries board, target and snapshot identity. Pane-local camera and presentation state remain distinct from source state.
  • Closing one client detaches it. It does not stop a session still used by other clients. Session lifecycle owns shutdown and idle-grace rules.
  • A cached stage is reusable only under its declared inputs and compiler identity. Generated caches are implementation artifacts, not editable source or a portable exchange contract.

Browser execution ​

Browser execution and parity defines the virtual project, supported host services, worker messages, cancellation and numerical self-check. A static page can compile its packaged source graph in a worker. That does not grant the page access to a writable development session.

The Platform abstraction supplies files, paths, hashing, environment and cache storage. Node is the normal host; browser memory storage does not read or mutate the checkout's stage cache. See platform.ts.

Detailed contracts and verification ​

Stage/cache tests and Node/browser equality tests cover important boundaries. Their presence does not establish that every supported platform passed the current release candidate. The conformance page separates contract checks from release acceptance.

MIT licensed. A proof of concept, pre 0.1.