# amdhaffar/slrresearchai-td02 architecture

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

- Interactive diagram: https://gitdiagram.com/amdhaffar/slrresearchai-td02
- Repository: https://github.com/amdhaffar/slrresearchai-td02

## Overview

SLRResearchAI is a teaching application for turning a review topic into controlled systematic-literature-review search queries. The workflow contrasts zero-shot and few-shot question generation, checks formatted text, attempts at most one repair before human escalation, then applies a Pydantic contract and builds Boolean queries for Scholar, IEEE, and ACM. The CLI and Streamlit interface expose this workflow; configuration selects Ollama or Groq. Some Streamlit code and the query-pipeline implementation were not fully sampled, so those connections are included only where documented or directly visible.

Main entry points: [`streamlit_app.py`](https://github.com/amdhaffar/slrresearchai-td02/blob/main/streamlit_app.py) (Streamlit App), [`main.py`](https://github.com/amdhaffar/slrresearchai-td02/blob/main/main.py) (CLI Workflow), [`slrresearch/config.py`](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/config.py) (Model Factory), [`slrresearch/search_plan.py`](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py) (Controlled Workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["CLI Workflow<br/>[main.py]"]
  node_webapp["Streamlit App<br/>[streamlit_app.py]"]
end

subgraph group_generation["Question Generation"]
  node_zero_shot["Zero-shot Questions"]
end

subgraph group_control["Validation and Repair"]
  node_few_shot["Few-shot Prompt<br/>[search_plan.py]"]
  node_text_validation["Text Validation<br/>[search_plan.py]"]
  node_repair["Single Repair<br/>[search_plan.py]"]
  node_workflow["Controlled Workflow<br/>[search_plan.py]"]
  node_human_review(("Human Review"))
end

subgraph group_search["Search Planning"]
  node_question_contract["Question Contract<br/>[search_plan.py]"]
  node_query_builder["Query Builder<br/>[search_plan.py]"]
end

subgraph group_configuration["Model Configuration"]
  node_settings["Provider Settings<br/>[config.py]"]
  node_model_factory["Model Factory<br/>[config.py]"]
end

node_researcher(("Researcher"))
node_ollama["Ollama"]
node_groq["Groq"]
node_research_engines["Research Engines"]

node_researcher -->|"enters topic"| node_cli
node_researcher -->|"uses interface"| node_webapp
node_cli -->|"loads settings"| node_settings
node_cli -->|"builds model"| node_model_factory
node_webapp -->|"loads settings"| node_settings
node_webapp -->|"builds model"| node_model_factory
node_settings -->|"configures"| node_model_factory
node_model_factory -.->|"selects provider"| node_ollama
node_model_factory -.->|"selects provider"| node_groq
node_cli -->|"generates questions"| node_zero_shot
node_zero_shot -->|"invokes model"| node_model_factory
node_cli -->|"builds prompt"| node_few_shot
node_cli -->|"checks output"| node_text_validation
node_cli -->|"runs workflow"| node_workflow
node_cli -->|"invokes pipeline"| node_query_builder
node_webapp -->|"generates questions"| node_zero_shot
node_webapp -->|"builds prompt"| node_few_shot
node_webapp -->|"checks output"| node_text_validation
node_webapp -->|"requests repair"| node_repair
node_webapp -->|"validates questions"| node_question_contract
node_webapp -->|"runs pipeline"| node_query_builder
node_workflow -->|"validates text"| node_text_validation
node_workflow -->|"repairs on failure"| node_repair
node_workflow -->|"validates records"| node_question_contract
node_repair -->|"invokes model"| node_model_factory
node_workflow -->|"escalates failure"| node_human_review
node_question_contract -.->|"supplies questions"| node_query_builder
node_query_builder -->|"targets queries"| node_research_engines

click node_cli "https://github.com/amdhaffar/slrresearchai-td02/blob/main/main.py"
click node_webapp "https://github.com/amdhaffar/slrresearchai-td02/blob/main/streamlit_app.py"
click node_settings "https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/config.py"
click node_model_factory "https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/config.py"
click node_zero_shot "https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/research_questions.py"
click node_few_shot "https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py"
click node_text_validation "https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py"
click node_repair "https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py"
click node_workflow "https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py"
click node_question_contract "https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py"
click node_query_builder "https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.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_cli,node_webapp toneBlue
class node_zero_shot toneAmber
class node_few_shot,node_text_validation,node_repair,node_workflow,node_human_review toneMint
class node_question_contract,node_query_builder toneRose
class node_settings,node_model_factory,node_researcher,node_ollama,node_groq,node_research_engines toneIndigo
```

## Components

### User Interfaces

- [CLI Workflow](https://github.com/amdhaffar/slrresearchai-td02/blob/main/main.py): `main.py`
- [Streamlit App](https://github.com/amdhaffar/slrresearchai-td02/blob/main/streamlit_app.py): `streamlit_app.py`

### Question Generation

- [Zero-shot Questions](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/research_questions.py): `slrresearch/research_questions.py`

### Validation and Repair

- [Few-shot Prompt](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py): `slrresearch/search_plan.py`
- [Text Validation](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py): `slrresearch/search_plan.py`
- [Single Repair](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py): `slrresearch/search_plan.py`
- [Controlled Workflow](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py): `slrresearch/search_plan.py`
- **Human Review**

### Search Planning

- [Question Contract](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py): `slrresearch/search_plan.py`
- [Query Builder](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/search_plan.py): `slrresearch/search_plan.py`

### Model Configuration

- [Provider Settings](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/config.py): `slrresearch/config.py`
- [Model Factory](https://github.com/amdhaffar/slrresearchai-td02/blob/main/slrresearch/config.py): `slrresearch/config.py`

### Other components

- **Researcher**
- **Ollama**
- **Groq**
- **Research Engines**

## Connections

- Researcher → CLI Workflow: enters topic (evidence: `main.py`)
- Researcher → Streamlit App: uses interface (evidence: `streamlit_app.py`)
- CLI Workflow → Provider Settings: loads settings (evidence: `main.py`)
- CLI Workflow → Model Factory: builds model (evidence: `main.py`)
- Streamlit App → Provider Settings: loads settings (evidence: `streamlit_app.py`)
- Streamlit App → Model Factory: builds model (evidence: `streamlit_app.py`)
- Provider Settings → Model Factory: configures (evidence: `slrresearch/config.py`)
- Model Factory → Ollama: selects provider (evidence: `slrresearch/config.py`)
- Model Factory → Groq: selects provider (evidence: `slrresearch/config.py`)
- CLI Workflow → Zero-shot Questions: generates questions (evidence: `main.py`)
- Zero-shot Questions → Model Factory: invokes model (evidence: `main.py`)
- CLI Workflow → Few-shot Prompt: builds prompt (evidence: `main.py`)
- CLI Workflow → Text Validation: checks output (evidence: `main.py`)
- CLI Workflow → Controlled Workflow: runs workflow (evidence: `main.py`)
- CLI Workflow → Query Builder: invokes pipeline (evidence: `main.py`)
- Streamlit App → Zero-shot Questions: generates questions (evidence: `streamlit_app.py`)
- Streamlit App → Few-shot Prompt: builds prompt (evidence: `streamlit_app.py`)
- Streamlit App → Text Validation: checks output (evidence: `streamlit_app.py`)
- Streamlit App → Single Repair: requests repair (evidence: `streamlit_app.py`)
- Streamlit App → Question Contract: validates questions (evidence: `streamlit_app.py`)
- Streamlit App → Query Builder: runs pipeline (evidence: `streamlit_app.py`)
- Controlled Workflow → Text Validation: validates text (evidence: `slrresearch/search_plan.py`)
- Controlled Workflow → Single Repair: repairs on failure (evidence: `slrresearch/search_plan.py`)
- Controlled Workflow → Question Contract: validates records (evidence: `slrresearch/search_plan.py`)
- Single Repair → Model Factory: invokes model (evidence: `slrresearch/search_plan.py`)
- Controlled Workflow → Human Review: escalates failure (evidence: `README.md`)
- Question Contract → Query Builder: supplies questions (evidence: `README.md`)
- Query Builder → Research Engines: targets queries (evidence: `slrresearch/search_plan.py`)
