Skip to content

dsmcewan/LEXI

Repository files navigation

LEXI: Evidence-Grounded Communication-Forensics Platform

Live Demo

LEXI Dashboard Overview

LEXI is a multi-agent forensic NLP platform for analyzing large, unstructured communication records — thousands of messages spanning years. It organizes what happened, surfaces recurring behavioral and linguistic patterns, and reconstructs a coherent, evidence-grounded account of events, while explicitly separating what the record shows from what remains uncertain.

"Here is what the record shows, how the pieces connect, and what remains uncertain."

Features

  • Interactive AI Chat Assistant: Conversational UI (LEXI) that serves as the primary interface for exploring the message corpus — every claim grounded in retrievable source messages.
  • Behavioral Pattern Recognition: Analyzes communication threads to identify escalation-prone exchanges, emotional coercion, and recurring interaction tactics.
  • Automated Timelines: Correlates dates across thousands of messages to build interactive chronological maps of critical events.
  • Dynamic Case Memory: Tracks behavioral profiles and known relationships, separating the underlying analysis logic from hardcoded assumptions.
  • Speech Integration (ElevenLabs): Built-in voice synthesis powered by ElevenLabs streaming APIs with real-time synchronization.
  • Source PDF Ingestion: Direct upload of communication exports with automated timestamp normalization to ISO-8601 for accurate causality ordering.

Tech Stack

Backend

  • Framework: FastAPI (Python)
  • Database: SQLCipher (Encrypted SQLite) with SQLModel (SQLAlchemy)
  • AI Processing: Anthropic Claude / OpenAI API (deep-dive semantic analysis, chat responses, and proactive commentary)

Frontend

  • Framework: React (Vite) & Standalone Landing Dashboard (docs/index.html with Three.js WebGL Ferrofluid Orb)
  • Styling: Tailwind CSS & Vanilla CSS
  • Interactive Timeline: Standalone D3/JS Interactive Timeline (event-timeline.html)

🔒 Database & Data Access

The database is not accessible. LEXI.db is encrypted at rest with SQLCipher (AES-256) and requires a private encryption key (DB_ENCRYPTION_KEY) that is not included in this repository. The live GitHub Pages demo at dsmcewan.github.io/LEXI runs entirely client-side with static mock data — it cannot connect to the backend API or read the database. Cloning this repo without the key will not grant access to any case data.

🧠 Interactive AI Chat: Adaptive Modes & Tiered Difficulty Model

LEXI's chat interface is powered by a dynamic routing and persona framework tailored to forensic communication analysis.

🎭 Adaptive Conversational Modes

LEXI operates as a strategic analyst persona and switches between response modes based on patterns detected in the material under analysis:

  • Baseline Mode: Collaborative and solution-focused for routine, non-conflict material.
  • Integration Mode: Triggered when passive-aggressive framing, gaslighting, or manipulation is detected in the corpus. Responses anchor exclusively to objective facts, discarding loaded framing.
  • Boundary Mode: Triggered by repeated violations or safety-relevant patterns. Direct and explicit, citing specific policy obligations and documenting breaches.

Mode selection is itself a detection output — the system's behavioral-pattern classifiers drive the interaction style, not manual configuration.

📊 Tiered Difficulty Model (Dynamic Routing)

To optimize latency, cost, and depth of reasoning, queries are dynamically classified into three difficulty tiers:

  1. Simple Tier (Greetings, short count lookups, yes/no queries):
    • Model: claude-sonnet-4 (Fast path)
    • Token Limit: 1,024 max tokens
    • Behavior: Direct response without tool overhead for sub-second latency.
  2. Medium Tier (Single-topic lookups, moderate detail queries):
    • Model: claude-sonnet-4
    • Token Limit: 4,096 max tokens
    • Behavior: Enabled with standard database and SQL queries to pull message records.
  3. Complex Tier (Deep-dive pattern analysis, timeline correlation, cross-referencing, multi-part strategic queries):
    • Model: claude-opus-4 (Deep reasoning)
    • Token Limit: 8,192 max tokens
    • Behavior: Runs an agentic tool loop (up to 10 iterations) capable of executing custom SQL, running Python analytical calculations, mapping behavioral trends, and assembling audit-ready event sequences.

🚀 Quick Start Guide

Prerequisites

  • Python 3.10+ (Tested on 3.12)
  • Node.js LTS (For frontend)
  • Anthropic / OpenAI API Key (Required for LLM features)

Backend Setup

  1. Navigate to the backend directory:
    cd lexi-dashboard/backend
  2. Create a virtual environment:
    python -m venv venv
    # On Windows:
    .\venv\Scripts\activate
    # On macOS/Linux:
    source venv/bin/activate
  3. Install dependencies:
    pip install -r requirements.txt
  4. Environment Variables: Copy the example environment file and add your keys/database encryption password:
    cp .env.example .env
  5. Start the server:
    python -m uvicorn main:app --reload --port 8000
    The API will be available at http://localhost:8000. Interactive documentation is at http://localhost:8000/docs.

Frontend Setup

  1. Navigate to the frontend directory:
    cd lexi-dashboard/frontend
  2. Install dependencies:
    npm install
  3. Start the development server:
    npm run dev
    The React interface will be available at http://localhost:5173.

Repository Structure

  • /lexi-dashboard/backend: Core API endpoints, campaign detection, chat, and case command center logic.
  • /lexi-dashboard/frontend: React application for the user interface.
  • /scripts: Python scripts for database migrations, analysis, and custom data processing.
  • /data: Encrypted SQLite database LEXI.db.
  • /docs: Technical specs, design plans, and system architecture.
  • event-timeline.html: Interactive, client-side policy timeline visualization.

Architecture

For a deep dive into the system's infrastructure, routing, and database schema, see the LEXI Production Architecture Spec.

License

Proprietary — All Rights Reserved. See LICENSE. No third-party licensed subtrees are vendored in this repository.

About

Multi-agent forensic NLP platform — four LLMs behind a complexity-routing pipeline, with bias validation held separate from generation and cross-model consensus checks. Live demo.

Topics

Resources

License

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors