DevelopmentResource Framework
Database
Database reference — resource framework
This page documents the primary tables that configure the resource framework and related UI: resource_routes, resource_forms, and resource_charts. It also notes key indexes and how each table maps to the frontend.
public.resource_routes
Defines list/drilldown behavior for resources when no static entry is present. The UI loads one row by resource_name (or by table as a fallback) and maps fields into a ResourceRoute object.
Important columns:
table(text): Postgres table/view name to queryid_column(text): primary id column for drilldown links and updatesschema(text, defaultpublic): optional schema nameenable_search(boolean) andsearch_by(text): list search configurationcolumns(json): array of column specs or strings ({ column_name, ... })company_id_column(text),disable_company_filter(boolean): company scopingenable_new_resource_creation(boolean): show/hide “New” buttonnew_resource_button_text(text),new_resource_href(text): creation UXforce_wrapping_header_labels(boolean): wrap long table headers- Edit policy:
enable_edit(boolean),allowed_columns_edit(json),denied_columns_edit(json),scope(text),ignore_company_check_before_mutation(boolean) row_actions(json): optional per-row action configurationavatar_column(text),icon(text),page_label(text): display hintspermanent_edit_state(boolean): drilldown opens in edit modedrilldown_route_prefix(text),sidebar_route(text): navigation hintsfilter_options(jsonb),column_datatypes(jsonb): future extensibilityforce_remove_back_button_store_on_index_resource(boolean): UX hintpath(text),resource_name(text),resource_route_id(uuid): identity and routingnew_resource_mandatory_columns(json),new_resource_optional_columns(json): scoped creation configforce_no_cache(boolean): client sendsCache-Control: no-cachewhen true; disables header when false; falls back to scope default when null/omitted (see caching.md)
Uniqueness:
resource_routes_resource_name_keyensures one row perresource_name.
Frontend mapping:
components/ResourceTable.tsxandcomponents/ResourceDrilldown.tsxmap these columns toResourceRoutefields and drive UI accordingly.
public.resource_forms
Stores schema‑driven forms used across list/drilldown and formation flows.
Important columns:
resource_form_id(uuid, unique): stable referencecompany_id(uuid, nullable): optional scopingentity(text): logical entity (e.g.,customer_signup)slug(text, unique): primary lookup key used in routesversion(int): versioning supportexperimental(boolean): feature flaggingis_active(boolean): visibility flagschema(jsonb): the form definition (v1 or v2; see form.md and form-fields.md)error_keys(jsonb): precomputed analytics/lookup keys extracted from schematags(text[]): search/filter helpersdescription(text): human description
Indexes:
- GIN on
schemaanderror_keysfor efficient search - Unique btree on
slug - Additional btrees on
entity,is_active,updated_at
Frontend mapping:
- Page loads forms by
slug, falling back byentityif needed. The v2 schemas are normalized to v1 at render time (see overview.md).
public.resource_charts
Configures charts that can be associated with resources or dashboards.
Important columns:
table_name(text): source table for chart datatitle(text),color(text): presentationtarget_column(text): numeric/measure columncalculation_strategy(text): e.g.,sum,avg,count, etc.dragonfly_key(text): cache key for chart data in the cache layerchart_type(text): e.g.,line,bar,area,kpix_axis_group_by(text): time or categorical grouping (e.g.,day,month,category)has_label(boolean),label_color_body(text),label_color_text(text): label styleis_currency(boolean),currency_number_format(text),currency(text): currency formatting controlsis_percentage(boolean): percentage formattingshow_last_updated_at(boolean): display freshness indicatorchart_id(uuid): stable referenceenabled(boolean): toggle chart availabilitydata_endpoint(text): optional custom endpoint for data sourceeq_column(text),eq_value(text): optional default filter
Frontend mapping:
- A chart renderer reads this configuration, builds the request (optionally applying
eq_column/eq_value), calls the endpoint or table gateway, and formats output based on currency/percentage flags.
Operational notes
- Tables include
created_atand identity keys to simplify audit and pagination. - Use DB defaults for booleans and string fields where appropriate for predictable client mapping.
- Keep JSON structures small and typed: the UI expects arrays for
columns,allowed_columns_edit, etc.
Typical queries
- Load a route by name:
select * from public.resource_routes
where resource_name = $1
limit 1;
```typescript
- Load a form by slug:
```sql
select * from public.resource_forms
where slug = $1 and is_active = true
limit 1;
```typescript
- List enabled charts:
```sql
select * from public.resource_charts
where enabled = true
order by created_at desc;
```typescript
*** End Patch