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)
| Field | Type | Notes |
|---|---|---|
project | relation → projects | required, single |
name | text | required |
description | text | optional |
display_type | select: kpi_card, funnel, bar_list | required; meaningful on top-level categories |
color | text | optional, hex pattern ^#[0-9A-Fa-f]{6}$ |
restricted | bool | cascades to child categories/metrics |
sort_order | number | |
parent | relation → metric_categories | optional; 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)
| Field | Type | Notes |
|---|---|---|
category | relation → metric_categories | required, single |
label | text | required |
description | text | optional |
unit | select: count, percent, currency | |
aggregation | select: sum, latest, average | drives rollupWindow/rollupAll on the frontend |
frequency | select: daily, weekly, monthly, quarterly, annually | exposed to the FE as default_granularity (translated in store/index.js) |
target_daily / target_weekly / target_monthly / target_quarterly / target_annually | number | optional, several may be set at once |
target_custom | number | optional, one-off target |
target_custom_start / target_custom_end | date | paired with target_custom |
is_headline_kpi | bool | powers the project listing's momentum sparkline |
is_active | bool | archive flag - set false instead of hard-deleting a metric with entries |
restricted | bool | cascades from/with category restriction |
sort_order | number | |
momentum | json | cache 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)
| Field | Type | Notes |
|---|---|---|
metric | relation → metrics | required, single |
period_start | date | required |
period_end | date | required, inclusive |
value | number | |
note | text | optional |
entered_by | relation → users | optional, 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.
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
- Architecture
- Getting Started
- Frontend docs: FS Garage Score Card (FE)