Blame

cf29e8 admin 2026-08-07 11:34:44
init
1
---
2
title: Data Model (Supabase)
3
aliases: [Supabase Schema, Database Schema]
4
tags: [3netra/wiki, supabase, data-model, diagrams]
5
product: 3netra Meta Android App
6
source_repository: 3Netra-ai/3n_meta_android
7
source_ref: origin/prod
8
source_revision: b48aada8fd5427b5db0c02945569963c4ae543c8
9
last_verified: 2026-08-06
10
up: "[[Home]]"
11
---
12
13
# Data Model (Supabase)
14
15
> [!warning] No DDL is committed
16
> No migrations, seed, or `CREATE TABLE` statements are present. The Kotlin payload/data classes and table names below show **what the client expects**, not an authoritative deployed schema. Local config requests Postgres 17, API port 55321, and DB port 55322; it has no schema paths.
17
18
## Entity Diagram
19
20
```mermaid
21
erDiagram
22
AUTH_USERS ||--|| USER_PROFILES : "id"
23
USER_PROFILES ||--o| STUDENTS : "student"
24
STUDENTS ||--|| STUDENT_SETTINGS : "student_id"
25
STUDENTS ||--o{ SESSIONS : "student_id"
26
STUDENTS ||--o{ FACE_EMBEDDINGS : "student_id"
27
SESSIONS ||--o{ SESSION_EVENTS : "session_id"
28
STUDENTS ||--o{ EMERGENCY_ALERTS : "student_id"
29
AUDIT_LOGS }o--|| AUTH_USERS : "actor_id"
30
```
31
32
## Tables (columns as used in code)
33
34
| Table | Columns | Notes |
35
|---|---|---|
36
| `user_profiles` | `id`, `role`, `first_name`, `last_name` (+ UI reads `avatar_url`) | Client attempts bootstrap/query |
37
| `students` | `id`, `date_of_birth`, consent/opt-out fields | Client payload; values/workflow are not validated in repo |
38
| `student_settings` | voice, language, capture and battery fields | Client queries/updates and declares a Realtime subscription |
39
| `sessions` | `student_id`, `mode`, `session_summary`, `offline_mode`, `created_at` | Client attempts an insert; Today's Story itself is in-memory |
40
| `face_embeddings` | `id`, `student_id`, `person_name`, CSV embedding | Active enrollment writes and matching reads this cloud table |
41
| `session_events` | event concepts | Mentioned in repository code/docs; table contract unverified |
42
| `audit_logs` | actor/action/entity fields | Repository method attempts inserts; not compliance proof |
43
| `emergency_alerts` | SOS payload fields | Service attempts insert but GPS/summaries are TODO |
44
45
> [!todo] Planned but absent from code
46
> `schools`, `caregiver_students`, `iep_goals`, `progress_reports` — designed in Mayukh's schema work, PRD-level only.
47
48
## Compliance Design (FERPA / Higher Ed Privacy)
49
50
- **Face data:** FaceNet runs on-device, but active code writes/reads CSV embeddings in `face_embeddings`. The AES/90-day utility is not invoked, including its retention method.
51
- **Consent/audit/RLS:** client fields and insert methods exist; no versioned schema, policy, consent flow, audit coverage, or test proves their operation.
52
- **Media:** the SAM bucket has no lifecycle rule; only a comment suggests one.
53
- **Vendor flow:** scene/photo bytes are sent to the Supabase Edge Function for VLM analysis. Do not claim local-only face or media handling.
54
55
See [[11-Security-Privacy-Compliance]] for the audited gap analysis.
56
57
## Auth Model
58
59
- Providers: email/password, email OTP, Google (IDToken via Credential Manager)
60
- Deep links: `threenetra://` + `http://localhost:3000` for OAuth/email callbacks
61
- Roles today: `student` (role field exists for future teacher/parent/caregiver)
62
- Teacher gating in-app via local BCrypt PIN (`3netra_secure` prefs), not a backend role — **gap to close**
63
64
---
65
66
> [!tip] Navigation
67
> ⬅️ [[07-Services-APIs-Vendors|Services, APIs & Vendors]] · 🏠 [[Home]] · ➡️ [[09-Design-System|Design System]]