# yurirdev/elosys architecture

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

- Interactive diagram: https://gitdiagram.com/yurirdev/elosys
- Repository: https://github.com/yurirdev/elosys

## Overview

EloSys builds a provenance-tracked SQLite database of Brazilian election and public-integrity data, then presents it through a read-only web application. The main workflow is to collect official records, reconcile people and companies, optionally enrich or analyze them, and let investigators search profiles, finances, relationships, and warning signals. The README documents the product capabilities and pipeline; sampled source confirms key collector, provenance, CLI, and review behavior. Web query and route internals were not sampled, so those connections are documented at the README level.

Main entry points: [`elosys/cli.py`](https://github.com/yurirdev/elosys/blob/main/elosys/cli.py) (Pipeline CLI), [`web/src/lib/queries.ts`](https://github.com/yurirdev/elosys/blob/main/web/src/lib/queries.ts) (Read queries), [`elosys/provenance.py`](https://github.com/yurirdev/elosys/blob/main/elosys/provenance.py) (Source provenance), [`web/src/app`](https://github.com/yurirdev/elosys/tree/main/web/src/app) (Investigation interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Official collection"]
  node_cli["Pipeline CLI<br/>[cli.py]"]
  node_candidates["Candidate records<br/>[candidates.py]"]
  node_accounts["Campaign finance<br/>[accounts.py]"]
  node_assets["Declared assets<br/>[assets.py]"]
  node_tse_social["Declared social<br/>[social.py]"]
  node_sanctions["Federal sanctions<br/>[sanctions.py]"]
  node_earmarks["Parliamentary earmarks<br/>[earmarks.py]"]
end

subgraph group_enrichment["Identity and enrichment"]
  node_identity["Person resolution<br/>[identity.py]"]
  node_cnpj["Company enrichment<br/>[cnpj.py]"]
  node_photo["Candidate photos<br/>[photo_urls.py]"]
  node_xposts["X post collection<br/>[x_posts.py]"]
  node_lexicon["Term matching<br/>[lexicon.py]"]
end

subgraph group_analysis["Signals and review"]
  node_rules["Detection rules"]
  node_ai_review["Signal AI review<br/>[ai_review.py]"]
  node_social_review["Social post review<br/>[social_review.py]"]
  node_deepseek["DeepSeek client<br/>[deepseek.py]"]
end

subgraph group_web["Investigation web app"]
  node_web["Investigation interface"]
  node_search["Search and profiles<br/>[page.tsx]"]
  node_finance["Finance and rankings<br/>[page.tsx]"]
  node_graph["Relationship graph<br/>[page.tsx]"]
  node_signals_ui["Signal investigations"]
  node_queries["Read queries<br/>[queries.ts]"]
end

subgraph group_foundation["Shared data foundation"]
  node_provenance["Source provenance<br/>[provenance.py]"]
  node_sqlite[("SQLite database<br/>[db.py]")]
end

node_operator(("Operator"))

node_operator -->|"runs commands"| node_cli
node_cli -->|"runs collector"| node_candidates
node_cli -->|"runs collector"| node_accounts
node_cli -->|"runs collector"| node_assets
node_cli -->|"runs collector"| node_tse_social
node_cli -->|"runs collector"| node_sanctions
node_cli -->|"runs collector"| node_earmarks
node_candidates -->|"resolves people"| node_identity
node_accounts -->|"resolves people"| node_identity
node_cli -->|"runs enrichment"| node_cnpj
node_cli -->|"runs enrichment"| node_photo
node_cli -->|"runs collection"| node_xposts
node_xposts -->|"matches terms"| node_lexicon
node_cli -->|"runs detections"| node_rules
node_cli -->|"runs review"| node_ai_review
node_cli -->|"runs review"| node_social_review
node_ai_review -->|"requests review"| node_deepseek
node_social_review -->|"requests review"| node_deepseek
node_candidates -->|"records source"| node_provenance
node_accounts -->|"records source"| node_provenance
node_sanctions -->|"records source"| node_provenance
node_cnpj -->|"records source"| node_provenance
node_provenance -->|"stores provenance"| node_sqlite
node_candidates -->|"writes records"| node_sqlite
node_accounts -->|"writes records"| node_sqlite
node_web -->|"provides search"| node_search
node_web -->|"provides finance views"| node_finance
node_web -->|"provides graph views"| node_graph
node_web -->|"provides signal views"| node_signals_ui
node_search -.->|"requests data"| node_queries
node_finance -.->|"requests data"| node_queries
node_graph -.->|"requests data"| node_queries
node_signals_ui -.->|"requests data"| node_queries
node_queries -->|"reads database"| node_sqlite

click node_cli "https://github.com/yurirdev/elosys/blob/main/elosys/cli.py"
click node_candidates "https://github.com/yurirdev/elosys/blob/main/elosys/tse/candidates.py"
click node_accounts "https://github.com/yurirdev/elosys/blob/main/elosys/tse/accounts.py"
click node_assets "https://github.com/yurirdev/elosys/blob/main/elosys/tse/assets.py"
click node_tse_social "https://github.com/yurirdev/elosys/blob/main/elosys/tse/social.py"
click node_sanctions "https://github.com/yurirdev/elosys/blob/main/elosys/transparencia/sanctions.py"
click node_earmarks "https://github.com/yurirdev/elosys/blob/main/elosys/transparencia/earmarks.py"
click node_identity "https://github.com/yurirdev/elosys/blob/main/elosys/identity.py"
click node_cnpj "https://github.com/yurirdev/elosys/blob/main/elosys/receita/cnpj.py"
click node_photo "https://github.com/yurirdev/elosys/blob/main/elosys/tse/photo_urls.py"
click node_xposts "https://github.com/yurirdev/elosys/blob/main/elosys/social/x_posts.py"
click node_lexicon "https://github.com/yurirdev/elosys/blob/main/elosys/social/lexicon.py"
click node_rules "https://github.com/yurirdev/elosys/tree/main/elosys/rules"
click node_ai_review "https://github.com/yurirdev/elosys/blob/main/elosys/rules/ai_review.py"
click node_social_review "https://github.com/yurirdev/elosys/blob/main/elosys/rules/social_review.py"
click node_deepseek "https://github.com/yurirdev/elosys/blob/main/elosys/ai/deepseek.py"
click node_provenance "https://github.com/yurirdev/elosys/blob/main/elosys/provenance.py"
click node_sqlite "https://github.com/yurirdev/elosys/blob/main/elosys/db.py"
click node_web "https://github.com/yurirdev/elosys/tree/main/web/src/app"
click node_search "https://github.com/yurirdev/elosys/blob/main/web/src/app/page.tsx"
click node_finance "https://github.com/yurirdev/elosys/blob/main/web/src/app/ranking/page.tsx"
click node_graph "https://github.com/yurirdev/elosys/blob/main/web/src/app/grafo/page.tsx"
click node_signals_ui "https://github.com/yurirdev/elosys/tree/main/web/src/app/sinais"
click node_queries "https://github.com/yurirdev/elosys/blob/main/web/src/lib/queries.ts"

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_cli,node_candidates,node_accounts,node_assets,node_tse_social,node_sanctions,node_earmarks toneBlue
class node_identity,node_cnpj,node_photo,node_xposts,node_lexicon toneAmber
class node_rules,node_ai_review,node_social_review,node_deepseek toneMint
class node_web,node_search,node_finance,node_graph,node_signals_ui,node_queries toneRose
class node_provenance,node_sqlite,node_operator toneIndigo
```

## Components

### Official collection

- [Pipeline CLI](https://github.com/yurirdev/elosys/blob/main/elosys/cli.py): `elosys/cli.py`
- [Candidate records](https://github.com/yurirdev/elosys/blob/main/elosys/tse/candidates.py): `elosys/tse/candidates.py`
- [Campaign finance](https://github.com/yurirdev/elosys/blob/main/elosys/tse/accounts.py): `elosys/tse/accounts.py`
- [Declared assets](https://github.com/yurirdev/elosys/blob/main/elosys/tse/assets.py): `elosys/tse/assets.py`
- [Declared social](https://github.com/yurirdev/elosys/blob/main/elosys/tse/social.py): `elosys/tse/social.py`
- [Federal sanctions](https://github.com/yurirdev/elosys/blob/main/elosys/transparencia/sanctions.py): `elosys/transparencia/sanctions.py`
- [Parliamentary earmarks](https://github.com/yurirdev/elosys/blob/main/elosys/transparencia/earmarks.py): `elosys/transparencia/earmarks.py`

### Identity and enrichment

- [Person resolution](https://github.com/yurirdev/elosys/blob/main/elosys/identity.py): `elosys/identity.py`
- [Company enrichment](https://github.com/yurirdev/elosys/blob/main/elosys/receita/cnpj.py): `elosys/receita/cnpj.py`
- [Candidate photos](https://github.com/yurirdev/elosys/blob/main/elosys/tse/photo_urls.py): `elosys/tse/photo_urls.py`
- [X post collection](https://github.com/yurirdev/elosys/blob/main/elosys/social/x_posts.py): `elosys/social/x_posts.py`
- [Term matching](https://github.com/yurirdev/elosys/blob/main/elosys/social/lexicon.py): `elosys/social/lexicon.py`

### Signals and review

- [Detection rules](https://github.com/yurirdev/elosys/tree/main/elosys/rules): `elosys/rules`
- [Signal AI review](https://github.com/yurirdev/elosys/blob/main/elosys/rules/ai_review.py): `elosys/rules/ai_review.py`
- [Social post review](https://github.com/yurirdev/elosys/blob/main/elosys/rules/social_review.py): `elosys/rules/social_review.py`
- [DeepSeek client](https://github.com/yurirdev/elosys/blob/main/elosys/ai/deepseek.py): `elosys/ai/deepseek.py`

### Investigation web app

- [Investigation interface](https://github.com/yurirdev/elosys/tree/main/web/src/app): `web/src/app`
- [Search and profiles](https://github.com/yurirdev/elosys/blob/main/web/src/app/page.tsx): `web/src/app/page.tsx`
- [Finance and rankings](https://github.com/yurirdev/elosys/blob/main/web/src/app/ranking/page.tsx): `web/src/app/ranking/page.tsx`
- [Relationship graph](https://github.com/yurirdev/elosys/blob/main/web/src/app/grafo/page.tsx): `web/src/app/grafo/page.tsx`
- [Signal investigations](https://github.com/yurirdev/elosys/tree/main/web/src/app/sinais): `web/src/app/sinais`
- [Read queries](https://github.com/yurirdev/elosys/blob/main/web/src/lib/queries.ts): `web/src/lib/queries.ts`

### Shared data foundation

- [Source provenance](https://github.com/yurirdev/elosys/blob/main/elosys/provenance.py): `elosys/provenance.py`
- [SQLite database](https://github.com/yurirdev/elosys/blob/main/elosys/db.py): `elosys/db.py`

### Other components

- **Operator**

## Connections

- Operator → Pipeline CLI: runs commands
- Pipeline CLI → Candidate records: runs collector (evidence: `elosys/cli.py`)
- Pipeline CLI → Campaign finance: runs collector (evidence: `elosys/cli.py`)
- Pipeline CLI → Declared assets: runs collector (evidence: `elosys/cli.py`)
- Pipeline CLI → Declared social: runs collector (evidence: `elosys/cli.py`)
- Pipeline CLI → Federal sanctions: runs collector (evidence: `elosys/cli.py`)
- Pipeline CLI → Parliamentary earmarks: runs collector (evidence: `elosys/cli.py`)
- Candidate records → Person resolution: resolves people (evidence: `elosys/tse/candidates.py`)
- Campaign finance → Person resolution: resolves people (evidence: `elosys/tse/accounts.py`)
- Pipeline CLI → Company enrichment: runs enrichment (evidence: `elosys/cli.py`)
- Pipeline CLI → Candidate photos: runs enrichment (evidence: `elosys/cli.py`)
- Pipeline CLI → X post collection: runs collection (evidence: `elosys/cli.py`)
- X post collection → Term matching: matches terms (evidence: `elosys/social/x_posts.py`)
- Pipeline CLI → Detection rules: runs detections (evidence: `elosys/cli.py`)
- Pipeline CLI → Signal AI review: runs review (evidence: `elosys/cli.py`)
- Pipeline CLI → Social post review: runs review (evidence: `elosys/cli.py`)
- Signal AI review → DeepSeek client: requests review (evidence: `elosys/rules/ai_review.py`)
- Social post review → DeepSeek client: requests review (evidence: `elosys/rules/social_review.py`)
- Candidate records → Source provenance: records source (evidence: `elosys/tse/candidates.py`)
- Campaign finance → Source provenance: records source (evidence: `elosys/tse/accounts.py`)
- Federal sanctions → Source provenance: records source (evidence: `elosys/transparencia/sanctions.py`)
- Company enrichment → Source provenance: records source (evidence: `elosys/receita/cnpj.py`)
- Source provenance → SQLite database: stores provenance
- Candidate records → SQLite database: writes records
- Campaign finance → SQLite database: writes records
- Investigation interface → Search and profiles: provides search
- Investigation interface → Finance and rankings: provides finance views
- Investigation interface → Relationship graph: provides graph views
- Investigation interface → Signal investigations: provides signal views
- Search and profiles → Read queries: requests data
- Finance and rankings → Read queries: requests data
- Relationship graph → Read queries: requests data
- Signal investigations → Read queries: requests data
- Read queries → SQLite database: reads database
