The docs lived on one lineage and the fleet code on another. That is why six pages described a shared fleet key as how an agent authenticates, why COLLECTOR-AUTH had to warn that the per-PC credential code was not in the repository it sat in, and why ADR-019 recorded a decision whose implementation was somewhere else. Documentation that cannot see the code it documents goes stale by construction, and no amount of editing fixes that. So the corpus moves here: 84 files, 56 pages, 20 ADRs, the proposals, INDEX.md, llms.txt and both gates. Filenames are unchanged, because a wiki page name is derived from the filename and a rename breaks every link anybody saved. THE POINT OF THE MOVE IS THE CORRECTION IT ENABLES. Every caveat that said "not in this tree" was false the moment the files landed beside the code, so each was rewritten from what is actually here: - COLLECTOR-AUTH gained the real enroll request body, the two bounds on the unauthenticated route (per-IP rate limit, pending cap with stale rows dropped before a real PC is refused), and the rejected pending reason that binds to the endpoint identity rather than the nonce. - ADR-019 now describes an implementation that is present, including its tests, and says plainly that what remains is the FLEET migration, not the code. - proposals/device-identity claimed phase 1 was unbuilt. plugins/computers declares deviceid on the collector schema and prefers it over the older fallbacks. Corrected in the page, its summary and the index. WINDOWS/IIS IS NOW DOCUMENTED AS THE LEGACY PATH, per the product decision, and carefully: it is what production runs today. Every Windows page opens by saying it is supported, not for a new site, and where a new site should go instead. No procedure was cut - an operator on an IIS box at 2am needs these pages to work exactly as well tomorrow. MIGRATE-TOPOLOGY stops being a footnote and becomes the off-ramp, which is why it nearly doubled: what was there did not match how the Docker stack really works here. The Docker material that already lived on this line was kept and given ownership rather than buried under the ported Windows-centric prose: DEPLOY now describes the four services, the migrate service that runs the upgrade chain before api starts, TLS terminated by nginx, and the plugin count corrected from thirteen to seventeen - a number both lineages had wrong. ROADMAP is rewritten from evidence rather than memory: what has shipped, read out of the changelog, the ADRs and the manifests, and ahead of it exactly two items - finalize a distributed release and polish the setup wizard. PROJECT-MAP is generated and was stale; the GENERATOR was what was wrong. --check passes now. API-REFERENCE is retired to a pointer. /api/docs serves 573 operations with derived auth, query parameters and harvested examples, and a hand-written page competing with that is a liability. The file stays so its wiki page and its inbound links survive. AND THE MOVE TURNED ON A SCRUB THAT HAD NEVER RUN HERE. test_docs_publishable keys on docs/*.md, which this line did not have, so it skipped - its own comment predicted what would surface. Porting the corpus activated it and it found 48 lines that must not reach a published wiki: branch names abbreviating the site, assistant-tooling paths, the site name in two deployment pages, and an employee ID in a Windows path that the scrub does not even look for.
137 lines
6.7 KiB
Plaintext
137 lines
6.7 KiB
Plaintext
# ShopDB - guide for an AI agent
|
|
|
|
ShopDB is a plugin-based asset-management system (PCs, printers, machines,
|
|
network devices, measuring tools, applications, knowledge base, USB,
|
|
warranties, backups and more) for manufacturing sites. Every site runs its
|
|
own instance.
|
|
|
|
This file is the machine entry point, served at `/api/docs/llms.txt`. It covers
|
|
the API, which is what most callers need, and routes everything else.
|
|
|
|
## Routing - read this before opening any document
|
|
|
|
`docs/INDEX.md` is the routing table. Rows are TASKS, each row gives the
|
|
smallest set of pages that answers it, and each row says how many lines that
|
|
costs. Find the row, read those pages, skip the rest. The corpus is far larger
|
|
than any one context window and almost none of it applies to a given question.
|
|
|
|
Every page opens with an HTML comment naming `purpose`
|
|
(tutorial/howto/reference/explanation), `audience`, `status` and a one-sentence
|
|
`summary`, plus `loadwith` for the pages it is not complete without. Filter on
|
|
that metadata before opening anything: `status: legacy` means true but
|
|
superseded (do not follow it for new work) and `status: historical` means a
|
|
finished migration or a proposal kept as a record, so neither is an answer to
|
|
"how do I do this today".
|
|
|
|
`docs/START-HERE.md` is the same routing for a human, and shorter.
|
|
|
|
Not an API question? Still start from the index rather than guessing at a
|
|
filename: its rows cover installing and running a site, loading its data, the
|
|
shop-floor PCs, and building on the platform. For "why is it built this way",
|
|
`docs/adr/README.md` says which decision governs the question and whether it
|
|
still holds. For writing a plugin, `docs/PLUGIN-HOOKS.md` is the contract and
|
|
everything else defers to it.
|
|
|
|
## Answering "how do I install or fix this server"
|
|
|
|
The people running these servers are often not Windows, IIS or Python
|
|
specialists. `docs/INSTALL-WINDOWS.md` (a new site, one offline installer
|
|
`.exe`) and `docs/OPERATE-WINDOWS.md` (restart, logs, backups, health) are
|
|
authoritative, and both ship in `docs/` inside the install directory on every
|
|
installed server.
|
|
|
|
Do NOT walk anyone through `docs/INSTALL-WINDOWS-IIS.md` for a new site. It is
|
|
the manual procedure kept for servers that predate the installer, and following
|
|
it produces a server the installer then refuses to upgrade.
|
|
|
|
Before diagnosing anything, ask for the output of `shopdb-admin.ps1 check -Json`
|
|
from the install directory (default `C:\shopdb-flask`). It reports version,
|
|
publishing method, IIS and pool state, HTTP reachability, database host and
|
|
reachability, Python version, installed plugins and errors, and it contains no
|
|
secrets. The other day-2 verbs are `status`, `start`, `stop`, `restart`, `logs`,
|
|
`open`, `backup`, `repair`, `catalog`, `sessions`, `plugins`, `add-plugin`,
|
|
`verify`, `uninstall`. `verify -Path <name>` answers "does this server carry
|
|
component X" from the on-box CycloneDX SBOM.
|
|
|
|
Python is 3.14 and the wheelhouse is locked to it; an upgrade against a venv
|
|
built by a different minor version is refused by design.
|
|
|
|
## Bulk-loading a site's data
|
|
|
|
Two routes, and the right one depends on what the site has:
|
|
|
|
- SPREADSHEET, no developer (the common case): `flask csv templates --out <dir>`
|
|
generates templates FROM THE LIVE SCHEMA, then `flask csv import --dir <dir>`
|
|
checks and `--commit` applies. Do NOT hand-write the templates - generate
|
|
them. `docs/CSV-IMPORT.md`.
|
|
- A SOURCE DATABASE to script against: the HTTP import API,
|
|
`docs/IMPORT-API.md`, with `docs/IMPORT-ADOPTION.md` for the loader around it.
|
|
|
|
User accounts are deliberately not CSV-importable.
|
|
|
|
## Base URL
|
|
|
|
Each site runs its own instance (ADR-004), so there is no single production URL:
|
|
it is whatever that site serves, e.g. `https://shopdb.example.net/shopdb`.
|
|
All API paths are under `/api` (e.g. `<base>/api/assets`). Dev: `http://localhost:5001`.
|
|
|
|
## Auth
|
|
|
|
Three schemes:
|
|
|
|
- **Bearer JWT** - most endpoints. Get one by logging in, or use a managed
|
|
Personal Access Token (PAT). Send `Authorization: Bearer <token>`.
|
|
- Login: `POST /api/auth/login` `{ "username": "...", "password": "..." }`
|
|
-> `data.access_token`. Refresh: `POST /api/auth/refresh`.
|
|
- PATs are minted in the UI (Settings > API Tokens); a *scoped* PAT is limited
|
|
to named permissions and suspends the admin bypass.
|
|
- **X-API-Key** - unattended/service endpoints (collector ingest, GE-Enforce
|
|
fetch). Send `X-API-Key: <managed-token>`. How a shop-floor PC gets its own
|
|
credential is `docs/COLLECTOR-AUTH.md`.
|
|
- **Public** - some read endpoints (e.g. printer install-list, employee search,
|
|
dashboards) need no auth.
|
|
|
|
Auth level per endpoint is in the OpenAPI `security` field: `bearerAuth`,
|
|
`apiKeyAuth`, or none. Admin-only and permission-gated routes both use bearer.
|
|
|
|
## Response envelope
|
|
|
|
JSON endpoints return `{ "status": "success", "data": <payload>, "meta": {...} }`.
|
|
Errors nest under `data`, NOT at the top level:
|
|
`{ "status": "error", "data": { "error": { "code": "...", "message": "...", "details": {...} } } }`
|
|
with an HTTP 4xx/5xx. Reading `message` or `code` off the root gives `undefined`.
|
|
Lists carry `meta.pagination.{page, perpage, total, pages}` - again nested, not
|
|
`meta.total`. A few feed endpoints (screensaver, some installer text formats)
|
|
return raw text/JSON without the envelope - noted per route.
|
|
|
|
## Common recipes
|
|
|
|
- Search everything: `GET /api/search?q=<term>` (multi-word = AND across words).
|
|
- List assets on the map: `GET /api/assets/map`.
|
|
- List a type: `GET /api/printers`, `/api/computers`, `/api/machines`,
|
|
`/api/network`, `/api/measuringtools` (paginated: `?page=&perpage=`). A
|
|
plugin that is disabled at that site serves none of its routes.
|
|
- Get one: `GET /api/printers/<id>` etc.
|
|
- Create (bearer): `POST /api/printers` `{assetnumber, windowsname, vendorid, ...}`.
|
|
- Reports: `GET /api/reports` (list), `GET /api/reports/pc-relationships` (PC<->machine).
|
|
- Printer installer data: `GET /api/printers/install-list` (public; add
|
|
`?format=text` for a pipe-delimited variant); `GET /api/printers/pc-default?machine=<n>`.
|
|
- Collector ingest (X-API-Key): `POST /api/collector/computers`.
|
|
- GE-Enforce: `GET /api/geenforce/manifest?pctype=<scope>`,
|
|
`GET /api/geenforce/payload/<sha256>`, `POST /api/geenforce/report`.
|
|
- Import (admin PAT, preserves timestamps with `X-Import-Mode`): `docs/IMPORT-API.md`.
|
|
|
|
## Conventions
|
|
|
|
- DB-mirrored params/fields use lowercase concatenated names (no underscores):
|
|
`locationid`, `vendorid`, `windowsname` - match them exactly.
|
|
- IDs in paths are integers.
|
|
- Plugin endpoints live under the plugin's prefix (`/api/<plugin>/...`).
|
|
|
|
## Full reference
|
|
|
|
- Machine spec: `GET /api/docs/openapi.json` (OpenAPI 3.1). Operation and
|
|
plugin counts live in `docs/PROJECT-MAP.md`, which is generated.
|
|
- Interactive: `GET /api/docs` (Redoc).
|
|
- Human reference: the same spec at `GET /api/docs`, and `docs/INDEX.md` for everything else.
|