You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/supabase-data-architecture.md
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,42 @@ The main public tables are split into two groups:
15
15
- Source-of-truth tables that store real application records.
16
16
- Read-model tables that expose deliberately shaped data to a specific audience.
17
17
18
+
## Naming
19
+
20
+
### Source tables
21
+
22
+
Source tables are the canonical records. They are the place writes happen and
23
+
the place the application should treat as the source of truth.
24
+
25
+
For example, `public.listings.location` is the canonical listing location.
26
+
Other tables may copy or reshape that location for safe reads, but they do not
27
+
become the source of truth.
28
+
29
+
### Read models
30
+
31
+
A read model is a table shaped for a read use case rather than for canonical
32
+
storage. Peels uses read models when different audiences need different columns
33
+
from the same underlying records.
34
+
35
+
This avoids using base tables as both storage and public API. The base table can
36
+
keep all fields needed by the product, while each read model exposes only the
37
+
fields needed by its audience.
38
+
39
+
### `contact_cards`
40
+
41
+
`contact_cards` is Peels naming, not a Postgres or Supabase convention. It means
42
+
"small safe display/contact summary".
43
+
44
+
The important part is the audience boundary:
45
+
46
+
-`public_listings` is for signed-out public browsing and SEO.
47
+
-`listing_contact_cards` is for signed-in listing/contact/chat flows.
48
+
-`profile_contact_cards` is for signed-in profile display in allowed
49
+
relationships, especially chat participants.
50
+
51
+
If a future table needs a different audience or purpose, prefer a name that says
52
+
that audience clearly rather than blindly reusing `contact_cards`.
53
+
18
54
### `private`
19
55
20
56
`private` is not an exposed Data API schema. It is for database implementation details such as trigger functions, security-definer helpers, and internal-only tables.
@@ -77,6 +113,26 @@ Residential listings keep their description, accepted items, and rejected items
77
113
78
114
Rows are maintained by database triggers from `public.listings`.
0 commit comments