# kyanqueso/thesis_clean architecture

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

- Interactive diagram: https://gitdiagram.com/kyanqueso/thesis_clean
- Repository: https://github.com/kyanqueso/thesis_clean

## Overview

This repository combines an indirect-prompt-injection research pipeline with a local dashboard for exploring results, running retraining jobs, and testing saved classifiers. The research workflow builds datasets, embeds context/intent pairs, trains and evaluates classifiers, and stores run artifacts; the dashboard discovers those artifacts and exposes analysis and live detection. The main pipeline stages are documented, but several implementation files were not sampled, so their internal connections are omitted unless supported by the README or source index.

Main entry points: [`app/server.py`](https://github.com/kyanqueso/thesis_clean/blob/main/app/server.py) (Dashboard API), [`src/run_all_pipelines.py`](https://github.com/kyanqueso/thesis_clean/blob/main/src/run_all_pipelines.py) (Pipeline sweep), [`src/train_evaluate_visualize.py`](https://github.com/kyanqueso/thesis_clean/blob/main/src/train_evaluate_visualize.py) (Train and evaluate), [`app/detect.py`](https://github.com/kyanqueso/thesis_clean/blob/main/app/detect.py) (Live detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_research["Research pipeline"]
  node_datasets["Dataset preparation<br/>[organic_dataset.py]"]
  node_anonymize["Email anonymization<br/>[anonymize_enron.py]"]
  node_embeddings["Pair embeddings"]
  node_evaluation["Train and evaluate"]
  node_orchestrator["Pipeline sweep"]
  node_progress["Progress markers<br/>[progress.py]"]
end

subgraph group_dashboard["Dashboard"]
  node_server["Dashboard API<br/>[server.py]"]
  node_ui["Dashboard UI<br/>[app.js]"]
  node_detect["Live detection<br/>[detect.py]"]
  node_jobs["Run job queue<br/>[jobs.py]"]
  node_settings["Settings<br/>[settings.py]"]
end

subgraph group_artifacts["Artifacts and paths"]
  node_runs_reader["Run analysis<br/>[runs.py]"]
  node_paths["Dashboard paths<br/>[paths.py]"]
  node_resolver["Tree resolver<br/>[pipeline_paths.py]"]
  node_run_store[("Run artifacts")]
end

subgraph group_integrations["External integrations"]
  node_openai["OpenAI API"]
  node_vast["Vast.ai worker<br/>[vast.py]"]
end

node_user(("Engineer"))
node_browser(("Browser"))

node_user -->|"uses dashboard"| node_browser
node_browser -->|"requests API"| node_server
node_server -->|"queries runs"| node_runs_reader
node_server -->|"requests detection"| node_detect
node_server -->|"manages jobs"| node_jobs
node_server -->|"updates settings"| node_settings
node_server -->|"tests connection"| node_vast
node_runs_reader -->|"resolves artifacts"| node_paths
node_paths -->|"uses tree locations"| node_resolver
node_jobs -->|"launches sweep"| node_orchestrator
node_orchestrator -->|"runs embedding stage"| node_embeddings
node_orchestrator -->|"runs evaluation stage"| node_evaluation
node_orchestrator -->|"writes run outputs"| node_run_store
node_evaluation -->|"saves models and results"| node_run_store
node_runs_reader -->|"reads run data"| node_run_store
node_detect -->|"loads saved classifiers"| node_run_store
node_detect -.->|"embeds text"| node_openai
node_jobs -->|"dispatches remote embedding"| node_vast
node_embeddings -.->|"emits progress"| node_progress
node_evaluation -.->|"emits progress"| node_progress
node_anonymize -->|"scrubs source text"| node_datasets
node_browser -.->|"loads interface"| node_ui

click node_server "https://github.com/kyanqueso/thesis_clean/blob/main/app/server.py"
click node_ui "https://github.com/kyanqueso/thesis_clean/blob/main/app/static/app.js"
click node_detect "https://github.com/kyanqueso/thesis_clean/blob/main/app/detect.py"
click node_jobs "https://github.com/kyanqueso/thesis_clean/blob/main/app/jobs.py"
click node_settings "https://github.com/kyanqueso/thesis_clean/blob/main/app/settings.py"
click node_runs_reader "https://github.com/kyanqueso/thesis_clean/blob/main/app/runs.py"
click node_paths "https://github.com/kyanqueso/thesis_clean/blob/main/app/paths.py"
click node_resolver "https://github.com/kyanqueso/thesis_clean/blob/main/pipeline_paths.py"
click node_datasets "https://github.com/kyanqueso/thesis_clean/blob/main/src/organic_dataset.py"
click node_anonymize "https://github.com/kyanqueso/thesis_clean/blob/main/src/anonymize_enron.py"
click node_embeddings "https://github.com/kyanqueso/thesis_clean/blob/main/src/generate_embeddings.py"
click node_evaluation "https://github.com/kyanqueso/thesis_clean/blob/main/src/train_evaluate_visualize.py"
click node_orchestrator "https://github.com/kyanqueso/thesis_clean/blob/main/src/run_all_pipelines.py"
click node_progress "https://github.com/kyanqueso/thesis_clean/blob/main/src/progress.py"
click node_vast "https://github.com/kyanqueso/thesis_clean/blob/main/app/vast.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_datasets,node_anonymize,node_embeddings,node_evaluation,node_orchestrator,node_progress,node_browser toneBlue
class node_server,node_ui,node_detect,node_jobs,node_settings toneAmber
class node_runs_reader,node_paths,node_resolver,node_run_store toneMint
class node_openai,node_vast toneRose
class node_user toneIndigo
```

## Components

### Research pipeline

- [Dataset preparation](https://github.com/kyanqueso/thesis_clean/blob/main/src/organic_dataset.py): `src/organic_dataset.py`
- [Email anonymization](https://github.com/kyanqueso/thesis_clean/blob/main/src/anonymize_enron.py): `src/anonymize_enron.py`
- [Pair embeddings](https://github.com/kyanqueso/thesis_clean/blob/main/src/generate_embeddings.py): `src/generate_embeddings.py`
- [Train and evaluate](https://github.com/kyanqueso/thesis_clean/blob/main/src/train_evaluate_visualize.py): `src/train_evaluate_visualize.py`
- [Pipeline sweep](https://github.com/kyanqueso/thesis_clean/blob/main/src/run_all_pipelines.py): `src/run_all_pipelines.py`
- [Progress markers](https://github.com/kyanqueso/thesis_clean/blob/main/src/progress.py): `src/progress.py`

### Dashboard

- [Dashboard API](https://github.com/kyanqueso/thesis_clean/blob/main/app/server.py): `app/server.py`
- [Dashboard UI](https://github.com/kyanqueso/thesis_clean/blob/main/app/static/app.js): `app/static/app.js`
- [Live detection](https://github.com/kyanqueso/thesis_clean/blob/main/app/detect.py): `app/detect.py`
- [Run job queue](https://github.com/kyanqueso/thesis_clean/blob/main/app/jobs.py): `app/jobs.py`
- [Settings](https://github.com/kyanqueso/thesis_clean/blob/main/app/settings.py): `app/settings.py`

### Artifacts and paths

- [Run analysis](https://github.com/kyanqueso/thesis_clean/blob/main/app/runs.py): `app/runs.py`
- [Dashboard paths](https://github.com/kyanqueso/thesis_clean/blob/main/app/paths.py): `app/paths.py`
- [Tree resolver](https://github.com/kyanqueso/thesis_clean/blob/main/pipeline_paths.py): `pipeline_paths.py`
- **Run artifacts**

### External integrations

- **OpenAI API**
- [Vast.ai worker](https://github.com/kyanqueso/thesis_clean/blob/main/app/vast.py): `app/vast.py`

### Other components

- **Engineer**
- **Browser**

## Connections

- Engineer → Browser: uses dashboard (evidence: `README.md`)
- Browser → Dashboard API: requests API (evidence: `README.md`)
- Dashboard API → Run analysis: queries runs (evidence: `app/server.py`)
- Dashboard API → Live detection: requests detection (evidence: `app/server.py`)
- Dashboard API → Run job queue: manages jobs (evidence: `app/server.py`)
- Dashboard API → Settings: updates settings (evidence: `app/server.py`)
- Dashboard API → Vast.ai worker: tests connection (evidence: `app/server.py`)
- Run analysis → Dashboard paths: resolves artifacts (evidence: `app/runs.py`)
- Dashboard paths → Tree resolver: uses tree locations (evidence: `app/paths.py`)
- Run job queue → Pipeline sweep: launches sweep (evidence: `app/jobs.py`)
- Pipeline sweep → Pair embeddings: runs embedding stage (evidence: `src/run_all_pipelines.py`)
- Pipeline sweep → Train and evaluate: runs evaluation stage (evidence: `src/run_all_pipelines.py`)
- Pipeline sweep → Run artifacts: writes run outputs (evidence: `README.md`)
- Train and evaluate → Run artifacts: saves models and results (evidence: `README.md`)
- Run analysis → Run artifacts: reads run data (evidence: `app/runs.py`)
- Live detection → Run artifacts: loads saved classifiers (evidence: `app/detect.py`)
- Live detection → OpenAI API: embeds text (evidence: `app/detect.py`)
- Run job queue → Vast.ai worker: dispatches remote embedding (evidence: `app/jobs.py`)
- Pair embeddings → Progress markers: emits progress (evidence: `src/generate_embeddings.py`)
- Train and evaluate → Progress markers: emits progress (evidence: `src/train_evaluate_visualize.py`)
- Email anonymization → Dataset preparation: scrubs source text (evidence: `src/anonymize_enron.py`)
- Browser → Dashboard UI: loads interface
