> 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)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://grouple.gitbook.io/docs/supabase/supabase-overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
