Skip to content
← All articles

Technical guide · 1,676 words

How We Built Dashier: A Schema-Driven Admin Infrastructure

A technical look at how Dashier uses Next.js, TypeScript, Supabase, and schema-driven data sources to power admin interfaces and REST APIs.

How We Built Dashier: A Schema-Driven Admin Infrastructure

Dashier started with a constraint: we did not want to build a separate admin dashboard every time an application gained another operational resource. The useful abstraction was not a generic workflow engine. It was a data source whose definition could drive the records table, forms, validation, imports, and REST endpoints together.

The implementation is a Next.js 15 and TypeScript application using the App Router and Route Handlers. Supabase supplies the database and authentication services. The part that required the most care is the boundary between shared platform code and application-specific data: organizations and projects define tenancy, data-source metadata defines a resource, and each record stores its resource-specific values in JSONB.

That boundary keeps the platform code reusable without pretending that all application data has the same shape. The shared layer knows how to resolve a source, interpret its fields, validate a record, and perform common operations. The application-specific layer is mostly the source definition and the values entered into it. In other words, configuration describes the resource, while application code still owns the behavior that cannot be expressed safely as field metadata.

Tenancy is an explicit hierarchy

The core relationship is Organization → Project → Data Source → Record. An organization is the tenant, a project groups resources, a data source describes one resource, and a record is one value in that source.

This is more than a navigation model. The data model carries organization ownership on core rows, and source resolution follows the organization and project chain. API requests do not get to turn an arbitrary slug or ID into access: the server resolves the project-scoped source before it loads fields, policies, or records.

The server-side resolver starts with the signed-in user, finds an organization membership, joins the requested project, and loads the source and its ordered fields in that scope. A missing or out-of-scope object is treated as not found, which avoids turning the route into an existence oracle. Project allowlists and, where configured, member source allowlists are checked as part of that chain rather than as a late UI decision.

That gives the CRUD engine a stable shape. A source has a project, name, slug, and description. Its fields have a key, display name, type, required and nullable behavior, uniqueness, defaults, options, and position. A record has fixed columns for identity, timestamps, ownership, and attribution, plus a values JSONB object for source-specific fields.

Using JSONB means adding a source does not require creating another physical table. The trade-off is that the field metadata has to be authoritative and carefully validated; the platform cannot rely on a database column definition for every application field. We keep relational columns for relationships and operational queries such as datasourceid, organizationid, timestamps, and createdby, while the variable portion stays together in values. A GIN index supports JSONB containment-style work, and the records path can query a particular value when it needs to enforce a configured unique field.

One field definition feeds the product

datasourcefields is the source of truth for a source’s shape. The shared field helpers turn those rows into typed definitions used by the dashboard and the API instead of maintaining separate, drifting schemas for forms, tables, and requests.

The current field vocabulary includes text, textarea, number, decimal, boolean, email, phone, URL, date, datetime, JSON, image, file, enum, reference, array, and rich text. Reference fields can point to another source in the same project, and the definition records relationship details such as cardinality and the display field. Required, nullable, unique, default, option, and position metadata are part of the definition rather than hard-coded into a particular screen.

In the dashboard, a source provides a records table with search, filters, sorting, pagination, and bulk actions, along with create and edit forms. The field type controls the input and its coercion: for example, number values are converted from form or JSON strings, booleans accept common form values, and JSON and array inputs are normalized before validation.

The same definitions build a Zod record schema at the Route Handler boundary. Writes are validated, defaults are applied, unknown keys are stripped, references are checked against the target source, and unique fields are checked before persistence. Server-generated ID fields are never accepted from input. This shared path matters because dashboard writes and REST writes should not disagree about what a valid record is.

There are small but consequential normalization rules behind that promise. Empty non-text values become absent values, nullable fields can preserve an explicit null, date inputs can be normalized from supported date formats or epoch values, and array inputs can be read from a comma-separated form string. These rules live beside validation because inference, forms, imports, and API payloads need to agree about what the same raw value means.

Records use a predictable REST surface

