What it is
A printing and gifting business with a part-built catalogue and admin system, and a developer who was no longer available. The site ran. The question was what it would cost to finish, which is a question that cannot be answered by looking at the screens.
The engagement began as a written audit against the running code rather than a quote. Nine risks were recorded with file references and a severity, and the audit document is what the client approved before any rebuilding started.
One change was made during the audit itself, before anything was read in full.
The problem
Most of the application had never been committed
The repository contained a single commit — an untouched framework starter. Everything after it, including the entire database schema and the specification document, was untracked. One routine clean command would have destroyed the project with no warning and no copy.
Every amount was displayed a hundred times too high
Amounts were stored correctly as integer paise, and the display never divided by a hundred. An item costing 499 rupees rendered as 49,900. The formatting was duplicated in two files, which is precisely why the bug had survived: fixing the one somebody noticed left the other still lying.
An upload endpoint signed credentials for anyone who asked
The route that issues signed media-upload credentials had no session check and took the destination folder straight from the request body. An anonymous caller could mint credentials for any folder in the client's media account, including one holding existing files.
Eleven server actions had no authorisation at all
Alongside a dashboard that was readable without logging in. The functions that mutate data were reachable by anyone who knew they existed.
Cache invalidation pointed at routes that did not exist
Every revalidation target named a path that had been renamed or never created, so the admin showed stale data after every save. The symptom reported by the client was that saving did not work.
Single characters were silently disabling whole systems
One stray percent sign in a colour declaration killed it without an error, taking a palette with it. A font variable defined in terms of itself meant the entire site rendered in the browser default face while the design document said otherwise.
Errors were being swallowed where they were raised
Catch blocks discarded the real failure and returned a generic message, so a validation problem and a database outage were indistinguishable from the outside. Cost fields from internal records were also being serialised to the browser.
What we built
Commit first, audit second, rebuild third
The only change made before reading anything was committing the untracked tree, with a message saying exactly what it was. You cannot audit something you might accidentally destroy, and the snapshot costs nothing.
Money was eliminated as a class of bug, not fixed as an instance
Amounts are integer paise everywhere and pass through exactly one formatting function. There is no second place for a currency to be rendered, so the hundred-fold error cannot recur in a file somebody forgets.
Uploads were closed properly rather than patched
Session check first, the destination folder validated against a server-controlled prefix rather than taken from the caller, and limits on type, size and count. Signed direct upload is the right pattern; unauthenticated signed direct upload is a gift to a stranger.
Every risk was written down with its file, its severity and its fix
The audit is a document the client owns, not a verbal summary. It is also what made the scope of the rebuild arguable rather than asserted — the work was priced against a list both sides could read.
One deferral, stated in writing with its reason
Business messaging over the official API needs verification and a payment method the client did not have. Rather than blocking the project on paperwork, we shipped free deep links that work today, left the message tables and configuration placeholders in place, and documented that enabling the real integration later is one provider file. Deferring is not skipping.
What the client has now
- The project is in version control with its history, and no longer one command from deletion.
- Amounts are correct, and there is one code path by which a currency value can be rendered.
- The upload endpoint requires a session and controls its own destination.
- The client holds a written audit that names every risk, its location and its resolution.
- An automated check suite — types, lint, formatting and tests — runs green on every change.
What we took from it
Duplication is why bugs survive being noticed
The hundred-fold display error had almost certainly been reported before. It survived because the same formatting logic existed in two files, so fixing the page somebody complained about left the other one wrong — and the next report looked like a regression rather than the other half of the original defect. When something must be true everywhere, there has to be exactly one place it is decided.