Skip to content

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.

Download the sample CSV
#ColumnMeaningExample
1source_isoSPP or PJMPJM
2source_keyUnique key: SPP doc_id, PJM full /-/media/… path (zip members: key!/member)/-/media/DotCom/committees-groups/committees/mrc/2026/20261118/20261118-agenda.pdf
3source_urlFull URL the file was downloaded fromhttps://www.pjm.com/-/media/…/20261118-agenda.pdf
4file_nameThe file name as saved20261118-agenda.pdf
5file_extensionpdf, docx, xlsx, zip, …pdf
6file_size_bytesSize of the downloaded file184213
7content_sha256SHA-256 of the file contents9f2c…e41a
8titleLink text / title exactly as shown on the listingAgenda
9posting_datePosting date from the listing, YYYY-MM-DD2026-11-18
10container_idSPP folder ID or PJM committee codemrc
11container_pathSPP folder breadcrumb or PJM page pathcommittees-and-groups/committees/mrc
12meeting_dateMeeting date from the path or title, YYYY-MM-DD2026-11-18
13parent_zipFile name of the parent .zip for extracted members, else blank(blank)
14local_pathRelative path of the saved file in the delivered treePJM/committees-groups/committees/mrc/2026/20261118/20261118-agenda.pdf
15crawl_timestampWhen the file was downloaded (UTC, ISO 8601)2026-11-26T03:41:09Z

Postgres catalogue

Three schemas, each with one job

iso.*

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
ops.*

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
ai.*

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.