terra vidhal

Db Schema Explorer

Component

About

A database schema explorer with a searchable table list, column details and notes, key markers, clickable relations, select-all column controls, editable draft indexes and a live SQL preview.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Db Schema Explorer to your project and fits it to your theme.

Code

How Db Schema Explorer is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

/**
 * PrequelUI Animate — MIT — https://prequeluianimate.terravidhal.me
 */

import { DbSchemaExplorer, type SchemaTable } from "@/components/ui/db-schema-explorer";

const TABLES: SchemaTable[] = [
  {
    id: "accounts",
    name: "accounts",
    description: "Workspaces that own projects, members and billing.",
    rows: 18420,
    columns: [
      { name: "id", type: "uuid", primaryKey: true },
      { name: "name", type: "text" },
      { name: "slug", type: "text", unique: true },
      { name: "plan", type: "text", note: "free, team, scale" },
      { name: "created_at", type: "timestamptz" },
      { name: "deleted_at", type: "timestamptz", nullable: true },
    ],
    indexes: [
      { name: "accounts_pkey", columns: ["id"], unique: true },
      { name: "accounts_slug_key", columns: ["slug"], unique: true },
    ],
  },
  {
    id: "projects",
    name: "projects",
    description: "Briefs, boards and reports grouped under an account.",
    rows: 96432,
    columns: [
      { name: "id", type: "uuid", primaryKey: true },
      { name: "account_id", type: "uuid", references: "accounts.id" },
      { name: "name", type: "text" },
      { name: "status", type: "text", note: "draft, active, archived" },
      { name: "visibility", type: "text", note: "private, team" },
      { name: "updated_at", type: "timestamptz" },
    ],
    indexes: [
      { name: "projects_pkey", columns: ["id"], unique: true },
      { name: "projects_account_idx", columns: ["account_id"] },
    ],
  },
  {
    id: "memberships",
    name: "memberships",
    description: "People attached to an account with a role.",
    rows: 41288,
    columns: [
      { name: "id", type: "uuid", primaryKey: true },
      { name: "account_id", type: "uuid", references: "accounts.id" },
      { name: "user_id", type: "uuid", references: "users.id" },
      { name: "role", type: "text", note: "owner, admin, editor, viewer" },
      { name: "invited_at", type: "timestamptz", nullable: true },
      { name: "accepted_at", type: "timestamptz", nullable: true },
    ],
    indexes: [
      { name: "memberships_pkey", columns: ["id"], unique: true },
      { name: "memberships_unique", columns: ["account_id", "user_id"], unique: true },
    ],
  },
  {
    id: "audit_events",
    name: "audit_events",
    description: "Append-only trail of security-sensitive actions.",
    rows: 1284520,
    columns: [
      { name: "id", type: "bigint", primaryKey: true },
      { name: "account_id", type: "uuid", references: "accounts.id" },
      { name: "actor_id", type: "uuid", references: "users.id", nullable: true },
      { name: "action", type: "text" },
      { name: "target", type: "text", nullable: true },
      { name: "created_at", type: "timestamptz" },
    ],
    indexes: [
      { name: "audit_events_pkey", columns: ["id"], unique: true },
      { name: "audit_events_account_idx", columns: ["account_id", "created_at"] },
    ],
  },
];

export default function DbSchemaExplorerDemo() {
  return (
    <main className="flex min-h-screen w-full items-start justify-center bg-gradient-to-b from-muted/40 via-background to-background px-4 py-8 sm:px-6">
      <DbSchemaExplorer tables={TABLES} title="Workspace data model" />
    </main>
  );
}

Dependencies

More by terra vidhal

View all
  • Project Timeline

    Project Timeline

    30
  • Kanban Board

    Kanban Board

    20
  • Gravity Stars Background

    Gravity Stars Background

    20
  • Booking Calendar

    Booking Calendar

    18
  • Kpi Counter

    Kpi Counter

    17
  • Notification Center

    Notification Center

    16
  • Audio Waveform

    Audio Waveform

    16
  • Topographic Lines

    Topographic Lines

    16

Explore more

Part of PrequelUI Animate — browse the full library on 21st.dev.