A Prompt for an Admin Dashboard
Your app is live and you are fixing things by hand in the database. This brief adds the admin area your team should use instead, with a log of every action.

Key takeaways
- Admin rights live in a table checked by the database and server, never in a hidden page or a check in the browser.
- Every admin action writes an audit log row: who, what, to which record, before and after.
- Start with the four or five numbers you actually check each morning, not a wall of charts.
The prompt below adds an admin dashboard to an app you already have running on Startbase Cloud. It gives your team a protected /admin area with the handful of numbers you check every day, a user list with safe actions (suspend, restore, change plan notes), a moderation queue for reported content, and an audit log of every admin action. It assumes a typical app with user accounts and user-generated content; adjust the nouns to match yours.
The brief
Add an admin dashboard to this app at /admin. Use the existing Startbase Cloud database and sign-in. Create an admin_roles table (user, role: viewer, moderator, admin; granted_by, granted_at) and make me the first admin. Every admin page and every admin action must check the role on the server and in database policies; a normal user who opens /admin sees a not found page. Pages: 1) Overview: tiles for signups today and in the last 7 days, active users in the last 7 days (users who did anything), new posts today, and open reports, each with the same number for the previous period and a small 30-day line chart. 2) Users: searchable table (email, display name, signup date, last active, status, number of posts) with a user detail page showing their recent posts and reports against them. Admins can suspend a user (they can sign in but cannot post, and see a notice) and restore them, with a required reason. 3) Moderation: open reports newest first with the reported content inline, the reporter, the reason, and actions: hide content, dismiss report, suspend author. Moderators and admins can act. 4) Audit log: every admin action with actor, action, target table and id, reason, the changed fields before and after, and time; filter by actor and action; nobody can edit or delete it. 5) Team: admins can grant and remove roles. Viewers can see everything but change nothing. Out of scope: impersonating users, editing user content, bulk email, and billing changes.
The parts, and why they are there
- A real role table: the most common admin mistake is protecting a page by hiding the link, or checking "is admin" in browser code anyone can change. A table of roles checked by database policies and server functions means the protection holds even if someone calls the API directly.
- Three roles: viewer for the teammate who needs numbers, moderator for the person handling reports, admin for you. Separate roles cost one field and prevent a support helper from accidentally suspending your best user.
- Not found for normal users: a "you are not an admin" page confirms the area exists. Not found is quieter.
- A handful of tiles with the previous period: "52 signups" means nothing alone; "52 versus 38 last week" is information. Five numbers you check every morning beat twenty you never read.
- Suspend instead of delete: deleting a user is permanent and loses the evidence you might need. Suspension is reversible and keeps the record. Deleting accounts on request is a separate, deliberate flow.
- A required reason on every action: six months later, "why was this person suspended?" needs an answer that does not depend on anyone's memory.
- An append-only audit log with before and after: when something changes that should not have, the log shows who did it and what it looked like before. It also keeps admins careful, which is half its value.
- No impersonation: logging in as a user is a powerful support tool and a serious privacy risk. Leave it out until you have a clear policy for it.
Why build this when the Backend tab already has a table browser and SQL editor? Those are for you as the builder, with full power over the live database. An admin dashboard gives teammates exactly the actions they need, with guardrails and a log, without handing them the keys to everything.
The first three follow-up prompts
- 01"Add a Feature flags page: flags with a name, description and on or off, plus an optional list of user ids that get it early. The app reads flags on load. Every change writes to the audit log."
- 02"On the Overview, add a signup funnel for the last 30 days: signed up, confirmed email, created first post, came back on another day, as counts and percentages."
- 03"Add an Export button on the Users and Audit log pages that downloads the current filtered view as CSV, available to admins only, and log every export."
Feature flags let you ship something to five users before everyone, and turn it off without a rebuild. The funnel is the first chart that tells you where people drop off rather than how many arrive. Exports come third because they move user data out of the app, which is exactly the kind of action an audit log exists to record.
Two variations
An operations dashboard for a booking or ordering business
Replace users and moderation with the daily work: today's bookings or orders by status, a list of anything stuck (unpaid after an hour, not confirmed by staff), refunds with a required reason, and a staff role that can change statuses but not prices. The audit log matters even more when money is involved.
A read-only metrics page for investors or a partner
A separate /metrics page for the viewer role only: weekly signups, active users and revenue for the last twelve weeks, with no user details at all. Aggregates only, computed by a scheduled job each night into a weekly_metrics table, so the page never queries personal data.
What usually goes wrong, and how to ask for the fix
- A normal user can call an admin action. The button is hidden but the function does not check roles. Ask: "Sign in as a normal user and call each admin action directly. Every one must fail with a permission error. Add the role check inside each server function and policy."
- Suspended users can still post. The notice shows, but writes still succeed. Ask: "Enforce suspension in the database policies on posts and comments, not only in the interface."
- Overview numbers disagree with the database. Often a time zone issue: "today" in UTC versus your local day. Ask: "Compute all dashboard periods in Europe/Berlin time" (or yours) "and show the time zone under the tiles."
- The users page is slow. Counting posts per user on every load gets heavy as you grow. Ask: "Paginate the users table at 50 rows, search on the server, and compute post counts with a single grouped query."
- The audit log misses changes. If logging is done in the screen code, some paths skip it. Ask: "Write audit rows in the same server function or database trigger as the change itself, so no admin action can happen without a log row."
Handing it to your team
Grant roles one at a time, starting with viewer. Write a short page of house rules next to the moderation queue: what gets hidden, when to suspend, when to ask you. Then read the audit log for the first week. You will learn more about how your team uses the dashboard from the log than from asking.
For more on tables, roles and audit logs, read how to build an admin panel, and for charts and metrics, how to build a data dashboard. The server-side role checks rely on row-level security and on user authentication. The Database docs show where to review the policies the agent writes.
Frequently asked questions
How do I protect an admin page in my app?
Store admin roles in a database table and check them in database policies and server functions for every admin read and action. Hiding links or checking roles only in browser code does not protect anything.
What should an admin dashboard show first?
The few numbers you check daily (signups, active users, new content, open reports), each compared with the previous period, plus the queues that need action. Add more charts only when someone asks a question they cannot answer.
Why do admin dashboards need an audit log?
It records who changed what, when and why, with before and after values. It answers disputes, catches mistakes, and keeps admins careful. Make it append-only so it cannot be edited.

