# dhruvisherathiya/nl-query-filter-agent architecture

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

- Interactive diagram: https://gitdiagram.com/dhruvisherathiya/nl-query-filter-agent
- Repository: https://github.com/dhruvisherathiya/nl-query-filter-agent

## Overview

This is a FastAPI service that turns natural-language requests into Pinecone-compatible metadata-filter JSON; it does not execute Pinecone searches. The main workflow runs from a user request through the API to the parsing agent, which builds a few-shot prompt, calls the configured OpenRouter model, and parses its JSON response. A separate evaluation workflow loads synthetic cases and invokes the same agent to score predictions; the API exposes both workflows. Relationships reflect the shown calls and README description; the model provider is documented, but no Pinecone integration is shown.

Main entry points: [`app/agent.py`](https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/agent.py) (Query parser), [`app/main.py`](https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/main.py) (FastAPI endpoints), [`app/eval_pipeline.py`](https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/eval_pipeline.py) (Evaluation pipeline), [`app/prompt.py`](https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/prompt.py) (Few-shot prompt)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_api["FastAPI endpoints<br/>[main.py]"]
end

subgraph group_generation["Filter Generation"]
  node_agent["Query parser<br/>[agent.py]"]
  node_prompt["Few-shot prompt<br/>[prompt.py]"]
  node_client["LLM client config<br/>[client.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_eval["Evaluation pipeline<br/>[eval_pipeline.py]"]
  node_dataset["Synthetic evaluation data"]
end

node_user(("User"))
node_openrouter{{"OpenRouter model"}}

node_user -->|"submits query"| node_api
node_api -->|"parses filter"| node_agent
node_agent -->|"builds prompt"| node_prompt
node_agent -->|"uses client"| node_client
node_agent -->|"requests JSON"| node_openrouter
node_api -->|"returns response"| node_user
node_api -->|"runs evaluation"| node_eval
node_eval -->|"loads cases"| node_dataset
node_eval -->|"scores predictions"| node_agent

click node_api "https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/main.py"
click node_agent "https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/agent.py"
click node_prompt "https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/prompt.py"
click node_client "https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/client.py"
click node_eval "https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/eval_pipeline.py"
click node_dataset "https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/data/synthetic_eval_data.json"

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_api,node_user toneBlue
class node_agent,node_prompt,node_client toneAmber
class node_eval,node_dataset,node_openrouter toneMint
```

## Components

### HTTP API

- [FastAPI endpoints](https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/main.py): `app/main.py`

### Filter Generation

- [Query parser](https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/agent.py): `app/agent.py`
- [Few-shot prompt](https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/prompt.py): `app/prompt.py`
- [LLM client config](https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/client.py): `app/client.py`

### Evaluation

- [Evaluation pipeline](https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/eval_pipeline.py): `app/eval_pipeline.py`
- [Synthetic evaluation data](https://github.com/dhruvisherathiya/nl-query-filter-agent/blob/main/app/data/synthetic_eval_data.json): `app/data/synthetic_eval_data.json`

### Other components

- **User**
- **OpenRouter model**

## Connections

- User → FastAPI endpoints: submits query (evidence: `README.md`)
- FastAPI endpoints → Query parser: parses filter (evidence: `app/main.py`)
- Query parser → Few-shot prompt: builds prompt (evidence: `app/agent.py`)
- Query parser → LLM client config: uses client (evidence: `app/agent.py`)
- Query parser → OpenRouter model: requests JSON (evidence: `app/agent.py`)
- FastAPI endpoints → User: returns response (evidence: `app/main.py`)
- FastAPI endpoints → Evaluation pipeline: runs evaluation (evidence: `app/main.py`)
- Evaluation pipeline → Synthetic evaluation data: loads cases (evidence: `app/eval_pipeline.py`)
- Evaluation pipeline → Query parser: scores predictions (evidence: `app/eval_pipeline.py`)
