Overview
A business had a customer-facing portal and several workflows built around a CRM, a payment provider and a hosted front-end builder. Parts of the experience looked finished. Underneath, there was no application layer holding it together, so the platform worked only as long as nobody leaned on it. The job was to build that foundation while the product stayed in use.
The Problem
Critical functionality was spread across the CRM, the payment provider, the front-end builder and a handful of separate workflows, with nothing coordinating them. That created five specific problems:
- Fragmented architecture. No single place owned the business logic, so every tool held a partial picture.
- No dedicated backend. Nothing consistently managed application state, authentication or data persistence.
- Disconnected subscriptions. Billing, membership access and CRM account provisioning were not fully linked, so payment status and platform access could drift apart.
- Legacy customers. Existing accounts and subscriptions had to keep their current billing arrangements, with no duplicate accounts and no disrupted access.
- Operational fragility. Platform-specific workflows and manual steps made the system hard to maintain, troubleshoot and extend.
Investigation
The useful question was not "what is broken?" but "where does each fact actually live?" Mapping three basic facts showed the problem clearly. Who is paying lived in the payment provider. Who has access lived partly in the CRM and partly in the front end. Who submitted what lived wherever a workflow happened to drop it. The same person could be correct in one system and wrong in another, and nothing could say which to believe.
Two decisions followed from that. The first was build versus buy for authentication. Hosted auth products handle login well, but login was not the hard part here. The hard parts were checking entitlement against the payment provider and attributing submissions reliably, and both would have needed custom logic wrapped around a third party anyway. A small purpose-built backend was less to maintain.
The second was about trust. If a user's identity travels with a submission in the form data or the URL, anyone who can edit a request can change it. That design is only as trustworthy as the browser. The rule that came out of this was that identity is established on the server, once, at login, and everything afterwards reads from it.
BEFORE
Payment CRM Front-end Separate
Provider Builder Workflows
| | | |
+----------+-----+----+-------------+
|
each holds part of the truth,
nothing coordinates them
|
v
payment status and platform
access drift apart
AFTER
Front End
|
v
Application Backend (one source of truth)
|
+--> Payment Provider (valid subscription?)
+--> Database (users, reviews, history)
+--> CRM (customers, provisioning)The Solution
A dedicated Node.js and Express backend, with PostgreSQL through Supabase for persistent data, sitting between the front end and the tools it used to depend on.
- Entitlement checks against the payment provider. An account is only created, and access only granted, when a valid subscription exists for that person, including the case where one person has several customer records.
- CRM integration for customer management and provisioning.The backend finds an existing contact before creating one, so the CRM does not fill up with duplicates.
- Signed sessions and server-side identity. Passwords are hashed, and every later request is identified from the verified session rather than from anything the browser sends.
- Legacy customers handled deliberately. Existing accounts and subscriptions were given special handling so billing arrangements stayed intact and nobody ended up with a duplicate account.
- The Business Review feature. Structured data storage, PDF generation, historical records, synchronisation with the CRM and error-recovery mechanisms.
The submission endpoint shows the identity rule in one place: the user comes from the verified session, and nothing about the user is read from the request body.
reviews.jsrouter.post("/reviews/submit", requireAuth, async (req, res, next) => {
try {
// Identity comes from the verified session, never from the request body
const user = req.user;
const { reviewData, clientEmail } = req.body;
const contactId = await upsertCrmContact(clientEmail);
await saveReview({ userId: user.id, contactId, reviewData });
await sendToCrm(contactId, {
reviewData,
submittedByName: user.name,
submittedByEmail: user.email,
});
res.json({ status: "submitted" });
} catch (err) {
next(err);
}
});Engineering Trade-offs
Every fact needs one source of truth, and it should never be the browser.
The main trade-off was building a foundation instead of adding more features on top of the existing structure. Continuing to extend the old setup would have produced visible progress sooner. It would also have made every later change harder, because each new feature would have inherited the same scattered state.
Trust decisions went on the server even though a front end already existed and appeared to work. Doing the checks in the browser would have looked identical in a demo, and it would have left the one thing the business cared about, correct attribution and correct access, dependent on the honesty of whoever was using the page.
The first version was also deliberately narrow. It used a single session type with a normal expiry, with no refresh tokens, no retry queues for every integration and no complicated roles. Each of those is a reasonable later addition, and leaving them out kept the security surface small enough to reason about while the product was live. One limit was accepted knowingly: in that first version, entitlement was checked when an account was created, not on every login, so a lapsed subscription was not caught automatically. It was recorded as the first thing to add if the business needed it.
Challenges
- Building under a live product. The platform was in use while it was being built, so changes had to land without disrupting existing customers, and anything touching accounts or billing had to be safe for people who were already paying.
- A build that only failed in production. The first deployment broke because dependency folders compiled on a Mac had been committed to git, and the hosting platform runs Linux. The fix was to remove them from the repository, regenerate dependencies cleanly and pin the runtime version so local and hosted environments matched.
- A browser that would not send the data. The CRM's webhook rejected requests made directly from the browser. Moving that call behind a small server-side proxy removed the restriction and preserved the request format.
- Email without DNS access. The usual way to send transactional email needs DNS records, and nobody on the team could reach the domain's DNS account. Switching to authenticated SMTP, with short-lived stateless tokens for password resets, removed the dependency.
Outcome
- ✓ Access follows payment status, because the backend checks the payment provider rather than trusting another tool's copy of it
- ✓ Every submission attributed to the logged-in user on the server, with no way to alter it from the browser
- ✓ Existing customers kept their billing arrangements without duplicate accounts or lost access
- ✓ Reviews stored with a full history, generated as PDFs and synchronised to the CRM, with error recovery built in
- ✓ One application layer that can be extended without rework, replacing a collection of loosely connected tools
Reflection
The most useful habit on this project was asking, for each feature, "which system is the source of truth for this?" and refusing to accept "the browser" or "whichever tool saw it last" for anything that mattered. Once those answers were fixed, the rest could be built incrementally on top of them, even with the product live. The known limit in the first version is the other lesson: it is better to state plainly what a design does not yet cover than to let a reviewer, or a customer, find it first.