Each source exposes the same REST shape:

  • GET /api/v1/{slug} lists records and supports search, filter_... parameters, sorting, and pagination.
  • POST /api/v1/{slug} validates and creates a record.
  • GET /api/v1/{slug}/{id} fetches one record.
  • PUT /api/v1/{slug}/{id} merges the submitted values with the existing record and validates the result.
  • DELETE /api/v1/{slug}/{id} removes a record after resolving the source and policy.

The source slug is both the UI identifier and the API path segment. It is URL-safe and treated as stable after creation. A route handler first resolves the organization, project, source, fields, and endpoint policy; only then does it run the operation. The slug itself is not authorization.

The API accepts a key in either the x-api-key header or an Authorization: Bearer header. Keys are hashed before lookup, revoked keys are rejected, and a valid key carries its project, organization, and scopes. Session callers can instead provide org and project query parameters; the server checks the Supabase session, membership, project allowlist, and optional source allowlist.

Endpoint policy is a separate decision from authentication. Each method can be public, authenticated, or role-protected, and it can be disabled or excluded from the API channel. Authenticated API-key requests need the appropriate read or write scope. Role-protected requests require an allowed session role or an API key with the admin scope. Rate limiting is applied after source and policy resolution, using the API key identity when available and otherwise the first forwarded IP value.

Authorization is checked on the server

The dashboard uses organization membership and resource permissions to decide which operations a user can perform. The role model includes Owner, Admin, Editor, and Viewer, with custom roles and resource permission keys such as members.read, members.write, and members.delete.

Those checks are not based on values sent by the browser. Server-side route helpers resolve the organization and project, and record operations pass an explicit organization and source context into the shared write functions. That context is also used when creating audit entries. The current sign-in flow uses Google OAuth through Supabase Auth; authentication identifies a caller, but it does not by itself grant access to every project or source.

System roles use a rank-based model: Owner and Admin bypass record-verb checks, Editor retains the current full record-operation behavior, and Viewer is read-only. Custom roles are different: their grants are parsed as source-specific verbs such as {slug}.read, {slug}.create, {slug}.update, and {slug}.delete, with the legacy {slug}.write grant covering create and update. This distinction lets the platform keep useful defaults while making narrower roles explicit.

The database reinforces the boundary rather than replacing it. Row-level security is enabled with a default-deny posture, and the server uses a service-role client only after it has performed explicit organization, membership, scope, and permission checks. Every record carries both source and organization IDs, so queries and audit rows retain the context needed to verify and explain a mutation.

Imports, files, and audit entries share the same boundaries

CSV and JSON imports use a validate-before-commit flow. The import route parses the input, maps columns or object keys to field keys, reports unmapped columns, coerces and validates every row, checks uniqueness, and returns a preview. Commit mode writes only after validation succeeds; imports are limited to 2,000 rows per request and 5 MB of content.

Exports use the source and access context rather than bypassing it. File and image fields have a separate upload route and the resulting URL is stored as a record value; the storage adapter is configured outside the record model, so the record still has the same JSONB shape.

Create, update, and delete operations write audit rows with the organization, acting user when there is one, action, entity type, record ID, and old or new values. Imports also write an audit entry describing the source, format, and inserted count. This keeps a mutation tied to the context in which it happened instead of making the audit log a detached event stream. Record creation can additionally enqueue the configured notification path, but that delivery behavior remains application code around the core write rather than another field type.

What this architecture does—and does not—try to do

The architecture is optimized for a configurable admin surface over changing application data. Creating a source means defining its fields, references, endpoint policies, and permissions; the platform can then reuse that definition for records, forms, validation, imports, exports, and REST operations.

That scope is intentionally narrow. Dashier is not a general workflow automation engine, and the current scope does not include GraphQL, workflows or webhooks, an SDK generator, automatic customer-facing website or form generation, a marketplace, an AI schema builder, white-label custom domains, email/password sign-in, or MySQL/MongoDB support. Those boundaries are important when comparing it with broader data or internal-tool products: it is not presented as a drop-in replacement for every category.

The central design choice remains simple: keep application values in metadata-backed JSONB records, make field definitions authoritative, resolve every request through the organization and project hierarchy, and reuse the same definitions across the dashboard, validation, API, and operational paths. That is what makes generated administration consistent without pretending that configuration removes the need for sound schemas and explicit access rules.

Dashier is admin infrastructure for modern applications. Learn how the product works in the documentation or explore features.