# frys3333/arrow-contract-intelligence-organization architecture

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

- Interactive diagram: https://gitdiagram.com/frys3333/arrow-contract-intelligence-organization
- Repository: https://github.com/frys3333/arrow-contract-intelligence-organization

## Overview

Arrow is a local-first SAM.gov contract-opportunity intelligence tool. Users sync public bulk CSV data into a local SQLite store, then browse/search, save or archive notices, and rank them against a company profile; optional Ollama calls provide explanations and summaries. The REPL and TUI are separate user interfaces over the same capabilities. Edges reflect excerpted calls or README descriptions; some subsystems are indexed but not excerpted, so their internal links are omitted where evidence is limited.

Main entry points: [`arrow/repl.py`](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/repl.py) (Command REPL), [`arrow/tui.py`](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/tui.py) (Terminal UI), [`arrow/sync_engine.py`](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/sync_engine.py) (Sync engine), [`arrow/repo.py`](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/repo.py) (Opportunity repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_repl["Command REPL<br/>[repl.py]"]
  node_tui["Terminal UI<br/>[tui.py]"]
  node_env["Environment loading<br/>[env.py]"]
end

subgraph group_ingest["Opportunity ingestion"]
  node_sync["Sync engine<br/>[sync_engine.py]"]
  node_download["CSV downloader<br/>[bulk_download.py]"]
  node_csv["CSV reader<br/>[bulk_csv.py]"]
  node_normalize["Opportunity normalization<br/>[normalize.py]"]
  node_canonical["Canonical mapping<br/>[canonical.py]"]
  node_ipv4["IPv4 preference<br/>[ipv4_preference.py]"]
end

subgraph group_data["Local data and profile"]
  node_repo["Opportunity repository<br/>[repo.py]"]
  node_db[("SQLite datastore<br/>[db.py]")]
  node_archive[("JSON archive<br/>[archive_store.py]")]
  node_profile["Company profile<br/>[company_profile.py]"]
end

subgraph group_intelligence["Ranking and analysis"]
  node_ranking["Fit ranking<br/>[ranking.py]"]
  node_analysis["Structured analysis<br/>[analysis.py]"]
  node_runtime["Ollama runtime<br/>[ollama_runtime.py]"]
  node_ollama["Ollama client<br/>[ollama_client.py]"]
end

node_user(("Arrow user"))
node_ollama_service["Local Ollama"]

node_user -->|"runs commands"| node_repl
node_user -->|"opens interface"| node_tui
node_repl -->|"requests sync"| node_sync
node_tui -->|"requests sync"| node_sync
node_sync -->|"downloads CSV"| node_download
node_sync -->|"reads rows"| node_csv
node_download -->|"uses CSV cache"| node_csv
node_sync -->|"normalizes notices"| node_normalize
node_normalize -->|"maps fields"| node_canonical
node_sync -->|"upserts records"| node_repo
node_repo -->|"reads and writes"| node_db
node_repl -->|"browses and saves"| node_repo
node_tui -->|"browses opportunities"| node_repo
node_repl -->|"manages exports"| node_archive
node_tui -->|"manages exports"| node_archive
node_repl -->|"edits profile"| node_profile
node_tui -->|"edits profile"| node_profile
node_repl -->|"ranks leads"| node_ranking
node_tui -->|"ranks leads"| node_ranking
node_repl -->|"requests explanations"| node_analysis
node_tui -->|"requests analysis"| node_analysis
node_analysis -->|"requests model output"| node_ollama
node_runtime -->|"checks service"| node_ollama
node_ollama -->|"sends HTTP requests"| node_ollama_service
node_repl -->|"starts if needed"| node_runtime
node_tui -->|"enables preference"| node_ipv4
node_repl -->|"enables preference"| node_ipv4
node_repl -->|"loads configuration"| node_env
node_tui -->|"loads configuration"| node_env
node_user -.->|"sets fit context"| node_ranking

click node_repl "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/repl.py"
click node_tui "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/tui.py"
click node_sync "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/sync_engine.py"
click node_download "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/bulk_download.py"
click node_csv "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/bulk_csv.py"
click node_normalize "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/normalize.py"
click node_canonical "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/canonical.py"
click node_ipv4 "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/ipv4_preference.py"
click node_repo "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/repo.py"
click node_db "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/db.py"
click node_archive "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/archive_store.py"
click node_profile "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/company_profile.py"
click node_ranking "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/ranking.py"
click node_analysis "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/analysis.py"
click node_runtime "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/ollama_runtime.py"
click node_ollama "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/ollama_client.py"
click node_env "https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/env.py"

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_repl,node_tui,node_env,node_user toneBlue
class node_sync,node_download,node_csv,node_normalize,node_canonical,node_ipv4 toneAmber
class node_repo,node_db,node_archive,node_profile toneMint
class node_ranking,node_analysis,node_runtime,node_ollama toneRose
class node_ollama_service toneIndigo
```

## Components

### User interfaces

- [Command REPL](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/repl.py): `arrow/repl.py`
- [Terminal UI](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/tui.py): `arrow/tui.py`
- [Environment loading](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/env.py): `arrow/env.py`

### Opportunity ingestion

- [Sync engine](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/sync_engine.py): `arrow/sync_engine.py`
- [CSV downloader](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/bulk_download.py): `arrow/bulk_download.py`
- [CSV reader](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/bulk_csv.py): `arrow/bulk_csv.py`
- [Opportunity normalization](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/normalize.py): `arrow/normalize.py`
- [Canonical mapping](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/canonical.py): `arrow/canonical.py`
- [IPv4 preference](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/ipv4_preference.py): `arrow/ipv4_preference.py`

### Local data and profile

- [Opportunity repository](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/repo.py): `arrow/repo.py`
- [SQLite datastore](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/db.py): `arrow/db.py`
- [JSON archive](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/archive_store.py): `arrow/archive_store.py`
- [Company profile](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/company_profile.py): `arrow/company_profile.py`

### Ranking and analysis

- [Fit ranking](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/ranking.py): `arrow/ranking.py`
- [Structured analysis](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/analysis.py): `arrow/analysis.py`
- [Ollama runtime](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/ollama_runtime.py): `arrow/ollama_runtime.py`
- [Ollama client](https://github.com/frys3333/arrow-contract-intelligence-organization/blob/main/arrow/ollama_client.py): `arrow/ollama_client.py`

### Other components

- **Arrow user**
- **Local Ollama**

## Connections

- Arrow user → Command REPL: runs commands (evidence: `README.md`)
- Arrow user → Terminal UI: opens interface (evidence: `README.md`)
- Command REPL → Sync engine: requests sync (evidence: `arrow/repl.py`)
- Terminal UI → Sync engine: requests sync (evidence: `arrow/tui.py`)
- Sync engine → CSV downloader: downloads CSV (evidence: `arrow/sync_engine.py`)
- Sync engine → CSV reader: reads rows (evidence: `arrow/sync_engine.py`)
- CSV downloader → CSV reader: uses CSV cache (evidence: `arrow/bulk_download.py`)
- Sync engine → Opportunity normalization: normalizes notices (evidence: `arrow/sync_engine.py`)
- Opportunity normalization → Canonical mapping: maps fields (evidence: `arrow/normalize.py`)
- Sync engine → Opportunity repository: upserts records (evidence: `arrow/sync_engine.py`)
- Opportunity repository → SQLite datastore: reads and writes (evidence: `arrow/repo.py`)
- Command REPL → Opportunity repository: browses and saves (evidence: `arrow/repl.py`)
- Terminal UI → Opportunity repository: browses opportunities (evidence: `arrow/tui.py`)
- Command REPL → JSON archive: manages exports (evidence: `arrow/repl.py`)
- Terminal UI → JSON archive: manages exports (evidence: `arrow/tui.py`)
- Command REPL → Company profile: edits profile (evidence: `arrow/repl.py`)
- Terminal UI → Company profile: edits profile (evidence: `arrow/tui.py`)
- Command REPL → Fit ranking: ranks leads (evidence: `arrow/repl.py`)
- Terminal UI → Fit ranking: ranks leads (evidence: `arrow/tui.py`)
- Command REPL → Structured analysis: requests explanations (evidence: `arrow/repl.py`)
- Terminal UI → Structured analysis: requests analysis (evidence: `arrow/tui.py`)
- Structured analysis → Ollama client: requests model output (evidence: `arrow/analysis.py`)
- Ollama runtime → Ollama client: checks service (evidence: `arrow/ollama_runtime.py`)
- Ollama client → Local Ollama: sends HTTP requests (evidence: `arrow/ollama_client.py`)
- Command REPL → Ollama runtime: starts if needed (evidence: `arrow/repl.py`)
- Terminal UI → IPv4 preference: enables preference (evidence: `arrow/tui.py`)
- Command REPL → IPv4 preference: enables preference (evidence: `arrow/repl.py`)
- Command REPL → Environment loading: loads configuration (evidence: `arrow/repl.py`)
- Terminal UI → Environment loading: loads configuration (evidence: `arrow/tui.py`)
- Arrow user → Fit ranking: sets fit context (evidence: `README.md`)
