Skip to content

feat: Canadian corporate registry ingestion pipeline#3

Open
xrendan wants to merge 1 commit into
mainfrom
xrendan/corp-registry-ingest
Open

feat: Canadian corporate registry ingestion pipeline#3
xrendan wants to merge 1 commit into
mainfrom
xrendan/corp-registry-ingest

Conversation

@xrendan

@xrendan xrendan commented Mar 23, 2026

Copy link
Copy Markdown
Member

Summary

  • Full rename: OrganizationGovernmentEntity (tables, columns, spending_deviations VIEW, all references across 31+ files)
  • Corporate registry pipeline: Ingest corporate entity data from every Canadian jurisdiction — federal (ISED XML, 500K+), BC (OrgBook API, 2.4M), Quebec (CSV ZIP), and provincial HTML scrapers (ON, AB, SK with shared concern for remaining provinces)
  • Enrichment datasets: ODBiz (450K businesses with NAICS codes) and ODA (10M geocoded addresses per-province) from Statistics Canada
  • Director tracking: CorporateDirector + DirectorAppointment models with ISED JSON API enrichment for federal corporations
  • Admin dashboard: Per-source "Run" buttons and "Ingest All Sources" bulk trigger, all via Solid Queue background jobs
  • REST API: New endpoints for corporate entities, corporate directors, and business establishments
  • QA-verified against real government data: 62K ODBiz records, 14K federal ISED records, 1.7M ODA address records

New models

CorporateEntity, CorporateDirector, DirectorAppointment, CorporateRegistration, CorporateEntityAlias, BusinessEstablishment, StandardizedAddress

New normalizers/scrapers

CorporateNormalizer (ISED SAX), OrgbookBcNormalizer, QuebecRegistryNormalizer, OdbizNormalizer, OdaNormalizer, OntarioObrScraper, AlbertaCoresScraper, SaskatchewanIscScraper

Database

10 migrations: pg_trgm extension, Organization→GovernmentEntity rename, 7 new tables, scraping progress column

Test plan

  • 77 tests, 239 assertions, 0 failures
  • Federal ISED XML SAX parser verified against real OPEN_DATA_SPLIT.zip (14K corps parsed)
  • ODBiz normalizer verified against real ODBus_2023.zip (62K establishments)
  • ODA normalizer verified against real ODA_AB_v1.zip (1.7M addresses)
  • OrgBook BC normalizer verified against real API response structure
  • Admin ingestion triggers tested (per-source and bulk)
  • Run bin/rails db:migrate on production Supabase
  • Run bin/rails db:seed to register new data sources
  • Trigger ingestion via admin dashboard or rake data:ingest_all

🤖 Generated with Claude Code

Add corporate entity tracking across all Canadian jurisdictions to connect
government fiscal data with the actual entities receiving public money.

Key changes:
- Rename Organization → GovernmentEntity (full DB rename: tables, columns, VIEW)
- Add CorporateEntity, CorporateDirector, DirectorAppointment, CorporateRegistration models
- Add BusinessEstablishment (ODBiz) and StandardizedAddress (ODA) for enrichment
- Federal ISED XML normalizer (SAX parser, 500K+ records, batch upserts)
- BC OrgBook API normalizer (2.4M entities, paginated)
- Quebec registry CSV normalizer (6-file ZIP)
- Provincial HTML scrapers (ON, AB, SK) with shared concern
- ODBiz CSV normalizer (450K businesses with NAICS codes)
- ODA CSV normalizer (10M addresses per-province with geocoding)
- Director enrichment via ISED JSON API
- Admin dashboard with per-source and bulk ingestion trigger buttons
- REST API endpoints for corporate entities, directors, and business establishments
- pg_trgm extension with GIN indexes for fuzzy name matching at scale
- Production rake tasks (data:ingest_all, data:ingest_federal, etc.)
- QA-verified against real government data (62K ODBiz, 14K ISED, 1.7M ODA records)

77 tests, 239 assertions, 0 failures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@xrendan xrendan force-pushed the main branch 2 times, most recently from baa6a90 to 5ce141b Compare April 4, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant