Skip to content

omorros/ClaudeAI-Hackathon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ethics Research Assistant

Next.js React TypeScript Tailwind CSS Python FastAPI Anthropic Pydantic

AI-powered ethics approval pipeline for UK clinical neuroscience research

Built for the Claude AI Hackathon β€” Track 1: Biological and Physical Health.

  • Transforms a draft ethical review submission into REC-ready regulatory documents using a multi-agent AI architecture
  • Dramatically accelerates a process that traditionally requires 4-8 months of researcher time.
  • Cross-references 200+ pages of regulation and official Review Criteria.

Authors: Oriol Morros Vilaseca, Indigo Luksch, Marvel Manoharan, Akeel Msjeed

Sample Output PDFs

Sample Dashboard Screenshots

Proposal input Loading
Results 1 Results 2
Results 3 Results 4

The Problem

Clinical neuroscience researchers in the UK face significant barriers when seeking ethics approval:

  • 4-8 months timeline from study conception to NHS REC approval
  • 70% of initial submissions are returned for revisions, primarily due to formatting and administrative issues
  • 120-200 hours of regulatory paperwork per study, typically completed by PhD students

The Solution

ERA uses 5 specialized AI agents that work sequentially to produce a complete ethics application package:

  1. Intake Agent β€” Extracts a structured study profile from your description
  2. Regulatory Agent β€” Maps the study against 14 UK and international regulatory frameworks
  3. Consent Agent β€” Generates HRA-standard Consent Forms and Participant Information Sheets
  4. Ethics Agent β€” Creates IRAS-compliant Ethics Narratives and UKRI Data Management Plans
  5. QA Agent β€” Simulates an NHS REC review with quality scores and actionable improvement suggestions

Architecture

flowchart TB
    subgraph Frontend["Frontend Layer (Next.js 16 + React 19)"]
        UI["Study Intake Form"]
        HOOK["usePipeline Hook<br/>(SSE Stream)"]
        RESULTS["Results Dashboard"]
        HEALTH["Health Check"]
    end

    subgraph Backend["Backend Layer (FastAPI + Python)"]
        API_PIPELINE["POST /api/pipeline<br/>(SSE endpoint)"]
        API_HEALTH["GET /api/health"]
        ORCH["Orchestrator<br/>(Pipeline Coordinator)"]

        subgraph Agents["AI Agents (Claude Sonnet 4.6)"]
            A1["1️⃣ Intake Agent<br/>Profile Extraction"]
            A2["2️⃣ Regulatory Agent<br/>Compliance Mapping"]
            A3["3️⃣ Consent Agent<br/>PIS + Consent Forms"]
            A4["4️⃣ Ethics Agent<br/>IRAS Narrative + DMP"]
            A5["5️⃣ QA Agent<br/>REC Review Simulation"]
        end

        subgraph KB["Knowledge Bases (Static JSON)"]
            REG["πŸ—‚οΈ 14 UK/International<br/>Regulations"]
            PREC["πŸ“š 8 Precedent<br/>Studies"]
            REC["βœ… 4 REC Review<br/>Checklists"]
        end
    end

    UI -->|"Study description"| API_PIPELINE
    UI -.->|"Monitor backend"| API_HEALTH
    API_HEALTH -.->|"Status response"| HEALTH
    API_PIPELINE --> ORCH
    ORCH -->|"Real-time events"| HOOK
    HOOK --> RESULTS

    ORCH --> A1
    A1 -->|"StudyProfile JSON"| A2
    A2 -->|"RegulatoryMatrix"| A3
    A2 -->|"RegulatoryMatrix"| A4
    A3 -->|"Consent Package"| A5
    A4 -->|"Ethics Package"| A5

    A2 -.->|"Lookup tools"| REG
    A4 -.->|"Search tools"| PREC
    A5 -.->|"Checklist tools"| REC

    style Frontend fill:#1e293b,stroke:#3b82f6,stroke-width:3px,color:#e2e8f0
    style Backend fill:#1e293b,stroke:#10b981,stroke-width:3px,color:#e2e8f0
    style Agents fill:#0f172a,stroke:#8b5cf6,stroke-width:2px,color:#e2e8f0
    style KB fill:#0f172a,stroke:#f59e0b,stroke-width:2px,color:#e2e8f0
Loading

Agent Pipeline Flow

