Skip to main content

FS Garage Score Card (BE) API Reference

Score Card has no custom pb_hooks routes of its own - the frontend reads/writes the collections below directly through the PocketBase JS SDK, gated by collection-level access rules. Field lists below are read directly from the current pb_migrations/*.js files, not from an external design doc, so they reflect the live schema.

Authentication​

PocketBase user session (cookie/token via SDK).

Base URL​

PocketBase: http://127.0.0.1:8091

metric_categories (pbc_366275764)​

FieldTypeNotes
projectrelation → projectsrequired, single
nametextrequired
descriptiontextoptional
display_typeselect: kpi_card, funnel, bar_listrequired; meaningful on top-level categories
colortextoptional, hex pattern ^#[0-9A-Fa-f]{6}$
restrictedboolcascades to child categories/metrics
sort_ordernumber
parentrelation → metric_categoriesoptional; added in a follow-up migration, one level of nesting

Access: listRule/viewRule - project owner, ceo/c-suite/project-lead role, or a project member. createRule/deleteRule - project owner or ceo/c-suite/project-lead only (tightened from "any authenticated user" in a later migration). updateRule matches create/delete.

metrics (pbc_3017397517)​

FieldTypeNotes
categoryrelation → metric_categoriesrequired, single
labeltextrequired
descriptiontextoptional
unitselect: count, percent, currency
aggregationselect: sum, latest, averagedrives rollupWindow/rollupAll on the frontend
frequencyselect: daily, weekly, monthly, quarterly, annuallyexposed to the FE as default_granularity (translated in store/index.js)
target_daily / target_weekly / target_monthly / target_quarterly / target_annuallynumberoptional, several may be set at once
target_customnumberoptional, one-off target
target_custom_start / target_custom_enddatepaired with target_custom
is_headline_kpiboolpowers the project listing's momentum sparkline
is_activeboolarchive flag - set false instead of hard-deleting a metric with entries
restrictedboolcascades from/with category restriction
sort_ordernumber
momentumjsoncache field (last ~8 {start, end, value} points)

Access: same pattern as metric_categories, scoped through category.project.owner/role/category.project.members.

metric_entries (pbc_724030684)​

FieldTypeNotes
metricrelation → metricsrequired, single
period_startdaterequired
period_enddaterequired, inclusive
valuenumber
notetextoptional
entered_byrelation → usersoptional, auto-set

Access: same owner/role/member pattern, scoped through metric.category.project. createRule/updateRule additionally require period_start <= period_end at the database level (on top of the frontend's own integrity check).

projects.type (existing collection, extended)​

Existing select field on projects, originally client/product; extended with a third value, business-unit, for the Score listing's project-type filter/badge. No new collection - only a value added to an existing field.

Error Responses​

Standard PocketBase error JSON (code, message, data) on validation failures - e.g. a metric_entries write with period_start > period_end, or a create/delete attempt by a member who isn't the project owner.

Formulas live on the frontend

This backend only stores raw entries and per-cadence targets - it does not compute roll-ups, deltas, or momentum. See FS Garage Score Card - Metrics and Calculations for exactly how those are derived from this data.

Next Steps​