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 hooks — part number, revision label,
before release, after release, review reviewers and review events — 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): the family page, Generate
from the family table’s rows — from the CAD app with its documents, or
assembled here and queued for a headless CAD worker’s bake (bake_worker)
— CSV import into a family’s table, and template spin-out.
Assembly structure (bom, bom_config): each revision’s “uses” list —
the one the CAD app publishes on save — and the indented and flat BOM, named
BOM column configurations, 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; and paged part listings. A data directory’s
schema version must match exactly; there is no upgrade path. Attachments
(attach), per-user workspaces (workspace) and backups, restore and
export (backup) sit beside it.
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).
Workflows (workflow): versioned workflow definitions and durable
executions with forms, reviews and script steps. Jobs (jobs): shop-floor
builds of released manufacturing instructions, signed off step by step. The
tools library (tools): the hand tools and fixtures instruction steps
name.
A part records where it came from (model::Origin) and an
external reference; the KiCad library setup stamps the parts it imports.
§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’s PLM client stores
through it.
api::router builds the axum router over a db::Db (opened with
db::Db::open); the brep-plm binary serves it. See the README for the
command line and an embedding example.
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, seecrate::sql), one file per CAD document, and the monotonic change sequence the CAD app’s mirror will key its cache on. - desktop_
link - Signing the desktop app in through the user’s browser: a device authorization flow in the spirit of RFC 8628.
- 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.
- jobs
- The jobs floor queue: serialized builds of released manufacturing instructions, signed off step by step on the shop floor.
- 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.
- player
- Serving the manufacturing instructions player per instructions revision.
- 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.
- 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>. - tools
- The tools library: the hand tools, drivers and fixtures manufacturing instructions name in their steps (a name, a picture and a spec).
- 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: folders of links and files, and each user’s Home (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.