sequenceDiagram
    participant User
    participant Frontend
    participant API as FastAPI Backend
    participant Orch as Orchestrator
    participant A1 as Intake Agent
    participant A2 as Regulatory Agent
    participant A3 as Consent Agent
    participant A4 as Ethics Agent
    participant A5 as QA Agent
    participant KB as Knowledge Bases

    User->>Frontend: Enter study description
    Frontend->>API: POST /api/pipeline (SSE)
    API->>Orch: Start pipeline

    Note over Orch,A1: Stage 1: Profile Extraction
    Orch->>A1: Extract structured profile
    A1->>A1: Parse study details
    A1-->>Orch: StudyProfile JSON
    Orch-->>Frontend: SSE: stage="intake" status="complete"

    Note over Orch,A2: Stage 2: Regulatory Mapping
    Orch->>A2: Identify regulations
    loop For each regulation
        A2->>KB: lookup_regulation()
        KB-->>A2: Regulation details
    end
    A2-->>Orch: RegulatoryMatrix (14 reqs)
    Orch-->>Frontend: SSE: stage="regulatory" status="complete"

    Note over Orch,A5: Stage 3 & 4: Parallel Document Generation

    par Consent Package
        Orch->>A3: Generate consent docs
        loop Until readable
            A3->>A3: check_readability()
        end
        A3-->>Orch: Consent Form + PIS
        Orch-->>Frontend: SSE: stage="consent" status="complete"
    and Ethics Package
        Orch->>A4: Generate ethics docs
        A4->>KB: search_precedent()
        KB-->>A4: Similar studies
        A4-->>Orch: Ethics Narrative + DMP
        Orch-->>Frontend: SSE: stage="ethics" status="complete"
    end

    Note over Orch,A5: Stage 5: Quality Assurance
    Orch->>A5: REC review simulation
    A5->>KB: lookup_rec_checklist()
    A5->>A5: cross_reference_check()<br/>(Claude Haiku)
    A5->>A5: check_readability()
    A5-->>Orch: QA Report + Scores
    Orch-->>Frontend: SSE: stage="qa" status="complete"

    Frontend-->>User: Display complete results

    opt User cancels pipeline
        User->>Frontend: Click cancel
        Frontend->>API: Disconnect SSE
        API->>Orch: Set cancel_event
        Orch->>Orch: Stop execution
    end
Loading

Key Features

1. Comprehensive Regulatory Mapping

Automatically maps your study against 14 UK and international regulatory frameworks, including:

  • Health Research Authority (HRA) Approval
  • Integrated Research Application System (IRAS)
  • NHS Research Ethics Committee (REC)
  • Mental Capacity Act 2005
  • UK GDPR and Data Protection Act 2018
  • Caldicott Principles
  • Human Tissue Act 2004
  • And 7 additional relevant frameworks

Each regulation is assessed for applicability with detailed rationale and actionable requirements.

2. Automated Document Generation

Produces 4 publication-ready documents optimized for NHS REC submission:

Document Standard Contents
Participant Information Sheet HRA-standard Purpose, procedures, risks, benefits, data handling, complaints, contacts
Consent Form HRA-standard Tick-box consent items, optional sections for MCA/MRI/genetics
Ethics Narrative IRAS Section A Scientific justification, recruitment, consent process, risk assessment
Data Management Plan UKRI-compliant BIDS format, storage, security, anonymization, GDPR, archiving

3. REC Review Simulation

Simulates an authentic NHS Research Ethics Committee review using 4 real REC reviewer checklist variants:

  • Standard full review
  • Mental Capacity Act (MCA) flagged studies
  • Database studies
  • Tissue bank studies

The QA Agent produces:

  • 6 quantitative quality scores β€” Overall quality, readability, completeness, consistency, regulatory alignment, and rejection risk
  • Per-item checklist evaluation β€” Categorized as adequate, minor concerns, major concerns, or not addressed
  • Prioritized fix suggestions β€” Actionable recommendations with severity ratings (critical, major, minor, info) and specific document locations

4. Real-Time Progress Streaming with Cancellation

Server-Sent Events (SSE) technology delivers live pipeline updates with user control:

  • Live stage tracking β€” Watch each of the 5 agents progress in real-time
  • Execution timing β€” See how long each stage takes
  • Incremental result delivery β€” Results appear as soon as each agent completes
  • Cancel anytime β€” Stop long-running pipelines without waiting for completion (graceful shutdown with asyncio event coordination)

5. Demo Mode with Pre-loaded Scenarios

