Merci — A Bank App Where the Edge Cases Come First
A full-stack banking app I'm designing and building solo, to prove I can ship secure server logic, not just interfaces. I built the API first, audited it against OWASP and NIST guidance, and designed every screen around what the server actually enforces.
Designs. Front end in development.
Why a Bank App
I wanted to prove I can ship secure server logic, not just interfaces. A bank app forces the hard questions: how passwords are stored, how one user is kept out of another's account, and what happens when two withdrawals land at once.
The goal was a project a hiring team could open and question. A user signs up, logs in, starts with $50,000, and deposits or withdraws money, with every rule enforced on the server. I own all of it: the brand, the UX/UI design, the front end and the back end.
User email, passwordHash └─ Account accountNumber, balanceCents └─ Transaction[] type DEPOSIT | WITHDRAWAL amountCents always positive balanceAfterCents
Architecture
Merci is two separate programs: a React client people see, and an Express API that owns every rule and every dollar. Before a route touches the database, a request passes the rate limit, Zod validation and the token check. Because the API stands alone, a phone app could use it without changing the server.
Money is stored as whole cents, never decimals, so a bank can't lose a cent to rounding. Each transaction also saves the balance right after it, so the activity list shows a running balance with no math on the client. SQLite keeps local setup to one file; the Prisma models move to Postgres unchanged for deployment.
// OWASP + NIST checklist Already solid money logic, bcrypt, Zod, user ID from token only Fix now 7 gaps in login + server setup Before front end 3 more Progress 5 of 8 steps shipped, each with a test that proves it
The Audit
Once the API worked, I audited it against a checklist drawn from OWASP and NIST guidance. The money logic passed every check. The gaps were in login and server setup, which is where most real account takeovers start.
I found 7 gaps worth fixing now and 3 to fix before the front end ships, and I'm closing them one step at a time. Each fix comes with a test script in the repo that proves it, so anyone can rerun it.
// Unknown emails still run bcrypt, // against a dummy hash made at startup const passwordMatches = await bcrypt.compare( password, user?.passwordHash ?? DUMMY_HASH, ); // Avg login time before after // real email, wrong pw 56ms 56ms // unknown email 2ms 54ms
Login That Doesn't Leak
Every failed login already returned the same message, but timing gave it away. I averaged logins on a local copy: a wrong password on a real email took 56ms, while an unknown email came back in 2ms. Response time alone revealed which emails had accounts.
Now unknown emails are checked against a dummy hash made at startup, so both paths do the same work: 54ms vs 56ms. Emails are trimmed and lowercased so "Cam@Merci.dev" and "cam@merci.dev" are one account, and passwords are capped at 64 characters because bcrypt silently ignores anything past 72 bytes.
Layer 1 per email 5 failed / 15 min Layer 2 per device 20 failed / 15 min Layer 3 sign-ups 10 / hour // 15 wrong passwords at the same instant // before: all 15 checked // after: 5 checked, 10 blocked
Rate Limiting in Layers
My first lockout had a race condition. It read the failed-login count, added one, and wrote it back in a separate step, so requests arriving at the same instant all read the same old count. I proved it by firing 15 wrong passwords at once: all 15 were checked, when the cap was 5.
I replaced it with a per-email limiter that counts the instant a request arrives: now 5 are checked and 10 blocked. It counts any email typed in, real or not, so the lockout can't reveal who has an account. A per-device limit and a sign-up limit cover the other angles, and about 40 lines of lockout code were deleted along the way.
// Check AND subtract in one database step. // Check-then-subtract would let two // simultaneous withdrawals both pass // and overdraw the account. const updated = await tx.account.updateMany({ where: { userId: res.locals.userId, balanceCents: { gte: amountCents }, }, data: { balanceCents: { decrement: amountCents } }, }); if (updated.count === 0) return null; // → 422
Money That Always Adds Up
The classic bug: check the balance, then subtract. If two withdrawals arrive at the same moment, both pass the check and the account goes negative. Merci does the check and the subtraction in a single database step, so that can't happen.
Every balance change and its transaction record are saved together, or not at all. Amounts are validated with Zod: whole cents, positive, and capped at $10,000 per transaction. Account routes take the user ID from the verified token, never from the request, so no one can reach another user's money by changing an ID.
Test Before After Another site reads API allowed blocked Broken JSON stack trace generic error Server crash DB query generic error Short JWT_SECRET fails later won't start 65-char password accepted rejected " Mixed@Merci.dev " rejected mixed@merci.dev
Hardening and Testing
Step 4 of the audit locked down the server itself. The API now only answers Merci's own site, sends four security headers through Helmet, never shows stack traces, and refuses to start without a strong JWT secret. Before, a broken request came back as an HTML page exposing the database query and file paths.
Each step has its own test script: lockout races, login timing, sign-up limits, server hardening and account-number randomness. Account numbers now come from Node's crypto module instead of Math.random, and a million generated numbers all came out as valid 10-digit numbers.
The insufficient-funds screen, designed around the API's 422 response.
Designing for Trust
I took Merci from a brand guide to 25 artboards and two playable prototypes, desktop and mobile, each in empty, filled, loading and error states. The direction: luxury, clean and warm. Sand backgrounds, frosted-glass cards, one crimson accent, and three typefaces with strict jobs: Orange Avenue for the wordmark and balance, Priestacy for the customer's name, DM Sans for everything functional.
Every look-driven choice was checked against contrast and touch targets. Red never means money out: deposits are crimson, withdrawals are ink. The glass stays at 62% white because any thinner drops gray text below 4.5:1 contrast. Every target is at least 44px, and mobile inputs use 16px text so phones don't zoom in.
Screen Grounded in Too many attempts 5 failed logins per email → 15-minute lock (auth.ts) Signed out "Your session expired. Log in again." (middleware.ts) Still there? No idle timer yet: the 2-minute warning is a design assumption
Design Grounded in the Code
I tied the security screens to what my server already enforces, so the design never promises behavior the code doesn't have. The lockout screen uses the server's exact words and counts down from 15:00. It says "login attempts", never "account locked", to match a limiter built so a lockout can't reveal who has an account.
Where the design gets ahead of the code, I say so. The "Still there?" warning assumes an idle timer I haven't built yet, and it's first on the list below.
What's Next
Merci is a work in progress. Next up is building the React front end from these designs: login, dashboard, and the deposit and withdraw flows, porting the prototype's carousel and money-flow logic into components.
After that: the last three security steps (double-submit protection, token revocation and a breached-password check), the idle timer and password reset, automated tests with Vitest and Supertest on every push, and deployment on Postgres with a live link.