# antmedellin/researchrag architecture

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

- Interactive diagram: https://gitdiagram.com/antmedellin/researchrag
- Repository: https://github.com/antmedellin/researchrag

## Overview

Local ResearcherRAG ingests Digital Measures faculty data by department, builds and reconciles research records, then serves scoped portfolio search, evidence, structured answers, and faculty/team matching. Neo4j is the graph source of truth; Qdrant supports hybrid dense/BM25 retrieval. The README also documents OpenAlex enrichment. Edges reflect excerpts, SOURCE INDEX references, or README statements; unsampled implementation details and some integrations are not asserted.

Main entry points: [`src/research_portfolio/run_department.py`](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/run_department.py) (Department sync), [`src/research_portfolio/web/app.py`](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/web/app.py) (Research API), [`src/research_portfolio/ledger/build_ledger.py`](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/build_ledger.py) (Ledger builder), [`src/research_portfolio/retrieval/search.py`](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/retrieval/search.py) (Hybrid retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Department ingestion"]
  node_department_config["Department config"]
  node_department_run["Department sync<br/>[run_department.py]"]
  node_faculty_discovery["Faculty discovery"]
  node_profile_fetch["Profile fetching<br/>[fetch_profiles.py]"]
  node_ledger_build["Ledger builder<br/>[build_ledger.py]"]
  node_dm_parser["Profile parser<br/>[dm_parse.py]"]
  node_record_merge["Record merging<br/>[merge.py]"]
  node_common["Shared data helpers<br/>[common.py]"]
end

subgraph group_identity["Identity and enrichment"]
  node_entity_dedup["Entity dedup<br/>[dedup.py]"]
  node_person_identity["Person identity<br/>[person_identity.py]"]
  node_openalex["OpenAlex enrichment<br/>[openalex.py]"]
  node_enrichment_apply["Enrichment apply"]
end

subgraph group_stores["Research stores"]
  node_neo4j[("Neo4j graph<br/>[store.py]")]
  node_qdrant_index["Qdrant indexing<br/>[qdrant_store.py]"]
end

subgraph group_query["Search and matching"]
  node_retrieval["Hybrid retrieval<br/>[search.py]"]
  node_structured["Structured records<br/>[structured.py]"]
  node_faculty_match["Faculty matching<br/>[faculty_match.py]"]
  node_person_match["Person matching<br/>[person_match.py]"]
end

subgraph group_runtime["API and models"]
  node_web_api["Research API<br/>[app.py]"]
  node_answer_guard["Answer and evidence<br/>[answer_guard.py]"]
  node_llm_client["LLM transport<br/>[llm_client.py]"]
  node_llm_endpoints["Model endpoints<br/>[llm_endpoints.py]"]
end

node_operator(("Department operator"))
node_dm[("Digital Measures")]
node_qdrant[("Qdrant")]
node_llm_gateway["LLM gateway"]

node_operator -->|"runs department"| node_department_run
node_department_run -->|"loads config"| node_department_config
node_department_run -->|"discovers faculty"| node_faculty_discovery
node_faculty_discovery -.->|"fetches roster"| node_dm
node_department_run -->|"fetches profiles"| node_profile_fetch
node_profile_fetch -.->|"fetches profiles"| node_dm
node_department_run -->|"builds ledger"| node_ledger_build
node_ledger_build -->|"parses records"| node_dm_parser
node_ledger_build -->|"merges records"| node_record_merge
node_dm_parser -->|"checks identity"| node_person_identity
node_department_run -->|"resolves entities"| node_entity_dedup
node_entity_dedup -->|"merges matches"| node_record_merge
node_department_run -->|"syncs graph"| node_neo4j
node_department_run -->|"indexes records"| node_qdrant_index
node_qdrant_index -->|"reads graph"| node_neo4j
node_qdrant_index -->|"writes vectors"| node_qdrant
node_operator -.->|"queries portfolio"| node_web_api
node_web_api -->|"searches evidence"| node_retrieval
node_web_api -.->|"queries records"| node_structured
node_web_api -->|"matches faculty"| node_faculty_match
node_web_api -->|"resolves people"| node_person_match
node_web_api -->|"guards answers"| node_answer_guard
node_retrieval -->|"queries candidates"| node_qdrant
node_retrieval -.->|"looks up people"| node_neo4j
node_faculty_match -->|"reranks evidence"| node_retrieval
node_faculty_match -.->|"reads collaborations"| node_neo4j
node_answer_guard -.->|"requests answer"| node_llm_client
node_llm_client -->|"uses endpoints"| node_llm_endpoints
node_llm_endpoints -->|"configures routes"| node_llm_gateway
node_department_run -.->|"enriches research"| node_openalex
node_openalex -.->|"applies metadata"| node_enrichment_apply
node_ledger_build -->|"uses shared helpers"| node_common

click node_department_config "https://github.com/antmedellin/researchrag/tree/main/config/departments"
click node_department_run "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/run_department.py"
click node_faculty_discovery "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/discover_faculty.py"
click node_profile_fetch "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/fetch_profiles.py"
click node_ledger_build "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/build_ledger.py"
click node_dm_parser "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/dm_parse.py"
click node_record_merge "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/merge.py"
click node_entity_dedup "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/resolve/dedup.py"
click node_person_identity "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/resolve/person_identity.py"
click node_openalex "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/enrichment/openalex.py"
click node_enrichment_apply "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/enrichment/apply_enrichment.py"
click node_neo4j "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/graph/store.py"
click node_qdrant_index "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/index/qdrant_store.py"
click node_web_api "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/web/app.py"
click node_retrieval "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/retrieval/search.py"
click node_structured "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/retrieval/structured.py"
click node_faculty_match "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/matching/faculty_match.py"
click node_person_match "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/person_match.py"
click node_answer_guard "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/answer_guard.py"
click node_llm_client "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/llm_client.py"
click node_llm_endpoints "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/llm_endpoints.py"
click node_common "https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/common.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_department_config,node_department_run,node_faculty_discovery,node_profile_fetch,node_ledger_build,node_dm_parser,node_record_merge,node_common toneBlue
class node_entity_dedup,node_person_identity,node_openalex,node_enrichment_apply,node_dm,node_qdrant toneAmber
class node_neo4j,node_qdrant_index toneMint
class node_retrieval,node_structured,node_faculty_match,node_person_match toneRose
class node_web_api,node_answer_guard,node_llm_client,node_llm_endpoints,node_operator,node_llm_gateway toneIndigo
```

## Components

### Department ingestion

- [Department config](https://github.com/antmedellin/researchrag/tree/main/config/departments): `config/departments`
- [Department sync](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/run_department.py): `src/research_portfolio/run_department.py`
- [Faculty discovery](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/discover_faculty.py): `src/research_portfolio/ledger/discover_faculty.py`
- [Profile fetching](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/fetch_profiles.py): `src/research_portfolio/ledger/fetch_profiles.py`
- [Ledger builder](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/build_ledger.py): `src/research_portfolio/ledger/build_ledger.py`
- [Profile parser](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/dm_parse.py): `src/research_portfolio/ledger/dm_parse.py`
- [Record merging](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/ledger/merge.py): `src/research_portfolio/ledger/merge.py`
- [Shared data helpers](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/common.py): `src/research_portfolio/common.py`

### Identity and enrichment

- [Entity dedup](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/resolve/dedup.py): `src/research_portfolio/resolve/dedup.py`
- [Person identity](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/resolve/person_identity.py): `src/research_portfolio/resolve/person_identity.py`
- [OpenAlex enrichment](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/enrichment/openalex.py): `src/research_portfolio/enrichment/openalex.py`
- [Enrichment apply](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/enrichment/apply_enrichment.py): `src/research_portfolio/enrichment/apply_enrichment.py`

### Research stores

- [Neo4j graph](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/graph/store.py): `src/research_portfolio/graph/store.py`
- [Qdrant indexing](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/index/qdrant_store.py): `src/research_portfolio/index/qdrant_store.py`

### Search and matching

- [Hybrid retrieval](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/retrieval/search.py): `src/research_portfolio/retrieval/search.py`
- [Structured records](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/retrieval/structured.py): `src/research_portfolio/retrieval/structured.py`
- [Faculty matching](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/matching/faculty_match.py): `src/research_portfolio/matching/faculty_match.py`
- [Person matching](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/person_match.py): `src/research_portfolio/person_match.py`

### API and models

- [Research API](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/web/app.py): `src/research_portfolio/web/app.py`
- [Answer and evidence](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/answer_guard.py): `src/research_portfolio/answer_guard.py`
- [LLM transport](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/llm_client.py): `src/research_portfolio/llm_client.py`
- [Model endpoints](https://github.com/antmedellin/researchrag/blob/main/src/research_portfolio/llm_endpoints.py): `src/research_portfolio/llm_endpoints.py`

### Other components

- **Department operator**
- **Digital Measures**
- **Qdrant**
- **LLM gateway**

## Connections

- Department operator → Department sync: runs department (evidence: `src/research_portfolio/run_department.py`)
- Department sync → Department config: loads config (evidence: `src/research_portfolio/run_department.py`)
- Department sync → Faculty discovery: discovers faculty (evidence: `src/research_portfolio/run_department.py`)
- Faculty discovery → Digital Measures: fetches roster
- Department sync → Profile fetching: fetches profiles (evidence: `src/research_portfolio/run_department.py`)
- Profile fetching → Digital Measures: fetches profiles
- Department sync → Ledger builder: builds ledger (evidence: `src/research_portfolio/run_department.py`)
- Ledger builder → Profile parser: parses records (evidence: `src/research_portfolio/ledger/build_ledger.py`)
- Ledger builder → Record merging: merges records (evidence: `src/research_portfolio/ledger/build_ledger.py`)
- Profile parser → Person identity: checks identity (evidence: `src/research_portfolio/ledger/dm_parse.py`)
- Department sync → Entity dedup: resolves entities (evidence: `src/research_portfolio/run_department.py`)
- Entity dedup → Record merging: merges matches (evidence: `src/research_portfolio/resolve/dedup.py`)
- Department sync → Neo4j graph: syncs graph (evidence: `src/research_portfolio/run_department.py`)
- Department sync → Qdrant indexing: indexes records (evidence: `src/research_portfolio/run_department.py`)
- Qdrant indexing → Neo4j graph: reads graph (evidence: `src/research_portfolio/index/qdrant_store.py`)
- Qdrant indexing → Qdrant: writes vectors (evidence: `src/research_portfolio/index/qdrant_store.py`)
- Department operator → Research API: queries portfolio
- Research API → Hybrid retrieval: searches evidence (evidence: `src/research_portfolio/web/app.py`)
- Research API → Structured records: queries records
- Research API → Faculty matching: matches faculty (evidence: `src/research_portfolio/web/app.py`)
- Research API → Person matching: resolves people (evidence: `src/research_portfolio/web/app.py`)
- Research API → Answer and evidence: guards answers (evidence: `src/research_portfolio/web/app.py`)
- Hybrid retrieval → Qdrant: queries candidates (evidence: `src/research_portfolio/retrieval/search.py`)
- Hybrid retrieval → Neo4j graph: looks up people
- Faculty matching → Hybrid retrieval: reranks evidence (evidence: `src/research_portfolio/matching/faculty_match.py`)
- Faculty matching → Neo4j graph: reads collaborations
- Answer and evidence → LLM transport: requests answer (evidence: `src/research_portfolio/answer_guard.py`)
- LLM transport → Model endpoints: uses endpoints (evidence: `src/research_portfolio/llm_client.py`)
- Model endpoints → LLM gateway: configures routes (evidence: `src/research_portfolio/llm_endpoints.py`)
- Department sync → OpenAlex enrichment: enriches research
- OpenAlex enrichment → Enrichment apply: applies metadata
- Ledger builder → Shared data helpers: uses shared helpers (evidence: `src/research_portfolio/ledger/build_ledger.py`)