Experience the full pipeline instantly with pre-generated demo results:

  • Complete Alzheimer's fMRI study scenario
  • All 5 pipeline stages pre-executed
  • Immediate access to regulatory mapping and generated documents
  • Perfect for evaluating output quality before running your own study

Tech Stack

Component Technology Purpose
Frontend Next.js 16, React 19, TypeScript Modern React framework with Server Components and API routes
Styling Tailwind CSS 4 Utility-first CSS framework for rapid UI development
Backend Python 3.8+, FastAPI High-performance async API framework
Real-time SSE-Starlette Server-Sent Events for live progress streaming
AI Models Claude Sonnet 4.6 Primary agent reasoning and document generation
Claude Haiku 4.5 Fast cross-reference validation checks
Data Validation Pydantic Type-safe data models and request/response validation
Knowledge Bases Static JSON files 14 regulations, 8 precedent studies, 4 REC checklists
API Communication REST + SSE HTTP endpoints with event streaming for long-running tasks

Getting Started

Prerequisites

1. Clone the repository

git clone https://github.com/ClaudeAI-Hackathon.git
cd ClaudeAI-Hackathon

2. Set up environment variables

Create a .env.local file in the project root:

ANTHROPIC_API_KEY=sk-ant-your-key-here

3. Install & run the backend

# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate      # Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Start the FastAPI backend
cd backend
python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload

The backend will start on http://localhost:8000. The --reload flag enables auto-restart on code changes during development.

4. Install & run the frontend

# From project root
npm install
npm run dev

5. Access the application

Navigate to http://localhost:3000 in your browser.

Quick Start Options:

  • Click "Load Demo Scenario" to view pre-generated results from a complete Alzheimer's fMRI study
  • Enter your own study description and click "Start Pipeline" to generate a new ethics package

Health Check: You can verify the backend is running by visiting http://localhost:8000/api/health or checking the health status indicator in the UI.


Demo Scenario

Overview

The pre-loaded demo showcases a UCL fMRI study investigating working memory deficits in early-stage Alzheimer's disease, including optional APOE genotyping via blood draw. This scenario intentionally triggers maximum regulatory complexity to demonstrate ResearchFlow's comprehensive compliance mapping.

Study Characteristics

  • Population: 30 participants aged 55-80 with MCI or early Alzheimer's diagnosis
  • Setting: NHS Memory Clinic (UCLH) recruitment
  • Procedures: fMRI scanning (3 timepoints), neuropsychological assessment, optional blood sampling
  • Duration: 18 months longitudinal follow-up
  • Risk Level: High (vulnerable population with intrusive procedures)

Triggered Regulatory Requirements (14 Total)

Requirement Rationale
Mental Capacity Act 2005 Participants have cognitive impairment; capacity assessment required
NHS REC Review (MCA-flagged) High-risk study with vulnerable participants
HRA Approval NHS patients, data, and facilities involved
IRAS Submission Mandatory for all NHS research
UK GDPR / DPA 2018 Processing health data and special category genetic data
Human Tissue Act 2004 Blood samples stored for research purposes
Genetic Data Regulations APOE genotyping with result disclosure considerations
Caldicott Principles NHS patient confidentiality and data access
MRI Safety Requirements Neuroimaging with safety screening protocols
Incidental Findings Protocol Potential unexpected scan findings in at-risk population
UKRI/MRC Data Sharing Policy Funder requirement for open data deposition
ICH GCP Clinical research good practice standards
Declaration of Helsinki Ethical principles for medical research
Vulnerable Populations Protections Enhanced safeguards for cognitively impaired participants

Generated Documents

The demo includes complete outputs:

  • πŸ“„ Participant Information Sheet (5.1 grade reading level, 77.4 readability score)
  • βœ… Consent Form (6 sections, MCA capacity assessment, genetic testing options)
  • πŸ“‹ Ethics Narrative (12 sections covering IRAS requirements, 8 precedents referenced)
  • πŸ’Ύ Data Management Plan (BIDS-compliant, UKRI Gateway sharing)
  • ⚠️ QA Report (REC simulation with 42/100 overall score, 21 identified issues)

Pipeline Execution Time (Demo)

  • Stage 1 (Intake): 35.7 seconds
  • Stage 2 (Regulatory): 120.1 seconds
  • Stage 3 (Consent): 715.1 seconds (parallel)
  • Stage 4 (Ethics): 715.2 seconds (parallel)
  • Stage 5 (QA): 623.3 seconds
  • Total: ~37 minutes

