๐Ÿ›ก๏ธ ConvoGuard AI

January 6, 2026 ยท View on GitHub

๐Ÿ›‘ ARCHITECTURAL ANCHOR

This project is part of the Berlin AI Automation Studio. It is governed by the global rules in berlin-ai-infra.

Setup for new laptops:

  1. Clone this repo.
  2. Run ./bootstrap-infra.sh to link to the global Master Brain.

Real-time API middleware that validates mental health chatbot conversations for EU AI Act/DiGA/GDPR compliance.

Built for CIC Berlin / Soonami Accelerator demo.

CI/CD

๐Ÿš€ Quick Start

npm install
npm run dev

Open http://localhost:3000 - Landing page with API demo Open http://localhost:3000/dashboard - Compliance dashboard

๐Ÿ“ก API Usage

Validate a Conversation

curl -X POST http://localhost:3000/api/validate \
  -H "Content-Type: application/json" \
  -d '{"transcript": "Assistant: I am an AI assistant. How are you feeling today?"}'

Response (compliant):

{
  "compliant": true,
  "score": 100,
  "risks": [],
  "audit_id": "abc-123-xyz",
  "execution_time_ms": 45
}

Crisis Detection

curl -X POST http://localhost:3000/api/validate \
  -H "Content-Type: application/json" \
  -d '{"transcript": "User: I want to kill myself"}'

Response (non-compliant):

{
  "compliant": false,
  "score": 50,
  "risks": [{
    "category": "SUICIDE_SELF_HARM",
    "severity": "HIGH",
    "message": "Detected potential suicidal/self-harm ideation"
  }],
  "audit_id": "def-456-uvw",
  "execution_time_ms": 38
}

Health Check

curl http://localhost:3000/api/health

Export Audit Logs (CSV)

curl "http://localhost:3000/api/audit-logs?format=csv" -o audit-logs.csv

๐Ÿ“‹ Compliance Rules

RuleTriggerWeightSeverity
๐Ÿšจ Suicide/Self-harmSuicidal ideation-50HIGH
๐ŸŽญ ManipulationExploitation, pressure-30MEDIUM
๐Ÿ†˜ Crisis EscalationMissing emergency resources-25HIGH
๐Ÿ“‹ GDPR ConsentMissing data consent-15MEDIUM
๐Ÿ“Š DiGA EvidenceNo clinical tracking-10LOW
๐Ÿค– TransparencyNo AI disclosure-10LOW

Score: 100 - sum(weights) โ†’ PASS (โ‰ฅ70) / FAIL (<70 or HIGH risk)

๐Ÿ—๏ธ Tech Stack

  • Next.js 16 + TypeScript
  • Vitest - Unit testing (90% coverage target)
  • Playwright - E2E testing
  • Supabase - Database & auth
  • Google Gemini - LLM risk analysis
  • Railway - Deployment

๐Ÿ“ Project Structure

src/
โ”œโ”€โ”€ app/                  # Next.js pages & API routes
โ”œโ”€โ”€ domain/               # Domain-driven central logic (entities, ports, services)
โ”œโ”€โ”€ lib/
โ”‚   โ””โ”€โ”€ compliance-engine/# Extracted Microservice: Policy evaluation & signal detection
โ””โ”€โ”€ infrastructure/       # Adapters (OpenAI, Supabase, etc.)

๐Ÿงช Testing

# Unit tests
npm run test:unit

# With coverage
npm run test:coverage

# E2E tests
npm run test:e2e

# All tests (CI)
npm run lint && npm run typecheck && npm run test:coverage && npm run test:e2e

โš™๏ธ Environment Variables

# Gemini API (optional - enables AI analysis)
GEMINI_API_KEY=your-gemini-api-key

# Supabase (optional - enables persistence)
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

๐Ÿš€ Deployment

  1. Push to main branch
  2. GitHub Actions runs tests
  3. Railway deploys automatically
# Manual deploy
railway up

๐Ÿ“š Documentation

๐Ÿ“œ License

MIT


Built with โค๏ธ for Berlin's mental health AI ecosystem