# alinawlo/master-thesis-code architecture

> Architecture diagram of the GitHub repository alinawlo/master-thesis-code, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alinawlo/master-thesis-code
- Repository: https://github.com/alinawlo/master-thesis-code

## Overview

ReformAgent is a policy-reform proposal discovery and document-processing application. Users explore proposal records or upload a policy document; the extraction interface processes it through an n8n workflow, presents results for duplicate review, and saves processed records. The repository also contains semantic deduplication, PDF page resolution, execution logging, and an analyst agent. Evidence is limited to the supplied excerpts and source index; several UI features and the analyst agent’s runtime wiring are not shown.

Main entry points: [`reformagent/vite.config.ts`](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/vite.config.ts) (Workflow middleware), [`reformagent/src/App.tsx`](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/App.tsx) (App shell), [`reformagent/src/components/Pipeline.tsx`](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/components/Pipeline.tsx) (Extraction pipeline), [`reformagent/src/server/ragDeduplication.ts`](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/server/ragDeduplication.ts) (Semantic matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Application interface"]
  node_app["App shell<br/>[App.tsx]"]
  node_explorer["Proposal explorer<br/>[ReformExplorer.tsx]"]
end

subgraph group_processing["Document processing"]
  node_pipeline["Extraction pipeline<br/>[Pipeline.tsx]"]
  node_workflow["n8n workflow"]
  node_server["Workflow middleware<br/>[vite.config.ts]"]
  node_pages["PDF page resolver<br/>[pdfPageResolver.ts]"]
end

subgraph group_data["Deduplication and records"]
  node_review["Duplicate review"]
  node_dedup["Semantic matching"]
  node_csv[("CSV records")]
end

subgraph group_support["Analysis and history"]
  node_logger["Execution logger<br/>[executionLogger.ts]"]
  node_history[("Execution history")]
  node_gemini["Gemini extraction<br/>[gemini.ts]"]
  node_analyst["Reform analyst<br/>[reform_analyst.py]"]
  node_taxonomy["Taxonomy clusters"]
end

node_user(("User"))
node_gemini_api{{"Google Gemini API"}}

node_user -->|"uses"| node_app
node_app -->|"renders"| node_explorer
node_app -->|"opens"| node_pipeline
node_pipeline -->|"uses"| node_review
node_pipeline -.->|"submits extraction"| node_server
node_server -->|"invokes"| node_workflow
node_server -->|"calls"| node_dedup
node_server -->|"resolves pages"| node_pages
node_server -->|"logs executions"| node_logger
node_dedup -->|"reads and writes"| node_csv
node_logger -->|"writes history"| node_history
node_gemini -->|"requests analysis"| node_gemini_api

click node_app "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/App.tsx"
click node_explorer "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/components/ReformExplorer.tsx"
click node_pipeline "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/components/Pipeline.tsx"
click node_review "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/components/DeduplicationReview.tsx"
click node_workflow "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/workflows/n8n_reformagent_workflow.json"
click node_server "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/vite.config.ts"
click node_dedup "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/server/ragDeduplication.ts"
click node_csv "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/server/ragDeduplication.ts"
click node_pages "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/server/pdfPageResolver.ts"
click node_logger "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/server/executionLogger.ts"
click node_history "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/workflows/execution_history.json"
click node_gemini "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/lib/gemini.ts"
click node_analyst "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/agents/reform_analyst.py"
click node_taxonomy "https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/taxonomy_clusters.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_app,node_explorer,node_user toneBlue
class node_pipeline,node_workflow,node_server,node_pages toneAmber
class node_review,node_dedup,node_csv,node_gemini_api toneMint
class node_logger,node_history,node_gemini,node_analyst,node_taxonomy toneRose
```

## Components

### Application interface

- [App shell](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/App.tsx): `reformagent/src/App.tsx`
- [Proposal explorer](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/components/ReformExplorer.tsx): `reformagent/src/components/ReformExplorer.tsx`

### Document processing

- [Extraction pipeline](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/components/Pipeline.tsx): `reformagent/src/components/Pipeline.tsx`
- [n8n workflow](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/workflows/n8n_reformagent_workflow.json): `reformagent/workflows/n8n_reformagent_workflow.json`
- [Workflow middleware](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/vite.config.ts): `reformagent/vite.config.ts`
- [PDF page resolver](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/server/pdfPageResolver.ts): `reformagent/src/server/pdfPageResolver.ts`

### Deduplication and records

- [Duplicate review](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/components/DeduplicationReview.tsx): `reformagent/src/components/DeduplicationReview.tsx`
- [Semantic matching](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/server/ragDeduplication.ts): `reformagent/src/server/ragDeduplication.ts`
- [CSV records](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/server/ragDeduplication.ts): `reformagent/src/server/ragDeduplication.ts`

### Analysis and history

- [Execution logger](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/server/executionLogger.ts): `reformagent/src/server/executionLogger.ts`
- [Execution history](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/workflows/execution_history.json): `reformagent/workflows/execution_history.json`
- [Gemini extraction](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/src/lib/gemini.ts): `reformagent/src/lib/gemini.ts`
- [Reform analyst](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/agents/reform_analyst.py): `reformagent/agents/reform_analyst.py`
- [Taxonomy clusters](https://github.com/alinawlo/master-thesis-code/blob/main/reformagent/taxonomy_clusters.json): `reformagent/taxonomy_clusters.json`

### Other components

- **User**
- **Google Gemini API**

## Connections

- User → App shell: uses (evidence: `reformagent/src/App.tsx`)
- App shell → Proposal explorer: renders (evidence: `reformagent/src/App.tsx`)
- App shell → Extraction pipeline: opens (evidence: `reformagent/src/App.tsx`)
- Extraction pipeline → Duplicate review: uses (evidence: `reformagent/src/components/Pipeline.tsx`)
- Extraction pipeline → Workflow middleware: submits extraction
- Workflow middleware → n8n workflow: invokes (evidence: `reformagent/vite.config.ts`)
- Workflow middleware → Semantic matching: calls (evidence: `reformagent/vite.config.ts`)
- Workflow middleware → PDF page resolver: resolves pages (evidence: `reformagent/vite.config.ts`)
- Workflow middleware → Execution logger: logs executions (evidence: `reformagent/vite.config.ts`)
- Semantic matching → CSV records: reads and writes (evidence: `reformagent/src/server/ragDeduplication.ts`)
- Execution logger → Execution history: writes history (evidence: `reformagent/src/server/executionLogger.ts`)
- Gemini extraction → Google Gemini API: requests analysis (evidence: `reformagent/src/lib/gemini.ts`)
