All articles

MVP architecture: BOLA, RLS, signed webhooks, and data that survives launch

The practical backend minimum for an MVP: preventing OWASP API1 (BOLA), securing Supabase and Firestore rules, building idempotent webhooks, and planning recovery.

Why “we’ll fix architecture later” costs more than the MVP itself

Good MVP architecture is not microservices, Kubernetes, or a 40-page design doc. It is four concrete engineering decisions that become painfully expensive to retrofit after real customers arrive: which system owns each fact, how the server verifies object-level access, how integrations survive duplicates and retries, and how the team rolls back a bad release.

Whether you ship Next.js + PostgreSQL, FlutterFlow + Firebase/Supabase, or Bubble, domain rules do not disappear. If access checks live only as conditional visibility on UI buttons, your app guards the interface while leaving the underlying API wide open.

The #1 MVP vulnerability: OWASP API1:2023 (BOLA / IDOR)

Broken Object Level Authorization (BOLA, formerly IDOR) holds the top spot in the OWASP API Security Top 10 for a reason. An endpoint checks that a user is logged in (valid JWT or session cookie), accepts an object ID from the request (such as GET /api/orders/554), and returns the database row without checking whether that order actually belongs to the caller.

Common MVP mistakes include trusting a client-supplied user_id in query strings or request bodies and exposing sequential integer IDs (1, 2, 3...) that make enumeration trivial. The rule is straightforward: always derive user identity and role from the verified server session or token, and scope every query to the owner (WHERE id = $1 AND owner_id = $currentUser). UUIDs deter casual guessing, but they never replace real authorization checks.

Where access rules actually break in Supabase, Firestore, and Bubble

Modern BaaS platforms let client SDKs query databases directly, which makes database-level rules the sole barrier between customer data and the public internet. Each platform has well-known failure modes.

In Supabase (PostgreSQL), teams forget to enable Row-Level Security on new tables, leave temporary USING (true) policies in production, skip indexes on tenant_id or user_id columns (causing implicit RLS WHERE clauses to crawl under load), and overlook that standard Postgres Views bypass RLS unless created with security_invoker = true, while Storage buckets require separate policies. The service_role key bypasses all RLS and must never ship in client bundles.

In Firebase Firestore, common mistakes include leaving test-mode rules (allow read, write: if true), protecting writes while leaving reads open to any signed-in user (allow read: if request.auth != null), assuming rules on /users/{uid} cascade automatically to subcollections (they do not), or trusting a client-writable role field instead of server-signed Firebase Custom Claims. In Bubble, Privacy Rules serve the same boundary: hiding a field in the editor still sends it in the browser’s network payload.

Payments and external webhooks: signatures, idempotency, and event order

A user landing on /success after checkout is only a UI hint that anyone can open directly. The authoritative proof of payment is a signed server-to-server webhook (Stripe, Paddle, WayForPay) or a direct server-side status check against the provider’s API.

Following Stripe’s documented webhook practices, a resilient handler rests on four pillars. First, verify the cryptographic HMAC signature against the raw request body before JSON parsing—reformatted whitespace or reordered keys invalidate the signature. Second, providers use at-least-once delivery, so duplicates are guaranteed: record event.id in a database table with a UNIQUE constraint so concurrent duplicate deliveries fail atomically rather than relying on a racy if (!exists) check in application code.

Third, return a 2xx response quickly and offload slow work (PDF generation, emails, CRM sync) to a background queue so timeouts do not trigger retry storms. Fourth, expect out-of-order delivery: a delayed event must never regress an already completed, cancelled, or refunded order back to an earlier state.

Use explicit state machines instead of tangled boolean flags

Piling up independent booleans (is_paid, is_cancelled, is_confirmed) inevitably creates impossible combinations. Model critical entities with an explicit state machine—such as draft → awaiting_payment → confirmed → completed or cancelled / refunded—and enforce allowed transitions and caller roles on the server.

For contentious operations (slot bookings, credit deductions, inventory claims), enforce uniqueness and atomicity in the database itself (composite unique indexes, transactions). In-memory server checks cannot stop two simultaneous requests from racing past each other.

The lightweight architecture and recovery package every MVP needs

An MVP does not need heavy documentation, but it does need a living baseline in the repository: a one-page component diagram, entity and state-transition definitions, a role access matrix, an integration inventory, and a release runbook. Secrets belong in a secret manager (such as Google Secret Manager), with staging and production strictly separated.

Finally, distinguish application rollback (such as shifting traffic back to a prior Cloud Run revision in a minute) from database recovery (Point-in-Time Recovery or backup restores). A backup whose restore procedure has never been rehearsed in an isolated environment is an assumption, not a recovery plan.

Sources and further reading

OWASP API Security Top 10: API1:2023 Broken Object Level Authorization ↗

Stripe Docs: Receive Stripe events in your webhook endpoint (signatures & idempotency) ↗

Supabase Docs: Row Level Security (RLS) & performance ↗

Firebase Docs: Structure Cloud Firestore Security Rules ↗

Google Cloud Well-Architected Framework: Reliability ↗