# gowtham2036/ai_intelligence_pipeline_starter architecture

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

- Interactive diagram: https://gitdiagram.com/gowtham2036/ai_intelligence_pipeline_starter
- Repository: https://github.com/gowtham2036/ai_intelligence_pipeline_starter

## Overview

#### Purpose and Entry Points
This is a Python batch data pipeline that builds a verified AI-research-paper dataset: ingest arXiv papers, associate GitHub repositories, normalize and persist records, generate grounded LLM enrichments, and export audited JSON/CSV artifacts. Primary orchestration is `src/main.py`; production enrichment runners are `src/run_production_enrichment.py` and `src/run_fast_production_enrichment.py`. Final operational commands are `src/final_validate.py`, `src/final_submission_audit.py`, and `src/export_final_dataset.py`.

#### Source Ingestion Boundary
arXiv and GitHub are external, independently failure-prone source systems. Source adapters retrieve papers/metadata from arXiv Atom and repository data from GitHub REST:
- `src/sources/arxiv.py`
- `src/sources/github.py`
- `src/crawler/http.py`

The HTTP layer is asynchronous and owns retry, exponential backoff/jitter, concurrency, and rate-limit handling. GitHub operation can use a token and must tolerate authenticated versus unauthenticated quotas.

#### Extraction, Identity, and Canonicalization
Raw source data is transformed into stable domain entities before persistence. Deterministic paper IDs, UTC timestamps, and canonical GitHub URLs establish deduplication and join boundaries:
- `src/normalization.py`
- `src/models/entities.py`
- `src/extractor/webpage.py`

Canonicalization removes GitHub URL variants such as tracking parameters, subpaths, and `.git`; this makes repository matching and later audits reproducible.

#### Authoritative Persistence
SQLite is the system of record, not the exported files. `DatabaseManager` provides schema creation and idempotent upserts, with foreign keys, WAL mode, and indexes supporting paper, enrichment, date, repository, and domain access:
- `src/database.py`
- `data/ai_intelligence.db`

The key relational boundary is papers to enrichments: accepted enrichment rows must reference a persisted paper, preventing orphan intelligence records.

#### LLM Enrichment Stage
The enrichment pipeline turns paper source text into seven structured intelligence fields: summary, problem, methodology, contributions, domain, topics, and keywords:
- `src/enrichment.py`
- `src/llm/provider.py`
- `src/llm/schemas.py`

Prompts and provider configuration are separated from pipeline control in `src/llm/prompts.py`. The runtime uses configurable LLM providers/models, with documented Groq multi-key worker behavior; credentials and provider settings enter through `.env` derived from `.env.example`.

#### Grounding, Provenance, and Rejection Boundary
LLM output is schema-validated and then subjected to deterministic grounding checks against authoritative paper text, especially numeric, statistical, and benchmark claims. Accepted data receives source type, URL, and SHA-256 content hash provenance. Rejected enrichment attempts must not enter production tables:
- `src/enrichment.py`
- `data/rejected_enrichments/quarantine_log.json`
- `src/final_validate.py`

This quarantine boundary isolates hallucinated or unsupported content while retaining an audit trail.

#### Publishing and Assurance
The database is flattened or nested into deterministic deliverables, with separate quality and final-submission audit stages:
- `src/export_final_dataset.py`
- `src/generate_quality_report.py`
- `src/final_submission_audit.py`

Published artifacts are `data/final_research_papers.json`, `data/final_research_papers.csv`, and `data/final_quality_report.json`. Supplemental GitHub cleanup/review scripts—such as `src/cleanup_github_dataset.py` and `src/audit_github_matches.py`—support correctness of repository associations outside the main ingestion-to-export path.

