# medh642/bench4geocode architecture

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

- Interactive diagram: https://gitdiagram.com/medh642/bench4geocode
- Repository: https://github.com/medh642/bench4geocode

## Overview

Bench4GeoCode is a benchmark and geospatial code-generation assistant: a user submits a natural-language task, the runtime optionally retrieves geospatial and dataset context, applies a selected prompt strategy, and returns generated Python. The repository also contains benchmark reference solutions and a functional evaluator that compares generated results with canonical outputs, with an LLM cross-check for deterministic failures. The README documents multiple model providers and benchmark complexity and robustness categories. Some runtime wiring and evaluation inputs are not present in the supplied tree or excerpts, so uncertain connections are omitted.

Main entry points: [`templates/__init__.py`](https://github.com/medh642/bench4geocode/blob/main/templates/__init__.py) (Template registry), [`main.py`](https://github.com/medh642/bench4geocode/blob/main/main.py) (Generation runtime), [`functional_eval/Functional_eval.py`](https://github.com/medh642/bench4geocode/blob/main/functional_eval/Functional_eval.py) (Functional evaluator), [`factory.py`](https://github.com/medh642/bench4geocode/blob/main/factory.py) (Model factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_web_app["Streamlit assistant<br/>[app.py]"]
  node_cli["Benchmark CLI<br/>[cli.py]"]
end

subgraph group_generation["Code generation"]
  node_runtime["Generation runtime<br/>[main.py]"]
  node_template_registry["Template registry<br/>[__init__.py]"]
  node_baseline["Baseline prompt<br/>[baseline.py]"]
  node_simple_rag["Simple RAG prompt<br/>[simple_rag.py]"]
  node_failure_check["Failure-check prompt<br/>[failure_check.py]"]
  node_information_gate["Information gate"]
  node_codegen["Clarified code prompt<br/>[codegen.py]"]
  node_knowledge_prompt["Knowledge prompt"]
end

subgraph group_knowledge["Retrieval and models"]
  node_retrieval["Context retrieval<br/>[retrieval.py]"]
  node_vector_store[("Chroma collections")]
  node_model_factory["Model factory<br/>[factory.py]"]
  node_model_provider(("Configured LLM"))
end

subgraph group_evaluation["Benchmark evaluation"]
  node_reference_corpus["Reference solutions"]
  node_functional_eval["Functional evaluator<br/>[Functional_eval.py]"]
  node_reference_execution["Reference execution"]
  node_canonical_outputs[("Canonical outputs")]
end

node_user(("Geospatial user"))

node_user -->|"submits query"| node_web_app
node_web_app -->|"requests generation"| node_runtime
node_cli -.->|"runs benchmark"| node_runtime
node_runtime -->|"selects template"| node_template_registry
node_runtime -->|"retrieves context"| node_retrieval
node_runtime -->|"initializes model"| node_model_factory
node_template_registry -->|"registers prompt"| node_baseline
node_template_registry -->|"registers prompt"| node_simple_rag
node_template_registry -->|"registers prompt"| node_failure_check
node_template_registry -->|"registers prompt"| node_information_gate
node_template_registry -->|"registers prompt"| node_codegen
node_template_registry -->|"registers prompt"| node_knowledge_prompt
node_retrieval -->|"queries collections"| node_vector_store
node_model_factory -->|"creates configured model"| node_model_provider
node_functional_eval -->|"initializes evaluator LLM"| node_model_factory
node_functional_eval -->|"loads reference results"| node_canonical_outputs
node_reference_corpus -.->|"documents benchmark references"| node_functional_eval

click node_web_app "https://github.com/medh642/bench4geocode/blob/main/app.py"
click node_cli "https://github.com/medh642/bench4geocode/blob/main/cli.py"
click node_runtime "https://github.com/medh642/bench4geocode/blob/main/main.py"
click node_template_registry "https://github.com/medh642/bench4geocode/blob/main/templates/__init__.py"
click node_baseline "https://github.com/medh642/bench4geocode/blob/main/templates/baseline.py"
click node_simple_rag "https://github.com/medh642/bench4geocode/blob/main/templates/simple_rag.py"
click node_failure_check "https://github.com/medh642/bench4geocode/blob/main/templates/failure_check.py"
click node_information_gate "https://github.com/medh642/bench4geocode/blob/main/templates/information_gate.py"
click node_codegen "https://github.com/medh642/bench4geocode/blob/main/templates/codegen.py"
click node_knowledge_prompt "https://github.com/medh642/bench4geocode/blob/main/templates/knowledge_enhanced.py"
click node_retrieval "https://github.com/medh642/bench4geocode/blob/main/retrieval.py"
click node_model_factory "https://github.com/medh642/bench4geocode/blob/main/factory.py"
click node_reference_corpus "https://github.com/medh642/bench4geocode/tree/main/reference_code"
click node_functional_eval "https://github.com/medh642/bench4geocode/blob/main/functional_eval/Functional_eval.py"
click node_reference_execution "https://github.com/medh642/bench4geocode/blob/main/functional_eval/reference_execution.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_web_app,node_cli,node_user toneBlue
class node_runtime,node_template_registry,node_baseline,node_simple_rag,node_failure_check,node_information_gate,node_codegen,node_knowledge_prompt toneAmber
class node_retrieval,node_vector_store,node_model_factory,node_model_provider toneMint
class node_reference_corpus,node_functional_eval,node_reference_execution,node_canonical_outputs toneRose
```

## Components

### User interfaces

- [Streamlit assistant](https://github.com/medh642/bench4geocode/blob/main/app.py): `app.py`
- [Benchmark CLI](https://github.com/medh642/bench4geocode/blob/main/cli.py): `cli.py`

### Code generation

- [Generation runtime](https://github.com/medh642/bench4geocode/blob/main/main.py): `main.py`
- [Template registry](https://github.com/medh642/bench4geocode/blob/main/templates/__init__.py): `templates/__init__.py`
- [Baseline prompt](https://github.com/medh642/bench4geocode/blob/main/templates/baseline.py): `templates/baseline.py`
- [Simple RAG prompt](https://github.com/medh642/bench4geocode/blob/main/templates/simple_rag.py): `templates/simple_rag.py`
- [Failure-check prompt](https://github.com/medh642/bench4geocode/blob/main/templates/failure_check.py): `templates/failure_check.py`
- [Information gate](https://github.com/medh642/bench4geocode/blob/main/templates/information_gate.py): `templates/information_gate.py`
- [Clarified code prompt](https://github.com/medh642/bench4geocode/blob/main/templates/codegen.py): `templates/codegen.py`
- [Knowledge prompt](https://github.com/medh642/bench4geocode/blob/main/templates/knowledge_enhanced.py): `templates/knowledge_enhanced.py`

### Retrieval and models

- [Context retrieval](https://github.com/medh642/bench4geocode/blob/main/retrieval.py): `retrieval.py`
- **Chroma collections**
- [Model factory](https://github.com/medh642/bench4geocode/blob/main/factory.py): `factory.py`
- **Configured LLM**

### Benchmark evaluation

- [Reference solutions](https://github.com/medh642/bench4geocode/tree/main/reference_code): `reference_code`
- [Functional evaluator](https://github.com/medh642/bench4geocode/blob/main/functional_eval/Functional_eval.py): `functional_eval/Functional_eval.py`
- [Reference execution](https://github.com/medh642/bench4geocode/blob/main/functional_eval/reference_execution.py): `functional_eval/reference_execution.py`
- **Canonical outputs**

### Other components

- **Geospatial user**

## Connections

- Geospatial user → Streamlit assistant: submits query (evidence: `app.py`)
- Streamlit assistant → Generation runtime: requests generation (evidence: `app.py`)
- Benchmark CLI → Generation runtime: runs benchmark (evidence: `README.md`)
- Generation runtime → Template registry: selects template (evidence: `main.py`)
- Generation runtime → Context retrieval: retrieves context (evidence: `main.py`)
- Generation runtime → Model factory: initializes model (evidence: `main.py`)
- Template registry → Baseline prompt: registers prompt (evidence: `templates/__init__.py`)
- Template registry → Simple RAG prompt: registers prompt (evidence: `templates/__init__.py`)
- Template registry → Failure-check prompt: registers prompt (evidence: `templates/__init__.py`)
- Template registry → Information gate: registers prompt (evidence: `templates/__init__.py`)
- Template registry → Clarified code prompt: registers prompt (evidence: `templates/__init__.py`)
- Template registry → Knowledge prompt: registers prompt (evidence: `templates/__init__.py`)
- Context retrieval → Chroma collections: queries collections (evidence: `retrieval.py`)
- Model factory → Configured LLM: creates configured model (evidence: `factory.py`)
- Functional evaluator → Model factory: initializes evaluator LLM (evidence: `functional_eval/Functional_eval.py`)
- Functional evaluator → Canonical outputs: loads reference results (evidence: `functional_eval/Functional_eval.py`)
- Reference solutions → Functional evaluator: documents benchmark references (evidence: `README.md`)
