How eethansmith/dissertation-project works
Project Type and Purpose
• Full-stack benchmarking tool: React-based frontend (“react-dashboard”) + Flask backend (“interactive-backend”).
• Purpose: allow users to upload CSV test scripts, select AI guardrails, run adversarial prompt tests asynchronously, and view interactive visualizations of detection rates/latency.
File Structure
• Top level:
• Dashboard_App/
– interactive-backend/ (Flask API + guardrail engine)
– react-dashboard/ (Vite + React UI)
• interactive-backend/app/: core modules (routes.py, processing.py, tasks.py, utils.py, config.py)
• interactive-backend/guards/: plug-in guardrail implementations (guardrails_ai.py, lakera_guard.py, presidio.py, etc.)
• interactive-backend/test-scripts/ & test-dataset/: CSV inputs & auto-generated results storage.
• react-dashboard/src/components: presentational components (Dashboard, Tables, Modals, VizBlocks).
• react-dashboard/src/services/api.js: API wrapper.
README for Additional Insights
• Backend uses concurrent.futures for asynchronous guard execution.
• Results persist to filesystem under test-dataset/<testID>/.
Main Components and Their Relationships
a. Frontend (React Dashboard)
• Components: Upload form, Guardrail Panel, Run Test button, Real-time charts (D3).
• Service layer calls REST endpoints on Flask backend.
b. Backend (Flask API Gateway)
• routes.py: defines endpoints (upload CSV, start test, fetch results).
• processing.py & tasks.py: orchestrate asynchronous execution.
• utils.py/config.py: config, env var handling.
c. Guard Execution Layer
• Each guard implementation in guards/*.py exposes preprocess() / postprocess().
• Orchestrated by concurrent.futures worker pool.
d. LLM Provider (external service)
• OpenRouter / OpenAI / HuggingFace, selected via LLM_PROVIDER env var.
e. Data Stores (local filesystem)
• test-scripts/: CSV inputs
• test-dataset/<testID>/: JSON/CSV outputs (pie_chart.csv, success_bar_chart.csv, etc.)
• test_list.csv: registry of test runs.
Architectural Patterns and Design Principles
• Plug-in architecture: drop new guard file → auto-discovered by backend.
• Asynchronous task execution: non-blocking guard + LLM calls.
• Separation of concerns: clear boundary between UI (React), API (Flask), guard modules, and data persistence.
• REST/JSON API layer for communication.
• File-based persistence simplifies traceability (no external DB).