Note: Demo mode loads these pre-generated results instantly.


Project Structure

neuro_ethics_hack/
β”œβ”€β”€ src/                                # Next.js frontend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ page.tsx                   # Home page with study intake form
β”‚   β”‚   β”œβ”€β”€ pipeline/page.tsx          # Pipeline execution and results page
β”‚   β”‚   β”œβ”€β”€ layout.tsx                 # Root layout with metadata
β”‚   β”‚   └── api/
β”‚   β”‚       β”œβ”€β”€ pipeline/route.ts      # Proxy to FastAPI backend
β”‚   β”‚       └── health/route.ts        # Backend health check endpoint
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ StudyIntakeForm.tsx        # Study description input
β”‚   β”‚   β”œβ”€β”€ PipelineProgress.tsx       # Real-time stage progress
β”‚   β”‚   β”œβ”€β”€ RegulatoryMap.tsx          # Regulation compliance grid
β”‚   β”‚   β”œβ”€β”€ DocumentViewer.tsx         # PIS, Consent, Ethics, DMP viewer
β”‚   β”‚   β”œβ”€β”€ QAReportPanel.tsx          # REC simulation results
β”‚   β”‚   β”œβ”€β”€ ScoreCard.tsx              # Quality score visualization
β”‚   β”‚   β”œβ”€β”€ ExportPanel.tsx            # Document export functionality
β”‚   β”‚   └── DemoScenarioButton.tsx     # Load pre-generated demo
β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   └── usePipeline.ts             # SSE streaming hook
β”‚   └── lib/
β”‚       β”œβ”€β”€ types.ts                   # TypeScript type definitions
β”‚       β”œβ”€β”€ pipeline-context.tsx       # React Context for pipeline state
β”‚       β”œβ”€β”€ demo-scenario.ts           # Demo study description
β”‚       └── demo-completed-state.ts    # Pre-generated demo results
β”‚
β”œβ”€β”€ backend/                            # Python FastAPI backend
β”‚   β”œβ”€β”€ main.py                        # FastAPI app + API routes
β”‚   β”œβ”€β”€ orchestrator.py                # Pipeline coordination + SSE streaming
β”‚   β”œβ”€β”€ agent_runner.py                # Claude tool-use loop executor
β”‚   β”œβ”€β”€ anthropic_client.py            # Anthropic API client wrapper
β”‚   β”œβ”€β”€ models.py                      # Pydantic data models
β”‚   β”œβ”€β”€ agents/                        # 5 specialized AI agents
β”‚   β”‚   β”œβ”€β”€ intake.py                  # Profile extraction agent
β”‚   β”‚   β”œβ”€β”€ regulatory.py              # Regulation mapping agent
β”‚   β”‚   β”œβ”€β”€ consent.py                 # Consent + PIS generation agent
β”‚   β”‚   β”œβ”€β”€ ethics_narrative.py        # Ethics + DMP generation agent
β”‚   β”‚   └── qa.py                      # REC review simulation agent
β”‚   β”œβ”€β”€ tools/                         # Agent tool implementations
β”‚   β”‚   β”œβ”€β”€ lookup_regulation.py       # Fetch regulation details
β”‚   β”‚   β”œβ”€β”€ search_precedent.py        # Search similar studies
β”‚   β”‚   β”œβ”€β”€ lookup_rec_checklist.py    # Fetch REC checklists
β”‚   β”‚   β”œβ”€β”€ check_readability.py       # Flesch-Kincaid scoring
β”‚   β”‚   └── cross_reference_check.py   # Document consistency validation
β”‚   └── knowledge/                     # Static knowledge bases (JSON)
β”‚       β”œβ”€β”€ regulations.py             # 14 UK/international regulations
β”‚       β”œβ”€β”€ precedents.py              # 8 precedent studies
β”‚       └── rec_checklists.py          # 4 REC review checklist variants
β”‚
β”œβ”€β”€ .env.local                         # Environment variables (API keys)
β”œβ”€β”€ requirements.txt                   # Python dependencies
β”œβ”€β”€ package.json                       # Node.js dependencies
└── tsconfig.json                      # TypeScript configuration

Design Decisions

Why Static JSON Instead of RAG?

