The problem
Andalan Consulting is a consulting firm in Indonesia, covering audit, legal, financial and tax work. Its inquiries arrive over WhatsApp and email, and they were tracked in spreadsheets and personal chats. Leads went cold, follow-ups were missed, and management could not see the pipeline.
The goal in the spec was one sentence: every inquiry is captured, owned by a consultant, and has a next action with a date.
What it does
- Leads with a history. Each lead has its details, notes, follow-ups and a Timeline. The Timeline records every change, stage move, meeting and quotation, and nothing can edit or remove an entry. A lead is archived, not deleted, and can be restored at any time.
- A pipeline board. Ten stages, from New Inquiry to Won and Lost. Drag a card, or pick it up with the keyboard. The card moves at once. If the server refuses the move, the card goes back, and when someone else changed the lead first, the message names them.
- Follow-ups and meetings. Follow-ups sit in Today, Upcoming, Overdue and Completed tabs. Meetings have week and month views, and the bell reminds the consultant 24 hours, 1 hour and 5 minutes before one starts.
- Quotations and reports. Quotations carry a number, a status and the PDF. Leads, follow-ups, meetings, quotations and reports export to CSV files that open cleanly in Excel.
- English and Indonesian. Every screen is in both languages, and so are the service and industry lists. A test fails when a text exists in one language and not the other.
Decisions
An API, not server actions
Next.js is used as a bundler and a Node server, not as a rendering framework. Screens are client components that read and write through TanStack Query, and every change goes through a route handler under /api. A lint rule rejects 'use server', so the boundary cannot erode one convenient shortcut at a time, and the backend can move to its own service later without a rewrite.
Permissions are data, applied before the page
A role is a database row with 34 permissions. Each one is either on or off, or scoped to all leads, assigned leads, the user's own, or none. An Admin changes them in Settings, not in code. The scope is returned as part of the query's WHERE clause, so it is applied before LIMIT and OFFSET. Filtering after paging would give a consultant a short first page and a total that counts leads they cannot see.
Stages are rows, not strings
An Admin can rename, reorder and add pipeline stages, so code must never recognise Won by its name. Each stage stores its outcome: open, won or lost. A test parses every source file and fails on code like stage.key === 'won', or on code that guesses the win from a stage's default probability. When the firm dropped the Follow-up stage, it was turned off rather than deleted, so old moves into it still show on each Timeline.
The next follow-up is computed
A lead's next follow-up date is never typed. Database triggers set it to the earliest pending follow-up, so the leads table and the follow-ups list cannot disagree. Overdue means due before today in Jakarta time, not UTC, so yesterday's follow-ups count as overdue from midnight, not from 7 in the morning. The dashboard counts open leads with nothing booked as Unscheduled, so a lead without a next step is visible.
WhatsApp without the API
The firm's inquiries come over WhatsApp, but the WhatsApp Business API needs an account review and approved message templates first. That integration was postponed. Instead, a consultant fills a saved template with a lead's details and opens it in their own WhatsApp through a wa.me link. The CRM sends nothing itself. A variable with no value renders as blank, never as {{lead.name}}, and a template that names an unknown variable cannot be saved. Opening the link writes a "template opened" entry on the Timeline; it does not claim the message was delivered.
Shipping
Every push and pull request to main or develop runs lint, type checks, 5,294 unit tests and a build. A second job migrates an empty Postgres 16 and runs the integration tests against it. One of them calls every route handler that changes a lead and fails if any of them skips the Timeline entry.
The first deploys ran on Railway, as the spec planned. The CRM then moved to a server of its own, run by one Docker Compose file in the repository: Caddy, the web app, a worker and Postgres. A migration step runs once and must finish before the app starts, so two copies of the app never migrate at the same time. The worker runs scheduled jobs on pg-boss, a queue inside the same Postgres, so there is no Redis to run: reminders, notifications, session cleanup and a nightly database backup.
Limits
- Two steps the spec asks for are not built. Moving a lead to Won or Lost does not ask for a reason yet, and marking a quotation Sent does not move its lead to the Quotation Sent stage.
- The inboxes have no screen. The WhatsApp inbox is postponed. The email inbox is built on the server, where an inbound email can become a lead, but the firm chose not to show it in the CRM. Attachments on those emails are not stored yet.
- Lists are made for laptops and tablets. The board, the dashboard and the dialogs work on a phone, but the tables squeeze.
- It is not public. The CRM holds client data and runs inside the firm. The screenshots come from a local copy filled by the app's own demo seeder: 200 generated leads and five made-up consultants. The entity codes at the start of each lead code are placeholders.


