Data model
The CSV you asked for.
The database you'll grow into.
Every file becomes one row in documents.csv with exactly the brief's 15 columns, in order, UTF-8. The same rows can also go into a Postgres catalogue (Supabase here), designed for many ISOs, full revision history and retrieval-augmented AI.
documents.csv · column contract
One row per file, and one per zip member. Dates are YYYY-MM-DD, timestamps ISO 8601 UTC.
| # | Column | Meaning | Example |
|---|---|---|---|
| 1 | source_iso | SPP or PJM | PJM |
| 2 | source_key | Unique key: SPP doc_id, PJM full /-/media/… path (zip members: key!/member) | /-/media/DotCom/committees-groups/committees/mrc/2026/20261118/20261118-agenda.pdf |
| 3 | source_url | Full URL the file was downloaded from | https://www.pjm.com/-/media/…/20261118-agenda.pdf |
| 4 | file_name | The file name as saved | 20261118-agenda.pdf |
| 5 | file_extension | pdf, docx, xlsx, zip, … | pdf |
| 6 | file_size_bytes | Size of the downloaded file | 184213 |
| 7 | content_sha256 | SHA-256 of the file contents | 9f2c…e41a |
| 8 | title | Link text / title exactly as shown on the listing | Agenda |
| 9 | posting_date | Posting date from the listing, YYYY-MM-DD | 2026-11-18 |
| 10 | container_id | SPP folder ID or PJM committee code | mrc |
| 11 | container_path | SPP folder breadcrumb or PJM page path | committees-and-groups/committees/mrc |
| 12 | meeting_date | Meeting date from the path or title, YYYY-MM-DD | 2026-11-18 |
| 13 | parent_zip | File name of the parent .zip for extracted members, else blank | (blank) |
| 14 | local_path | Relative path of the saved file in the delivered tree | PJM/committees-groups/committees/mrc/2026/20261118/20261118-agenda.pdf |
| 15 | crawl_timestamp | When the file was downloaded (UTC, ISO 8601) | 2026-11-26T03:41:09Z |
Postgres catalogue
Three schemas, each with one job
The catalogue: one row per document, immutable versions underneath.
sources
SPP, PJM active. MISO, ERCOT, CAISO, NYISO, ISO-NE pre-registered so a new ISO is a new adapter, not a migration.
- code PK
- name
- base_url
- region
- active
containers
SPP folder or PJM page/library section, with its human breadcrumb.
- source_code FK
- container_id
- container_path
- kind
- first/last_seen_at
documents
Identity of a file at a source. Zip members link to their zip. Disappearing files get removed_at, never deleted.
- source_code + source_key UQ
- title
- posting_date
- meeting_date
- parent_document FK
- category
- removed_at
document_versions
Every distinct content hash is a new revision. Nothing is overwritten.
- document_id FK
- revision
- content_sha256
- file_size_bytes
- local_path
- storage_uri
- crawl_timestamp
document_catalog (view)
Latest version per document, exactly the brief's CSV shape.
- 15 CSV columns
- + revision
- + category
Operations: what each run did, and anything that went wrong.
crawl_runs
Mode, cutoff, timing and stats for every run.
- mode
- since
- status
- started/finished_at
- stats jsonb
container_coverage
Files listed vs in scope per container per run. This is the coverage report.
- run_id
- container_ref
- files_listed
- files_in_scope
- earliest
- latest
- note
crawl_misses
Failures with the error text. Resolved automatically when a later run succeeds.
- url
- error
- occurred_at
- resolved_at
Ready for LaReg's regulatory AI: text, chunks, embeddings, alerts.
document_text
Extracted text metadata per version (extractor, pages, language).
- version_id PK
- extractor
- page_count
- text_chars
document_chunks
RAG chunks with pgvector embeddings (1536-d), page ranges kept for citations.
- version_id
- chunk_no
- page_from/to
- content
- embedding vector
watchlists
Saved queries such as 'new SPP tariff studies' that can drive email or Slack alerts.
- name
- query jsonb
- notify[]
Design principles
Immutable history
Versions are append-only, so you can always answer "what did this tariff say on March 3?"
Natural keys from the source
SPP doc_id and PJM media path. Re-runs upsert and never duplicate.
Security by default
Row-level security on every table. The browser only reaches narrow, audited RPC functions.
Search-ready
Trigram index on title + file name, date indexes per ISO, vector column for semantic search.
Multi-ISO from day one
Every row carries its ISO code, so adding MISO or ERCOT needs no schema change.
CSV stays the contract
The database is optional. documents.csv alone meets the brief and imports anywhere.