Regulatory matching is fundamentally deterministic β€” study features map directly to specific applicable regulations. The knowledge base is compact (14 regulations, 8 precedents, 4 checklists) and highly structured. Static lookups provide:

  • Faster execution β€” No embedding generation or vector search latency
  • Perfect recall β€” Every regulation is checked systematically
  • Predictable behavior β€” No semantic similarity ambiguity
  • Easy auditing β€” Clear traceability of which regulations were applied and why

Why Parallel Agent Execution?

The Consent Agent (Stage 3) and Ethics Agent (Stage 4) both depend only on outputs from Intake and Regulatory agents, with no inter-dependencies. Running them in parallel using asyncio.gather reduces total pipeline time by approximately 40%.

Why Tool-Use Loops?

Each agent leverages Claude's native tool-use capability to interact with deterministic tools:

  • Regulation lookup β€” Fetch complete regulatory requirements
  • Precedent search β€” Find similar approved studies
  • Readability checks β€” Calculate Flesch-Kincaid scores
  • Checklist validation β€” Apply real REC reviewer criteria

Agents call a final submit tool to return structured JSON output. This architecture keeps agents grounded in verified knowledge bases rather than generating potentially inaccurate regulatory information.

Why Server-Sent Events (SSE)?

SSE provides unidirectional real-time streaming from server to client with automatic reconnection, perfect for long-running pipeline updates. Unlike WebSockets, SSE works over standard HTTP and integrates seamlessly with Next.js API routes.

Why Pre-generated Demo State?

Running the full pipeline takes 30-40 minutes due to Claude API calls for document generation. Pre-generated demo results allow instant evaluation of:

  • Output quality and formatting
  • Regulatory mapping comprehensiveness
  • REC simulation accuracy
  • UI/UX flow

Users can explore complete results immediately before committing to a full pipeline run.


Troubleshooting

Backend Connection Issues

Symptom: Frontend shows "Backend not reachable" or health check fails

Solutions:

  1. Verify the backend is running: curl http://localhost:8000/api/health
  2. Check if port 8000 is available: lsof -i :8000 (macOS/Linux) or netstat -ano | findstr :8000 (Windows)
  3. Ensure .env.local file exists with your ANTHROPIC_API_KEY
  4. Check backend logs for errors in the terminal where you ran uvicorn

Missing Dependencies

Symptom: Import errors or module not found

Solutions:

  • Backend: pip install -r requirements.txt (ensure virtual environment is activated)
  • Frontend: npm install from project root

API Key Issues

Symptom: "401 Unauthorized" or authentication errors

Solutions:

  1. Verify your Anthropic API key is valid at https://console.anthropic.com/
  2. Ensure .env.local contains: ANTHROPIC_API_KEY=sk-ant-your-key-here
  3. Restart the backend after updating .env.local

Long Pipeline Execution Times

Expected Behavior: A full pipeline run takes 30-40 minutes due to:

  • Claude API calls for document generation (~10-15 minutes per document agent)
  • Quality checks and readability iterations
  • Regulatory lookups and precedent searches

Recommendations:

  • Use the demo mode for instant results during development
  • The cancel button allows stopping execution at any point
  • Consider running pipeline in background and checking results later

API Reference

Backend Endpoints (FastAPI)

POST /api/pipeline

Initiates the ethics approval pipeline with real-time SSE streaming.

Request Body:

{
  "description": "string (your study description)"
}

Response: Server-Sent Events stream with the following event types:

  • stage_update β€” Stage started or completed with timing
  • result β€” Final pipeline results with all generated documents

Example SSE Events:

data: {"type": "stage_update", "stage": "intake", "status": "running"}
data: {"type": "stage_update", "stage": "intake", "status": "complete", "duration_ms": 35700}
data: {"type": "result", "profile": {...}, "regulatoryMatrix": {...}, ...}

GET /api/health

Health check endpoint to verify backend connectivity.

Response:

{
  "status": "ok",
  "service": "researchflow"
}

Frontend API Routes (Next.js)

POST /api/pipeline

Next.js proxy route that forwards requests to the FastAPI backend with CORS handling.

GET /api/health

Next.js proxy route that checks FastAPI backend health, returning:

  • 200 OK with backend status if reachable
  • 503 Service Unavailable if backend is down

License

This project was built for the Claude AI Hackathon.

About

Multi-agent Claude pipeline that generates NHS ethics approval documents from a study description. Maps 14 UK regulatory frameworks, produces 4 REC-ready documents, and simulates committee review.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors