## User Registration & Verification

    sequenceDiagram
      participant U as User
      participant W as Web (Next.js)
      participant DB as Postgres
      participant Mail as SMTP
      participant Admin as Admin

      U->>W: Submit registration form (email, password)
      W->>DB: Create pending user + verification token
      W->>Mail: Send verification email with token link
      U-->>Mail: Opens email
      U->>W: Click verify link
      W->>DB: Mark email verified (status = verified, awaiting approval)
      Admin->>W: Approves user
      W->>DB: Update status = approved
      U->>W: Login (email/password)
      W->>DB: Validate credentials, create session token
      W-->>U: Set session cookie

## Listing Creation & Approval

    sequenceDiagram
      participant Host as Host (logged in)
      participant W as Web/API
      participant DB as Postgres
      participant Mod as Moderator
      participant Public as Public visitor

      Host->>W: Open "New listing" and submit details (address, amenities, images)
      W->>DB: Save listing (status = PENDING)
      Mod->>W: Review pending listing
      W->>DB: Approve (status = PUBLISHED)
      Host-->>W: Listing appears in "My listings" and public browse
      Public->>W: Browse latest/map and fetch listing cover image

## Listing Removal by Owner/Moderator

    sequenceDiagram
      participant Owner as Owner/Moderator
      participant W as Web/API
      participant DB as Postgres
      participant Public as Public visitor

      Owner->>W: Click "Remove" on listing
      W->>Owner: Confirm removal
      Owner-->>W: Confirm
      W->>DB: Set removedAt timestamp, status = REMOVED
      W-->>Owner: Show updated state in "My listings"
      Public--xW: Listing hidden from browse/slug pages

## Profile Update (Name/Password)

    sequenceDiagram
      participant User
      participant W as Web/API
      participant DB as Postgres

      User->>W: Open profile page (requires session cookie)
      W->>DB: Fetch user record (email immutable)
      User->>W: Submit updated name and/or password
      W->>DB: Update fields (hash password if provided)
      W-->>User: Show "Profile updated"

## Rendering instructions

- Mermaid renders automatically in-browser via CDN; no local tooling required.
- Edit the Mermaid blocks inline in these HTML files.