> For the complete documentation index, see [llms.txt](https://grouple.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://grouple.gitbook.io/docs/supabase/supabase-overview.md).

# Supabase Overview

### What Supabase Handles

Supabase is the core backend for Grouple. It’s not just a database — it handles a significant portion of the business logic:

<table><thead><tr><th width="261.86529541015625">Responsibility</th><th>How</th></tr></thead><tbody><tr><td>Primary database</td><td>PostgreSQL (20+ tables)</td></tr><tr><td>Authentication</td><td>GoTrue (JWT-based)</td></tr><tr><td>Email sending</td><td>Edge Functions (send-lead-email, send-proposal-email, reservation-confirmation-emails)</td></tr><tr><td>Business logic automation</td><td>14 Database Triggers</td></tr><tr><td>Complex queries</td><td>40+ RPC Functions</td></tr><tr><td>File storage</td><td>3 Storage buckets</td></tr><tr><td>Currency rates</td><td>Edge Function (update-exchange-rates)</td></tr><tr><td>AI proposal generation</td><td>Edge Function (generate-proposal)</td></tr><tr><td>OCR processing</td><td>Edge Function (mistral-ocr)</td></tr></tbody></table>

### [​](https://grouple.mintlify.app/supabase/overview#project-details)Project Details <a href="#project-details" id="project-details"></a>

<table><thead><tr><th width="212.37921142578125">Field</th><th>Value</th></tr></thead><tbody><tr><td>Project</td><td>Proposal maker</td></tr><tr><td>Organisation</td><td>grouple.in Org</td></tr><tr><td>Environment</td><td>Production (main branch)</td></tr><tr><td>Region</td><td>Supabase hosted</td></tr><tr><td>Connection</td><td>Via connection pooler (pooled connections from ECS)</td></tr></tbody></table>

### [​](https://grouple.mintlify.app/supabase/overview#authentication-flow)Authentication Flow <a href="#authentication-flow" id="authentication-flow"></a>

```
User signs up / logs in via Supabase Auth
        ↓
GoTrue issues JWT
        ↓
JWT used for:
  - Frontend direct Supabase CRUD (RLS enforced per user)
  - API requests to ECS backend (validated server-side)
        ↓
On new customer INSERT:
  DB Trigger: on_customer_created_link_enquiries
  → Links any pre-existing enquiries (submitted before signup) to this customer
```

### [​](https://grouple.mintlify.app/supabase/overview#row-level-security-rls)Row Level Security (RLS) <a href="#row-level-security-rls" id="row-level-security-rls"></a>

All tables have RLS enabled. Key patterns:

* **Merchants** can only see/edit their own venues, leads, proposals
* **Customers** can only see their own enquiries and proposals
* **Public** can read venues and submit enquiries (anonymous)
* **Service role** has full access (used by Edge Functions and workers)
