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."
- 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.
- 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)
- Framework: React (Vite) & Standalone Landing Dashboard (
docs/index.htmlwith Three.js WebGL Ferrofluid Orb) - Styling: Tailwind CSS & Vanilla CSS
- Interactive Timeline: Standalone D3/JS Interactive Timeline (
event-timeline.html)
The database is not accessible.
LEXI.dbis 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.
LEXI's chat interface is powered by a dynamic routing and persona framework tailored to forensic communication analysis.
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.
To optimize latency, cost, and depth of reasoning, queries are dynamically classified into three difficulty tiers:
- 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.
- Model:
- 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.
- Model:
- 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.
- Model:
- Python 3.10+ (Tested on 3.12)
- Node.js LTS (For frontend)
- Anthropic / OpenAI API Key (Required for LLM features)
- Navigate to the backend directory:
cd lexi-dashboard/backend - Create a virtual environment:
python -m venv venv # On Windows: .\venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Environment Variables:
Copy the example environment file and add your keys/database encryption password:
cp .env.example .env
- Start the server:
The API will be available at http://localhost:8000. Interactive documentation is at http://localhost:8000/docs.
python -m uvicorn main:app --reload --port 8000
- Navigate to the frontend directory:
cd lexi-dashboard/frontend - Install dependencies:
npm install
- Start the development server:
The React interface will be available at http://localhost:5173.
npm run dev
/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 databaseLEXI.db./docs: Technical specs, design plans, and system architecture.event-timeline.html: Interactive, client-side policy timeline visualization.
For a deep dive into the system's infrastructure, routing, and database schema, see the LEXI Production Architecture Spec.
Proprietary — All Rights Reserved. See LICENSE. No third-party licensed subtrees are vendored in this repository.
