Skip to main content

Crate brep_plm

Crate brep_plm 

Source
Expand description

The BREP PLM server.

Parts have a permanent identity and a configurable number; revisions carry the lifecycle and the CAD document; a draft is edited under an explicit checkout; a released revision is immutable. The HTTP surface is in api, the rules are in db and lifecycle, and the records are in model.

§What is built

The spine, plus the administrator’s scripting layer (scripting): part types number by counter, free text, pattern or script (model::NumberMode); revision labels are free text; every part carries a fixed model::DocumentClass; and four hooks — part number, revision label, before release, after release — let an organization override the defaults with JavaScript files in a directory it can keep in git.

The catalog (catalog): a tree of categories, each adding typed attributes to what it inherits from its parent; every part sits in one category, carries free tags, and holds attribute values that are type-checked when written and must be complete before a release.

Sourcing (sourcing): manufacturers and suppliers, and on each part its manufacturer parts with their supplier offers. Administrator settings (model::Settings) decide whether a part may have several revisions in work and whether a released part’s catalog values lock.

Families and templates (family, seed).

Assembly structure (bom): each revision’s “uses” list — the one the CAD app will publish on save — and the indented and flat BOM, the diff between two revisions’ lists, where-used, and an administrator’s release gate on unreleased children, all computed from it.

Security (security, api::credentials, tls): CSRF tokens on browser sessions, scoped API tokens for everything else, a sign-in throttle, session limits, password change and sign-out everywhere, response headers, Secure cookies, optional native TLS, and a switch for the in-browser script editor.

The audit log (audit): every change the store commits, found by diffing what the change touched before and after, attributed to the request’s actor, committed with the change and read through /api/audit.

Storage (sql, table): the metadata in one SQLite file, each change one transaction with its audit events; a trigram full-text index over what a person searches a part by; paged part listings; and a one-time import from the JSON-file store earlier versions wrote.

Review and approval (review): submitting a revision opens a review round judged by the settings’ rule or the nearest override, reviewers approve or reject, a rejection sends the revision back to Draft, release waits for the rule, and every revision carries a threaded discussion. One process holds a data directory at a time (dirlock).

Library import is designed but not built — where the design named a field it will need (model::Origin, external_ref), the field is here and inert.

§The document API

/api/store/* is deliberately shaped to what the CAD app’s StoreBackend requires of a remote backend: a metadata-only index (so a client never hydrates the corpus), a per-key read, a write, a delete, and a monotonic change sequence with a “what moved” feed. The CAD app is not touched by this crate; this is the surface it will adopt.

Modules§

api
The HTTP surface: the router, the session cookie, and the helpers every handler shares.
attach
Attachments: files on a part or on one of its revisions.
audit
The audit log: who changed what, and when, for every change to the store.
auth
Passwords, session tokens and the random ids everything else is keyed by.
backup
Backup, restore and export.
bake_worker
Administrator control of one server-owned native bake worker. Executable, credentials and server URL are operator configuration; HTTP callers cannot supply commands or obtain token contents.
bom
Assembly structure: the “uses” lists, and the BOM and where-used views computed from them.
bom_config
Revision and occurrence fields and the BOM layouts shared by CAD and PLM.
cad
Hosting the wasm CAD app from a directory the administrator controls (plm-cad-integration-todo D6, D7, §2 P2).
catalog
The catalog rules: how a category’s schema is inherited, what shape the tree may take, and whether a value fits an attribute.
db
The store: the metadata in SQLite (plm.sqlite, see crate::sql), one file per CAD document, and the monotonic change sequence the CAD app’s mirror will key its cache on.
dirlock
One process per data directory.
family
Families, templates and the bake queue on the server (§3.2, round 8).
geometry
Derived geometry metadata. Feature names alone never establish geometry.
identity
Human-readable part and revision identities. Escaping is transport syntax, never a lookup through a second identifier.
journal
Journaled: an in-memory list of keyed records that remembers what a change touched, so the store writes and audits only those.
lifecycle
The revision state machine, and the revision labels.
model
The PLM record types, and nothing that acts on them.
replace
Replace everywhere: swap one part (or one revision of it) for another in every assembly that uses it, driven by where-used.
review
Review and approval (round 9 item 4).
scripting
Administrator scripts: the directory they live in, the hooks the server calls, and the test run the web editor offers.
security
Hardening: how the server is configured to face a network, the sign-in throttle, API tokens, and the pieces of request checking every route shares (CSRF, token scopes, response headers).
seed
Family and template SEED documents, read and written the way the CAD app reads and writes them (§3.2, round 8).
sourcing
Sourcing: who makes a part and who sells it.
sql
The metadata store on disk: one SQLite file, plm.sqlite, in WAL mode.
table
Parts: the in-memory part list, which remembers what a change touched.
thumbnail
Revision thumbnails (P9): a small PNG per revision, made by a CAD client when it saves and by the bake worker for generated members. The server never links the kernel, so it never renders one; it keeps what it is sent.
tls
Native TLS: brep-plm serve --tls-cert <pem> --tls-key <pem>.
version
The version handshake: what this server is, and the oldest CAD app it serves.
workflow
Versioned workflow definitions and durable DAG executions. Scripts run outside the database lock; a persisted claim prevents concurrent duplicate dispatch.
workspace
Workspaces: each user’s folders of links and files (plm-cad-integration D12, prerequisite P6). In PLM mode the CAD app’s file explorer becomes a browser of these (S14).

Structs§

Error
A refusal, with the status the API answers it with and the message a person reads. Every refusal in this server carries a reason — a bare status code tells the user nothing about what to do next.