# Architecture note

## Recommended stack: Next.js + Supabase/Postgres

This is a generalist two-sided marketplace web app: auth with two roles, CRUD-heavy profiles and listings, a booking state machine, Stripe payments, and notifications — no heavy compute, ML, or offline-first mobile requirement. Supabase gives Postgres with row-level security for owner/walker/admin data isolation, built-in auth, and storage for profile photos in one deployable, letting a small team or solo founder ship fast and layer PostGIS later for radius search without switching platforms.

## Component diagram

- Next.js app (web) -> Supabase Auth (email/password, roles: owner/walker/admin)
- Next.js app -> Supabase Postgres (profiles, bookings, reviews, audit log) via RLS-scoped queries
- Next.js app -> Supabase Storage (profile photos)
- Next.js server routes / webhooks -> Stripe (checkout, connected accounts, payouts, webhooks)
- Next.js app -> Geocoding provider (postcode -> lat/lng) -> Postgres/PostGIS radius queries
- Scheduled jobs (Supabase cron / edge functions) -> booking reminders, rating prompts, payout scheduling
- Next.js app -> Push/Email provider (booking and message notifications)
- Admin dashboard (Next.js routes, admin-role gated) -> Postgres audit log, moderation queues

## Auth approach

Supabase Auth (email/password) with a role field (owner/walker/admin) enforced via Postgres row-level security policies, plus email verification and password reset handled by Supabase's built-in flows.

## Hosting

Next.js app deployed on Vercel; Supabase hosts Postgres, Auth, and Storage as a managed backend, minimizing infrastructure to maintain at launch scale.

## What NOT to build custom

- Stripe Connect for card processing, PCI-compliant checkout, and walker payouts instead of custom payment/ledger code.
- Supabase Auth for signup/login/verification/reset instead of a custom auth system.
- A transactional email provider (e.g. Resend) instead of a self-hosted mail server.
- A managed geocoding API (e.g. Mapbox or Google Geocoding) instead of building postcode-to-coordinates logic.
- A managed push notification service (e.g. Expo Push/FCM) instead of custom device token infrastructure.