Main entry points: [`src/enrichment.py`](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/enrichment.py) (Grounded Enrichment Pipeline), [`data/ai_intelligence.db`](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/data/ai_intelligence.db) (Authoritative SQLite Store), [`src/sources/arxiv.py`](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/sources/arxiv.py) (arXiv Adapter), [`src/sources/github.py`](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/sources/github.py) (GitHub Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sources["External Sources"]
  node_arxiv(("arXiv Atom<br/>external API"))
  node_github(("GitHub REST<br/>external API"))
end

subgraph group_pipeline["Core Pipeline"]
  node_orchestrator["Batch Orchestrator<br/>Python entry point<br/>[main.py]"]
  node_http["Async HTTP Client<br/>transport layer<br/>[http.py]"]
  node_arxiv_adapter["arXiv Adapter<br/>source adapter<br/>[arxiv.py]"]
  node_github_adapter["GitHub Adapter<br/>source adapter<br/>[github.py]"]
  node_canonicalization["Identity &amp; Canonicalization<br/>domain transform<br/>[normalization.py]"]
  node_entities["Domain Entities<br/>data model<br/>[entities.py]"]
  node_web_extractor["Paper Text Extractor<br/>content extractor<br/>[webpage.py]"]
  node_database[("Authoritative SQLite Store<br/>system of record<br/>[ai_intelligence.db]")]
  node_db_manager["Database Manager<br/>persistence layer<br/>[database.py]"]
end

subgraph group_enrichment["Enrichment &amp; Verification"]
  node_enrichment_runner["Production Enrichment Runners<br/>batch runners"]
  node_enrichment_pipeline["Grounded Enrichment Pipeline<br/>verification pipeline<br/>[enrichment.py]"]
  node_llm_provider{{"Configurable LLM Provider<br/>LLM integration<br/>[provider.py]"}}
  node_llm_schema["Enrichment Schemas<br/>structured contract<br/>[schemas.py]"]
  node_quarantine["Rejected Enrichment Log<br/>audit quarantine"]
end

subgraph group_publishing["Publishing &amp; Assurance"]
  node_final_validation["Final Validation<br/>validation command<br/>[final_validate.py]"]
  node_exporter["Dataset Exporter<br/>publishing stage"]
  node_artifacts["Published Dataset<br/>JSON / CSV artifacts"]
  node_quality_report["Quality Report<br/>assurance artifact"]
  node_submission_audit["Submission Audit<br/>audit command"]
end

node_arxiv -->|"paper metadata"| node_arxiv_adapter
node_github -->|"repository data"| node_github_adapter
node_arxiv_adapter -->|"requests"| node_http
node_github_adapter -->|"requests"| node_http
node_orchestrator -->|"ingests"| node_arxiv_adapter
node_orchestrator -->|"associates repos"| node_github_adapter
node_arxiv_adapter -->|"raw papers"| node_canonicalization
node_github_adapter -->|"raw repositories"| node_canonicalization
node_canonicalization -->|"stable records"| node_entities
node_entities -->|"upserts"| node_db_manager
node_db_manager -->|"persists"| node_database
node_orchestrator -->|"extracts source text"| node_web_extractor
node_enrichment_runner -->|"runs"| node_enrichment_pipeline
node_database -->|"persisted papers"| node_enrichment_pipeline
node_web_extractor -->|"authoritative text"| node_enrichment_pipeline
node_enrichment_pipeline -->|"structured requests"| node_llm_provider
node_llm_provider -->|"validated fields"| node_llm_schema
node_llm_schema -->|"schema result"| node_enrichment_pipeline
node_enrichment_pipeline -->|"accepted grounded enrichments"| node_database
node_enrichment_pipeline -.->|"rejected attempts"| node_quarantine
node_database -->|"validates"| node_final_validation
node_database -->|"export source"| node_exporter
node_exporter -->|"JSON and CSV"| node_artifacts
node_database -->|"quality metrics"| node_quality_report
node_artifacts -->|"audits deliverables"| node_submission_audit
node_quality_report -->|"audit evidence"| node_submission_audit

click node_orchestrator "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/main.py"
click node_http "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/crawler/http.py"
click node_arxiv_adapter "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/sources/arxiv.py"
click node_github_adapter "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/sources/github.py"
click node_canonicalization "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/normalization.py"
click node_entities "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/models/entities.py"
click node_web_extractor "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/extractor/webpage.py"
click node_database "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/data/ai_intelligence.db"
click node_db_manager "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/database.py"
click node_enrichment_runner "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/run_production_enrichment.py"
click node_enrichment_pipeline "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/enrichment.py"
click node_llm_provider "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/llm/provider.py"
click node_llm_schema "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/llm/schemas.py"
click node_quarantine "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/data/rejected_enrichments/quarantine_log.json"
click node_final_validation "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/final_validate.py"
click node_exporter "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/export_final_dataset.py"
click node_artifacts "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/data/final_research_papers.json"
click node_quality_report "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/data/final_quality_report.json"
click node_submission_audit "https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/final_submission_audit.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_arxiv,node_github toneBlue
class node_orchestrator,node_http,node_arxiv_adapter,node_github_adapter,node_canonicalization,node_entities,node_web_extractor,node_database,node_db_manager toneAmber
class node_enrichment_runner,node_enrichment_pipeline,node_llm_provider,node_llm_schema,node_quarantine toneMint
class node_final_validation,node_exporter,node_artifacts,node_quality_report,node_submission_audit toneRose
```

## Components

### External Sources

- **arXiv Atom**: external API
- **GitHub REST**: external API · Uses authenticated or unauthenticated quotas.

### Core Pipeline

- [Batch Orchestrator](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/main.py): Python entry point · Coordinates ingestion, persistence, and enrichment runs. · `src/main.py`
- [Async HTTP Client](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/crawler/http.py): transport layer · Owns retries, backoff, concurrency, and rate-limit handling. · `src/crawler/http.py`
- [arXiv Adapter](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/sources/arxiv.py): source adapter · `src/sources/arxiv.py`
- [GitHub Adapter](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/sources/github.py): source adapter · `src/sources/github.py`
- [Identity & Canonicalization](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/normalization.py): domain transform · Creates stable paper IDs, UTC timestamps, and canonical GitHub URLs. · `src/normalization.py`
- [Domain Entities](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/models/entities.py): data model · `src/models/entities.py`
- [Paper Text Extractor](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/extractor/webpage.py): content extractor · `src/extractor/webpage.py`
- [Authoritative SQLite Store](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/data/ai_intelligence.db): system of record · Idempotent upserts enforce persisted-paper references for enrichments. · `data/ai_intelligence.db`
- [Database Manager](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/database.py): persistence layer · Creates schema and manages WAL, foreign keys, and indexes. · `src/database.py`

### Enrichment & Verification

- [Production Enrichment Runners](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/run_production_enrichment.py): batch runners · Standard and fast production execution paths. · `src/run_production_enrichment.py`
- [Grounded Enrichment Pipeline](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/enrichment.py): verification pipeline · Produces seven intelligence fields and rejects unsupported claims. · `src/enrichment.py`
- [Configurable LLM Provider](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/llm/provider.py): LLM integration · Supports provider/model configuration and multi-key workers. · `src/llm/provider.py`
- [Enrichment Schemas](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/llm/schemas.py): structured contract · `src/llm/schemas.py`
- [Rejected Enrichment Log](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/data/rejected_enrichments/quarantine_log.json): audit quarantine · Unsupported enrichment attempts remain outside production tables. · `data/rejected_enrichments/quarantine_log.json`

### Publishing & Assurance

- [Final Validation](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/final_validate.py): validation command · `src/final_validate.py`
- [Dataset Exporter](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/export_final_dataset.py): publishing stage · Generates deterministic JSON and CSV deliverables from SQLite. · `src/export_final_dataset.py`
- [Published Dataset](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/data/final_research_papers.json): JSON / CSV artifacts · `data/final_research_papers.json`
- [Quality Report](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/data/final_quality_report.json): assurance artifact · `data/final_quality_report.json`
- [Submission Audit](https://github.com/gowtham2036/ai_intelligence_pipeline_starter/blob/main/src/final_submission_audit.py): audit command · `src/final_submission_audit.py`

## Connections

- arXiv Atom → arXiv Adapter: paper metadata
- GitHub REST → GitHub Adapter: repository data
- arXiv Adapter → Async HTTP Client: requests
- GitHub Adapter → Async HTTP Client: requests
- Batch Orchestrator → arXiv Adapter: ingests
- Batch Orchestrator → GitHub Adapter: associates repos
- arXiv Adapter → Identity & Canonicalization: raw papers
- GitHub Adapter → Identity & Canonicalization: raw repositories
- Identity & Canonicalization → Domain Entities: stable records
- Domain Entities → Database Manager: upserts
- Database Manager → Authoritative SQLite Store: persists
- Batch Orchestrator → Paper Text Extractor: extracts source text
- Production Enrichment Runners → Grounded Enrichment Pipeline: runs
- Authoritative SQLite Store → Grounded Enrichment Pipeline: persisted papers
- Paper Text Extractor → Grounded Enrichment Pipeline: authoritative text
- Grounded Enrichment Pipeline → Configurable LLM Provider: structured requests
- Configurable LLM Provider → Enrichment Schemas: validated fields
- Enrichment Schemas → Grounded Enrichment Pipeline: schema result
- Grounded Enrichment Pipeline → Authoritative SQLite Store: accepted grounded enrichments
- Grounded Enrichment Pipeline → Rejected Enrichment Log: rejected attempts
- Authoritative SQLite Store → Final Validation: validates
- Authoritative SQLite Store → Dataset Exporter: export source
- Dataset Exporter → Published Dataset: JSON and CSV
- Authoritative SQLite Store → Quality Report: quality metrics
- Published Dataset → Submission Audit: audits deliverables
- Quality Report → Submission Audit: audit evidence
