How datavenezuela/vzla_dedup works
1. Repository purpose
- This is a Python data-pipeline repo for collecting missing-person reports from many external sources, normalizing them, protecting PII, deduplicating records, and preparing clean entities for downstream publication.
- The codebase is organized around a scraping/cleaning pipeline now, with consolidation and public API serving defined as separate downstream stages.
2. Core runtime boundary
- The main executable surface is scrapers/cli.py, which drives scrapers/pipelines/run_pipeline.py.
- The pipeline is configured by source YAML in scrapers/config/, especially the demo offline config and a thin production config that maps opaque source_id UUIDs to parsers.
3. Source ingestion layer
- scrapers/adapters/ is the fetch layer and abstracts how raw content is retrieved: HTTP APIs, HTML pages, PDFs, Playwright-rendered pages, RSS, local files, and search/X-specific access.
- Adapter output is normalized into a RawContent-style boundary so parsers can work against content rather than transport details.
4. Parsing layer
- scrapers/parsers/ converts raw content into typed domain objects, primarily Person records, plus related entities like events or acopio centers where supported.
- The repo includes a synthetic demo parser and a concrete parser for a specific source, showing the intended pattern: one parser per source family, registered in the pipeline.
5. Domain model boundary
- scrapers/models/ defines the typed schema used throughout the pipeline: Person, Event, AcopioCenter, and SourceConfig.
- Pydantic-backed models act as the contract boundary between parsing, sanitization, validation, deduplication, and export.
6. Normalization and extraction
- scrapers/normalizers/ handles canonicalization of dates, locations, person names, text, phonetics, and NLP extraction.
- This is where source-specific variability is reduced into a shared representation used later for matching and quality scoring.
7. PII protection and security boundary
- scrapers/sanitizers/ enforces the repo’s strict PII policy: detection, redaction, tokenization, and minor-protection logic.
- The README and security docs make clear that cédulas and phones are HMAC’d before persistence, logs must not contain PII, and the public path must never expose direct personal data.
8. Persistence/export stages
- scrapers/exporters/ represents the bronze/staging/quarantine boundary: provenance export, quarantine export, and staging export.
- The staging exporter writes into Supabase via the scrapers/jobs/supabase_adapter.py and related job/materialization code, while quarantine exists for records that cannot be safely or cleanly processed.
9. Consolidation and gold generation
- scrapers/dedup/ contains the matching and clustering logic: fingerprints, blocking, similarity, clustering, and deduplicator orchestration.
- scrapers/jobs/ then turns dedup outputs into consolidated “gold” structures via a consolidation job, gold writer, and materializer, indicating a clear progression from raw/staging records to canonical entities and history.
10. Validation and governance
- scrapers/validators/ enforces source quality and record quality, including confidence scoring and source-level validation.
- The repo also contains ADRs for governance, versioned contracts, source identity handling, and PII retention, which are important architectural constraints rather than just documentation.
11. External dependencies and operational model
- The implementation relies on Supabase for ingestion/staging persistence, and the README describes a planned Cloudflare Worker + D1 public API layer.
- CI/workflows in .github/workflows/ separate build, ingest, consolidation, and public-index generation, reflecting that the system is composed of multiple pipeline jobs rather than one monolith.
12. Testing and reproducibility
- scrapers/tests/ is extensive and fixture-driven, covering adapters, parsers, sanitizers, deduplication, pipeline execution, contract validation, and database/job adapters.
- scrapers/sample_data/ and scrapers/runtime_output/ support offline/demo execution, which is a meaningful architectural feature: the pipeline can be exercised without live sources for development and CI.
13. Shared utilities
- shared/ holds cross-cutting helpers such as hashing and location data, suggesting a small shared utility layer outside the scraping package.
- verification/ exists as a separate boundary for human or downstream review workflows, aligning with the project’s emphasis on candidate validation.
Main entry points: run_pipeline.py Run pipeline · exporters Exporters · adapters Adapters · models Models
Components 18
Pipeline runtime
Entry points and orchestration for offline and production runs.
- CLI · Main executable surface for running pipeline jobs.
scrapers/cli.py - Run pipeline · Coordinates source loading, parsing, normalization, and export.
scrapers/pipelines/run_pipeline.py - Source config · Demo and production source configuration, including source_id to parser mapping.
scrapers/config
Source ingestion
Source loading, fetching, and raw content adapters.
- Source loader · Loads configured sources and source metadata.
scrapers/sources/loader.py - Adapters · Retrieves raw content from APIs, HTML, PDFs, Playwright, RSS, files, and search/X.
scrapers/adapters
Domain and parsing
Typed models and parser boundary between raw content and structured records.
Normalize and protect
Canonicalization, extraction, sanitization, and validation.
- Normalizers · Standardizes dates, locations, names, text, phonetics, and extracted entities.
scrapers/normalizers - Sanitizers · Detects, redacts, tokenizes, and protects sensitive data before persistence or logs.
scrapers/sanitizers - Validators · Enforces source quality, confidence, and record-level validation rules.
scrapers/validators
Export and consolidate
Staging, quarantine, deduplication, and gold materialization.
- Exporters · Writes provenance, quarantine, and staging outputs.
scrapers/exporters - Dedup · Fingerprints, blocks, scores, and clusters duplicate person records.
scrapers/dedup - Jobs · Turns dedup outputs into consolidated gold entities and materialized records.
scrapers/jobs - Supabase adapter · Database-facing adapter used by staging and materialization jobs.
scrapers/jobs/supabase_adapter.py
Shared boundaries
Cross-cutting helpers and human review boundary.
- Shared utils · Common hashing and location helpers shared across the repository.
shared - Verification · Human or downstream review boundary for candidate validation workflows.
verification
Governance
Security, contracts, and source policy constraints.
- Security docs · PII handling, commit safety, and source policy constraints.
scrapers/security - ADRs · Architecture decisions covering serving, security, contracts, retention, and gold model.
docs/adr
Connections 20
- CLI → Run pipeline: starts · CLI invokes the pipeline runner.
- Run pipeline → Source config: reads · Pipeline is configured by source YAML and runtime settings.
- Run pipeline → Source loader: loads · Resolves configured sources and source identity.
- Source loader → Adapters: fetches via · Source definitions drive the transport-specific adapter layer.
- Adapters → Parsers: raw content · Adapters normalize transport results into parser-ready content.
- Parsers → Models: builds · Parsers emit typed domain objects.
- Models → Normalizers: canonicalized by · Structured records are normalized for shared representation.
- Normalizers → Sanitizers: protects · Normalization feeds PII protection and tokenization.
- Sanitizers → Validators: checks · Sanitized records are validated for quality and contract compliance.
- Validators → Exporters: approved records · Validated records move to staging, provenance, or quarantine exports.
- Exporters → Supabase adapter: writes · Staging and materialization persist through the Supabase adapter.
- Exporters → Dedup: feeds · Staged data becomes input for matching and clustering.
- Dedup → Jobs: gold candidates · Deduplicated clusters are handed to consolidation jobs.
- Jobs → Supabase adapter: materializes · Gold writer and materializer persist consolidated structures.
- Jobs → Verification: reviewable · Consolidated candidates can flow into human validation workflows.
- Models → Security docs: governed by · Model fields and persistence behavior are constrained by PII policy.
- Run pipeline → ADRs: bounded by · Pipeline behavior reflects documented architecture decisions.
- Adapters → Shared utils: uses · Adapters reuse common helpers such as hashing and shared location data.
- Dedup → Shared utils: uses · Matching relies on shared hashing and helper utilities.
- Exporters → Security docs: enforces · Exports must respect PII retention and redaction requirements.