# datavenezuela/vzla_dedup architecture

> Architecture diagram of the GitHub repository datavenezuela/vzla_dedup, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/datavenezuela/vzla_dedup
- Repository: https://github.com/datavenezuela/vzla_dedup

## Overview

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: [`scrapers/pipelines/run_pipeline.py`](https://github.com/datavenezuela/vzla_dedup/blob/master/scrapers/pipelines/run_pipeline.py) (Run pipeline), [`scrapers/exporters`](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/exporters) (Exporters), [`scrapers/adapters`](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/adapters) (Adapters), [`scrapers/models`](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/models) (Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_pipeline["Pipeline runtime"]
  node_n_cli["CLI<br/>entrypoint<br/>[cli.py]"]
  node_n_pipeline["Run pipeline<br/>orchestrator<br/>[run_pipeline.py]"]
  node_n_config["Source config<br/>pipeline config"]
end

subgraph group_grp_sources["Source ingestion"]
  node_n_sources_loader["Source loader<br/>config loader<br/>[loader.py]"]
  node_n_adapters["Adapters<br/>fetch layer"]
end

subgraph group_grp_domain["Domain and parsing"]
  node_n_parsers["Parsers"]
  node_n_models[("Models<br/>domain schema")]
end

subgraph group_grp_transform["Normalize and protect"]
  node_n_normalizers["Normalizers<br/>canonicalization"]
  node_n_sanitizers["Sanitizers<br/>pii protection"]
  node_n_validators["Validators<br/>quality gates"]
end

subgraph group_grp_storage["Export and consolidate"]
  node_n_exporters["Exporters<br/>staging boundary"]
  node_n_dedup["Dedup<br/>matching"]
  node_n_jobs["Jobs<br/>consolidation"]
  node_n_supabase[("Supabase adapter<br/>persistence adapter")]
end

subgraph group_grp_shared["Shared boundaries"]
  node_n_shared["Shared utils<br/>cross-cutting"]
  node_n_verification(("Verification<br/>review boundary"))
end

subgraph group_grp_governance["Governance"]
  node_n_security["Security docs<br/>policy"]
  node_n_adr["ADRs<br/>governance docs"]
end

node_n_cli -->|"starts"| node_n_pipeline
node_n_pipeline -->|"reads"| node_n_config
node_n_pipeline -->|"loads"| node_n_sources_loader
node_n_sources_loader -->|"fetches via"| node_n_adapters
node_n_adapters -->|"raw content"| node_n_parsers
node_n_parsers -->|"builds"| node_n_models
node_n_models -->|"canonicalized by"| node_n_normalizers
node_n_normalizers -->|"protects"| node_n_sanitizers
node_n_sanitizers -->|"checks"| node_n_validators
node_n_validators -->|"approved records"| node_n_exporters
node_n_exporters -->|"writes"| node_n_supabase
node_n_exporters -->|"feeds"| node_n_dedup
node_n_dedup -->|"gold candidates"| node_n_jobs
node_n_jobs -->|"materializes"| node_n_supabase
node_n_jobs -.->|"reviewable"| node_n_verification
node_n_models -.->|"governed by"| node_n_security
node_n_pipeline -.->|"bounded by"| node_n_adr
node_n_adapters -->|"uses"| node_n_shared
node_n_dedup -->|"uses"| node_n_shared
node_n_exporters -.->|"enforces"| node_n_security

click node_n_cli "https://github.com/datavenezuela/vzla_dedup/blob/master/scrapers/cli.py"
click node_n_pipeline "https://github.com/datavenezuela/vzla_dedup/blob/master/scrapers/pipelines/run_pipeline.py"
click node_n_sources_loader "https://github.com/datavenezuela/vzla_dedup/blob/master/scrapers/sources/loader.py"
click node_n_adapters "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/adapters"
click node_n_parsers "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/parsers"
click node_n_models "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/models"
click node_n_normalizers "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/normalizers"
click node_n_sanitizers "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/sanitizers"
click node_n_validators "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/validators"
click node_n_exporters "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/exporters"
click node_n_dedup "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/dedup"
click node_n_jobs "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/jobs"
click node_n_supabase "https://github.com/datavenezuela/vzla_dedup/blob/master/scrapers/jobs/supabase_adapter.py"
click node_n_shared "https://github.com/datavenezuela/vzla_dedup/tree/master/shared"
click node_n_verification "https://github.com/datavenezuela/vzla_dedup/tree/master/verification"
click node_n_security "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/security"
click node_n_adr "https://github.com/datavenezuela/vzla_dedup/tree/master/docs/adr"
click node_n_config "https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/config"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n_cli,node_n_pipeline,node_n_config,node_n_security,node_n_adr toneBlue
class node_n_sources_loader,node_n_adapters toneAmber
class node_n_parsers,node_n_models toneMint
class node_n_normalizers,node_n_sanitizers,node_n_validators toneRose
class node_n_exporters,node_n_dedup,node_n_jobs,node_n_supabase toneIndigo
class node_n_shared,node_n_verification toneTeal
```

## Components

### Pipeline runtime

Entry points and orchestration for offline and production runs.

- [CLI](https://github.com/datavenezuela/vzla_dedup/blob/master/scrapers/cli.py): entrypoint · Main executable surface for running pipeline jobs. · `scrapers/cli.py`
- [Run pipeline](https://github.com/datavenezuela/vzla_dedup/blob/master/scrapers/pipelines/run_pipeline.py): orchestrator · Coordinates source loading, parsing, normalization, and export. · `scrapers/pipelines/run_pipeline.py`
- [Source config](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/config): pipeline 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](https://github.com/datavenezuela/vzla_dedup/blob/master/scrapers/sources/loader.py): config loader · Loads configured sources and source metadata. · `scrapers/sources/loader.py`
- [Adapters](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/adapters): fetch layer · 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.

- [Parsers](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/parsers): source parsers · Converts raw content into structured domain objects. · `scrapers/parsers`
- [Models](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/models): domain schema · Pydantic-backed contracts for people, events, acopio centers, and source config. · `scrapers/models`

### Normalize and protect

Canonicalization, extraction, sanitization, and validation.

- [Normalizers](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/normalizers): canonicalization · Standardizes dates, locations, names, text, phonetics, and extracted entities. · `scrapers/normalizers`
- [Sanitizers](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/sanitizers): pii protection · Detects, redacts, tokenizes, and protects sensitive data before persistence or logs. · `scrapers/sanitizers`
- [Validators](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/validators): quality gates · Enforces source quality, confidence, and record-level validation rules. · `scrapers/validators`

### Export and consolidate

Staging, quarantine, deduplication, and gold materialization.

- [Exporters](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/exporters): staging boundary · Writes provenance, quarantine, and staging outputs. · `scrapers/exporters`
- [Dedup](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/dedup): matching · Fingerprints, blocks, scores, and clusters duplicate person records. · `scrapers/dedup`
- [Jobs](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/jobs): consolidation · Turns dedup outputs into consolidated gold entities and materialized records. · `scrapers/jobs`
- [Supabase adapter](https://github.com/datavenezuela/vzla_dedup/blob/master/scrapers/jobs/supabase_adapter.py): persistence 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](https://github.com/datavenezuela/vzla_dedup/tree/master/shared): cross-cutting · Common hashing and location helpers shared across the repository. · `shared`
- [Verification](https://github.com/datavenezuela/vzla_dedup/tree/master/verification): review boundary · Human or downstream review boundary for candidate validation workflows. · `verification`

### Governance

Security, contracts, and source policy constraints.

- [Security docs](https://github.com/datavenezuela/vzla_dedup/tree/master/scrapers/security): policy · PII handling, commit safety, and source policy constraints. · `scrapers/security`
- [ADRs](https://github.com/datavenezuela/vzla_dedup/tree/master/docs/adr): governance docs · Architecture decisions covering serving, security, contracts, retention, and gold model. · `docs/adr`

## Connections

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