# lisazhuuu/autoschema architecture

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

- Interactive diagram: https://gitdiagram.com/lisazhuuu/autoschema
- Repository: https://github.com/lisazhuuu/autoschema

## Overview

AutoSchema is a literature-to-structured-data artifact with two phases: it generates queries from seed papers, retrieves and iteratively curates literature, then induces a domain schema; Phase II uses that schema to extract evidence-grounded values from PDFs and write audit and tabular outputs. The README documents these stages and the iterative coordinator. Source excerpts are partial, so detailed links within unsampled retrieval and orchestration code are limited to documented relationships or SOURCE INDEX references.

Main entry points: [`extract_schema_values.py`](https://github.com/lisazhuuu/autoschema/blob/main/extract_schema_values.py) (Extraction Runner), [`design_extraction_prompt.py`](https://github.com/lisazhuuu/autoschema/blob/main/design_extraction_prompt.py) (Schema Induction), [`iterative_expand.py`](https://github.com/lisazhuuu/autoschema/blob/main/iterative_expand.py) (Iterative Coordinator), [`prompt_pipeline.py`](https://github.com/lisazhuuu/autoschema/blob/main/prompt_pipeline.py) (Query Generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_phase1["Phase I Discovery"]
  node_query["Query Generation<br/>[prompt_pipeline.py]"]
  node_iterative["Iterative Coordinator"]
  node_retrieve["Literature Retrieval<br/>[expand_round.py]"]
  node_search["Source Search<br/>[searches.py]"]
  node_prep["Candidate Preparation<br/>[preprocessing.py]"]
end

subgraph group_schema["Schema Induction"]
  node_induce["Schema Induction"]
  node_propose["Field Proposals<br/>[fields.py]"]
  node_sample["Paper Sampling<br/>[sampling.py]"]
  node_refine["Schema Refinement<br/>[refine.py]"]
  node_merge["Semantic Merge<br/>[merge.py]"]
end

subgraph group_phase2["Phase II Extraction"]
  node_extract["Extraction Runner"]
  node_pdf["PDF Text Reading<br/>[pdf_io.py]"]
  node_load["Schema Loading<br/>[schema_loader.py]"]
  node_context["Passage Retrieval<br/>[retrieval.py]"]
  node_prompt["Extraction Prompt<br/>[prompt_builder.py]"]
  node_llmextract["Value Extraction<br/>[llm_extract.py]"]
  node_post["Result Postprocessing<br/>[postprocess.py]"]
  node_writer["Audit and CSV Output<br/>[writer.py]"]
end

subgraph group_shared["Shared Services"]
  node_domains["Query Domains<br/>[domain.py]"]
  node_paper["Seed Paper Model<br/>[paper_model.py]"]
end

node_user(("Researcher"))
node_llm{{"LLM Provider"}}
node_sources{{"Academic Sources"}}

node_user -->|"starts run"| node_iterative
node_user -->|"generates queries"| node_query
node_query -->|"uses domain rules"| node_domains
node_query -->|"records seeds"| node_paper
node_iterative -->|"orchestrates"| node_query
node_iterative -->|"orchestrates"| node_retrieve
node_iterative -->|"orchestrates"| node_induce
node_retrieve -->|"searches sources"| node_search
node_retrieve -->|"prepares candidates"| node_prep
node_search -->|"queries"| node_sources
node_induce -->|"samples papers"| node_sample
node_induce -->|"proposes fields"| node_propose
node_induce -->|"refines schema"| node_refine
node_induce -->|"merges duplicates"| node_merge
node_propose -->|"requests proposals"| node_llm
node_merge -.->|"requests merge"| node_llm
node_extract -->|"reads PDFs"| node_pdf
node_extract -->|"loads schema"| node_load
node_extract -->|"selects passages"| node_context
node_extract -->|"builds prompts"| node_prompt
node_extract -->|"extracts values"| node_llmextract
node_extract -->|"postprocesses results"| node_post
node_extract -->|"writes outputs"| node_writer
node_prompt -->|"uses schema fields"| node_load
node_context -->|"scores schema fields"| node_load
node_llmextract -->|"requests extraction"| node_llm

click node_query "https://github.com/lisazhuuu/autoschema/blob/main/prompt_pipeline.py"
click node_domains "https://github.com/lisazhuuu/autoschema/blob/main/prompt_lib/domain.py"
click node_paper "https://github.com/lisazhuuu/autoschema/blob/main/prompt_lib/paper_model.py"
click node_iterative "https://github.com/lisazhuuu/autoschema/blob/main/iterative_expand.py"
click node_retrieve "https://github.com/lisazhuuu/autoschema/blob/main/expand_round.py"
click node_search "https://github.com/lisazhuuu/autoschema/blob/main/expand_lib/searches.py"
click node_prep "https://github.com/lisazhuuu/autoschema/blob/main/expand_lib/preprocessing.py"
click node_induce "https://github.com/lisazhuuu/autoschema/blob/main/design_extraction_prompt.py"
click node_propose "https://github.com/lisazhuuu/autoschema/blob/main/schema_lib/fields.py"
click node_sample "https://github.com/lisazhuuu/autoschema/blob/main/schema_lib/sampling.py"
click node_refine "https://github.com/lisazhuuu/autoschema/blob/main/schema_lib/refine.py"
click node_merge "https://github.com/lisazhuuu/autoschema/blob/main/schema_lib/merge.py"
click node_extract "https://github.com/lisazhuuu/autoschema/blob/main/extract_schema_values.py"
click node_pdf "https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/pdf_io.py"
click node_load "https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/schema_loader.py"
click node_context "https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/retrieval.py"
click node_prompt "https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/prompt_builder.py"
click node_llmextract "https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/llm_extract.py"
click node_post "https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/postprocess.py"
click node_writer "https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/writer.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_query,node_iterative,node_retrieve,node_search,node_prep toneBlue
class node_induce,node_propose,node_sample,node_refine,node_merge toneAmber
class node_extract,node_pdf,node_load,node_context,node_prompt,node_llmextract,node_post,node_writer toneMint
class node_domains,node_paper toneRose
class node_user,node_llm,node_sources toneIndigo
```

## Components

### Phase I Discovery

- [Query Generation](https://github.com/lisazhuuu/autoschema/blob/main/prompt_pipeline.py): `prompt_pipeline.py`
- [Iterative Coordinator](https://github.com/lisazhuuu/autoschema/blob/main/iterative_expand.py): `iterative_expand.py`
- [Literature Retrieval](https://github.com/lisazhuuu/autoschema/blob/main/expand_round.py): `expand_round.py`
- [Source Search](https://github.com/lisazhuuu/autoschema/blob/main/expand_lib/searches.py): `expand_lib/searches.py`
- [Candidate Preparation](https://github.com/lisazhuuu/autoschema/blob/main/expand_lib/preprocessing.py): `expand_lib/preprocessing.py`

### Schema Induction

- [Schema Induction](https://github.com/lisazhuuu/autoschema/blob/main/design_extraction_prompt.py): `design_extraction_prompt.py`
- [Field Proposals](https://github.com/lisazhuuu/autoschema/blob/main/schema_lib/fields.py): `schema_lib/fields.py`
- [Paper Sampling](https://github.com/lisazhuuu/autoschema/blob/main/schema_lib/sampling.py): `schema_lib/sampling.py`
- [Schema Refinement](https://github.com/lisazhuuu/autoschema/blob/main/schema_lib/refine.py): `schema_lib/refine.py`
- [Semantic Merge](https://github.com/lisazhuuu/autoschema/blob/main/schema_lib/merge.py): `schema_lib/merge.py`

### Phase II Extraction

- [Extraction Runner](https://github.com/lisazhuuu/autoschema/blob/main/extract_schema_values.py): `extract_schema_values.py`
- [PDF Text Reading](https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/pdf_io.py): `extract_lib/pdf_io.py`
- [Schema Loading](https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/schema_loader.py): `extract_lib/schema_loader.py`
- [Passage Retrieval](https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/retrieval.py): `extract_lib/retrieval.py`
- [Extraction Prompt](https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/prompt_builder.py): `extract_lib/prompt_builder.py`
- [Value Extraction](https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/llm_extract.py): `extract_lib/llm_extract.py`
- [Result Postprocessing](https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/postprocess.py): `extract_lib/postprocess.py`
- [Audit and CSV Output](https://github.com/lisazhuuu/autoschema/blob/main/extract_lib/writer.py): `extract_lib/writer.py`

### Shared Services

- [Query Domains](https://github.com/lisazhuuu/autoschema/blob/main/prompt_lib/domain.py): `prompt_lib/domain.py`
- [Seed Paper Model](https://github.com/lisazhuuu/autoschema/blob/main/prompt_lib/paper_model.py): `prompt_lib/paper_model.py`

### Other components

- **Researcher**
- **LLM Provider**
- **Academic Sources**

## Connections

- Researcher → Iterative Coordinator: starts run (evidence: `README.md`)
- Researcher → Query Generation: generates queries (evidence: `README.md`)
- Query Generation → Query Domains: uses domain rules (evidence: `prompt_pipeline.py`)
- Query Generation → Seed Paper Model: records seeds (evidence: `prompt_pipeline.py`)
- Iterative Coordinator → Query Generation: orchestrates (evidence: `README.md`)
- Iterative Coordinator → Literature Retrieval: orchestrates (evidence: `README.md`)
- Iterative Coordinator → Schema Induction: orchestrates (evidence: `README.md`)
- Literature Retrieval → Source Search: searches sources (evidence: `expand_round.py`)
- Literature Retrieval → Candidate Preparation: prepares candidates (evidence: `expand_round.py`)
- Source Search → Academic Sources: queries (evidence: `README.md`)
- Schema Induction → Paper Sampling: samples papers (evidence: `design_extraction_prompt.py`)
- Schema Induction → Field Proposals: proposes fields (evidence: `design_extraction_prompt.py`)
- Schema Induction → Schema Refinement: refines schema (evidence: `design_extraction_prompt.py`)
- Schema Induction → Semantic Merge: merges duplicates (evidence: `design_extraction_prompt.py`)
- Field Proposals → LLM Provider: requests proposals (evidence: `schema_lib/fields.py`)
- Semantic Merge → LLM Provider: requests merge
- Extraction Runner → PDF Text Reading: reads PDFs (evidence: `extract_schema_values.py`)
- Extraction Runner → Schema Loading: loads schema (evidence: `extract_schema_values.py`)
- Extraction Runner → Passage Retrieval: selects passages (evidence: `extract_schema_values.py`)
- Extraction Runner → Extraction Prompt: builds prompts (evidence: `extract_schema_values.py`)
- Extraction Runner → Value Extraction: extracts values (evidence: `extract_schema_values.py`)
- Extraction Runner → Result Postprocessing: postprocesses results (evidence: `extract_schema_values.py`)
- Extraction Runner → Audit and CSV Output: writes outputs (evidence: `extract_schema_values.py`)
- Extraction Prompt → Schema Loading: uses schema fields (evidence: `extract_lib/prompt_builder.py`)
- Passage Retrieval → Schema Loading: scores schema fields (evidence: `extract_lib/retrieval.py`)
- Value Extraction → LLM Provider: requests extraction (evidence: `extract_lib/llm_extract.py`)
