The audit trail
An audit trail is the history of a record: every state change writes one entry with the person, the time and, where it matters, the reason. In Meadowstack the api or the database writes that entry together with the change, never the screen, and `AuditTimeline` shows it oldest first, decisions marked by their status glyph and written text as a filled bubble.
By Bohuslav PoláčekChecked
/** Routine events get a dot; decisions get their status glyph. */
export const eventMeta: Record<
RequestEventType,
{ title: string; tone: "neutral" | "success" | "danger" | "warning" | "info"; icon?: ReactNode }
> = {
created: { title: "Created", tone: "neutral" },
edited: { title: "Edited", tone: "neutral" },
submitted: { title: "Submitted for approval", tone: "warning", icon: statusMeta.submitted.icon },
withdrawn: { title: "Withdrawn to draft", tone: "neutral", icon: statusMeta.draft.icon },
approved: { title: "Approved", tone: "success", icon: statusMeta.approved.icon },
rejected: { title: "Rejected", tone: "danger", icon: statusMeta.rejected.icon },
reopened: { title: "Decision undone", tone: "warning", icon: statusMeta.submitted.icon },
commented: { title: "Comment", tone: "neutral" },
};The flow, step by step
What the history of one purchase request in the starter shows, entry by entry:
- Created. Leah writes a draft. The first entry is "Created", her name and the time beside it.
- Edited. She changes the supplier and the amount and saves. One entry, "Edited", and under it what changed, old value to new; a rewritten reason reads "Reason rewritten". Saving without a change writes nothing.
- Submitted for approval. The entry carries the half-filled waiting glyph, so the moment the request left her hands stands out from the edits.
- Rejected. Marcus rejects it. The entry is in the danger tone with the rejected glyph, and his reason sits under it in a filled bubble, where Leah will look for it.
- Comment. Anyone who may read the request writes under the history in a
Composer(Cmd/Ctrl+Enter sends). The comment lands as a bubble under a "Comment" label. If saving fails, the text stays in the box and a toast says so; the api refuses an empty comment. - Decision undone. If Marcus presses Undo, the history gains "Decision undone". Nothing is removed: the mistake and its correction both stay.
The rules and where each one is enforced
| Rule | Where it is enforced |
|---|---|
| Every state change writes one entry | moveEvent() in domain/workflow.ts for every move, written by the api with the change; the rule for every module in .claude/rules/apps.md |
| The entry is written where the change is saved, never by the screen | the module's api; in the Supabase example a trigger in the same transaction, "so no client can forget it", and people cannot insert history rows themselves |
| Nobody edits or deletes an entry | no update or delete policy on request_events |
| The person comes from the session, not from the request | actor_id default auth.uid() and actor_name default app_name() in the table above |
| Entries are labels without a grammatical subject | the titles in eventMeta ("Approved", the person beside it); a rule in the root AGENTS.md |
| Decisions stand out, routine entries stay quiet | eventMeta: a status glyph and tone for submitted, approved, rejected and undone, a dot for created, edited and comments |
| A rejection keeps its reason | moveEvent() puts the reason in detail; api test "asks for a reason before a rejection, and keeps it in the history" |
| An edit says what changed | the api compares old and new before it writes; api test "records what an edit changed" |
| Comments are entries, never empty ones | api test "writes comments into the history, never empty ones" |
| Written text looks different from the box you write in | AuditTimeline draws a filled bubble, Composer a white field with a ring |
What AI coding tools build instead
- History written by the screen. The component that changes the status also posts an activity row. Then the bulk bar, an import or a second screen changes the status without one, and the gaps show only when someone needs the history. The entry belongs where the change is saved.
- A sentence with the person as subject, "Marcus approved the request". It repeats the name the line already shows and has to agree with every person it names. A label, "Approved", with the person beside it reads right for everyone.
- Every entry the same weight. Twenty "Edited" lines bury the one rejection. Decisions get their glyph and tone, the rest a dot.
- Comments in a separate tab, so the reason for a decision and the talk about it live in two places. Here a comment is an entry in the same history, and the
Composersits under it. - An editable history, an update endpoint or an admin screen that corrects entries. A trail anyone can rewrite proves nothing.
- The actor read from the request body. Anyone can then write history in someone else's name. The database fills it from the session.
- "Updated" and nothing else. An edit here names what it changed, and a save that changed nothing writes nothing.
Where to see it
- Document inbox: a document's history in its side panel.
- Time-off approval: a leave request's decision card and its history.
- In the print shop of Foldline, a customer signed in for proofs sees only their side of a job's history (
customerEventsin the module'sdomain/permissions.ts); the shop's own notes never reach them. - The kit's AuditTimeline and Composer, the approval flow whose moves fill the history, and permissions, which decide whose history shows what.
Example apps with a record history
| Example app | Modules that render it |
|---|---|
| An app for a packaging and print company | Jobs, Print file editor, Quotes, Cutting dies, Colour |
| An app for a studio or agency | Capacity, Tasks, Finance |
| An app for a haulage company | Freight, Drivers, Costs |
| An app for a roastery with an online shop | Roasting, Green coffee, Shop, Wholesale, Scenarios |
| An app for a sports club | Front desk, Courts, Club, Coaching, Rentals |
| An app for a construction company | Sites, Schedule, Crews, Machines, Site diary, Drawings, Foreman's phone, Budget |
| An app for an accounting office | Documents, Bookkeeping, Official mail, Invoicing |
| An app for restaurants and venues | Shifts, Kitchen, Food safety, People, Handbook |
| An app for one person | Brand deals, Content, Money, Training |
The history table in Postgres
-- History: every change writes one row, in the same transaction, and nobody
-- edits or deletes a row (no update or delete policy exists).
create table public.request_events (
id uuid primary key default gen_random_uuid(),
request_id uuid not null references public.requests (id) on delete cascade,
type text not null
check (type in ('created', 'edited', 'submitted', 'withdrawn', 'approved', 'rejected', 'reopened', 'commented')),
actor_id uuid not null default auth.uid() references public.profiles (id),
actor_name text not null default public.app_name(),
at timestamptz not null default now(),
detail text
);Questions
Should the frontend or the backend write audit log entries?
The backend, in the same transaction as the change. A screen can only log the changes made through it, and the first import, bulk action or second screen leaves a gap. In the starter's Supabase example a trigger writes the row, so no client can forget it.
Can someone delete or correct a history entry?
No. The history table has no update or delete policy, and a correction is a new entry: an undone decision adds Decision undone rather than removing Approved.
Why are entries labels like Approved instead of sentences?
The person is already beside the label with their avatar, so a sentence would say the name twice, and a sentence has to agree with whoever it names. A label reads right for everyone and scans faster down a long history.
Where do comments go?
Into the same history, as a filled bubble under a Comment label, with the box to write in underneath. A reason for a rejection appears the same way, so everything said about the record reads in one place, oldest first.
Does a customer see the same history as the staff?
Not in the demo's print shop. A customer sees the steps of their own job, from the quote to the delivery, while the shop's notes and its internal steps, such as a colleague's check of a proof, stay with the staff. The filter is part of the permissions, not of the screen.
Two ways
Build it yourself, or have it built
Build it yourself
Build your app on the framework
Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.
One payment, lifetime updates
Get the frameworkHave it built
Have us build your app
Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.
After launch, Care keeps it improving, from €99 a month.
from €1,990
Describe your app