Files
botsmann/docs/archive/LEX_PROJECT_OVERVIEW.md
g-butandClaude Opus 4.6 9bf4630fd2 chore: clean up stale docs, fix outdated dates and content
- Archive 10 stale/completed docs to docs/archive/ (MongoDB-era,
  migration plans, stale status snapshots, AGENTS.md.new)
- Rewrite SHARED_CONTEXT.md: remove MongoDB sections, update env vars
  table to Supabase, fix project structure to match reality, fix data
  flow diagrams
- Fix "January 2025" typo → "January 2026" across 6 doc files
- Update governance demo dates from 2023 to 2026
- Fix "launching 2025" → "launching 2026" in techno-capital
- Update bot roadmap timelines and expected launch dates
- Fix demo chat bot status from "coming soon" to "demo available"
- Add missing OPENROUTER_API_KEY to .env.example
- Fix stale path in RALPH.md (src/lib/schemas/ → lib/validations/)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 10:22:39 +01:00

16 KiB

ARCHIVED: This document contains outdated MongoDB-era instructions. Prefer docs/SUPABASE_SETUP.md and docs/SSOT.md.

Lex - AI Legal Assistant Platform

🎯 Project Vision

Lex is a next-generation AI-powered legal platform that democratizes access to justice through collaborative data rooms, intelligent case management, and hybrid AI-human legal assistance.

Core Mission

  • Democratize Legal Access: Make quality legal help accessible to everyone, regardless of budget
  • Human-in-the-Loop AI: Combine AI efficiency with human lawyer expertise
  • Full Transparency: Every interaction logged, auditable, and clear
  • Collaborative by Design: Multi-party data rooms with granular access control

🏗️ Architecture Overview

Technology Stack

  • Frontend: Next.js 14+ (React 18), TypeScript, Tailwind CSS
  • State Management: React Hooks (useState, useEffect, useRef)
  • UI Components: Custom components with mobile-first design
  • File Handling: Client-side processing with AI categorization
  • Real-time Features: Simulated WebSocket for demo (production: Socket.io or similar)

Project Structure

/app/bots/legal-expert/
├── page.tsx                          # Main page orchestrator
├── styles.css                        # Custom styles and animations
├── components/
│   ├── hero/HeroSection.tsx         # Landing hero
│   ├── demo/                         # Interactive demo (CORE)
│   │   ├── DemoSection.tsx          # 4-step wizard orchestrator
│   │   ├── DataRoomDemo.tsx         # Live chat + file interface
│   │   ├── JurisdictionSelector.tsx # Hierarchical jurisdiction picker
│   │   ├── FileUploader.tsx         # Drag-and-drop upload
│   │   ├── LawyerMatcher.tsx        # AI lawyer matching
│   │   ├── AIWorkspace.tsx          # File organization display
│   │   ├── jurisdictions.ts         # 100+ jurisdictions (US, EU, etc.)
│   │   ├── constants.ts             # Legal areas, mock data
│   │   ├── types.ts                 # TypeScript interfaces
│   │   └── README.md                # Component documentation
│   ├── features/FeaturesSection.tsx
│   ├── how-it-works/HowItWorksSection.tsx
│   ├── usecases/UseCasesSection.tsx
│   ├── testimonials/TestimonialsSection.tsx
│   ├── vision/VisionSection.tsx
│   ├── tech/TechSection.tsx
│   └── cta/CallToActionSection.tsx
└── BotNavigation.tsx                 # Page navigation

🔥 Core Features

1. Hierarchical Jurisdiction System

  • 130+ Jurisdictions with drill-down capability
  • US: All 50 states
  • EU: All 27 member countries
  • Switzerland: All 26 cantons (Zürich, Bern, Geneva, etc.)
  • UAE: Dubai, Abu Dhabi, Sharjah, etc.
  • Canada, Australia, UK, India, Singapore, Hong Kong and more
  • Smart search across all jurisdictions
  • Skip refinement option for broader selection
  • Breadcrumb navigation for easy back-tracking

2. Interactive Data Room (Flagship Feature)

The data room is the heart of Lex - a secure, collaborative workspace where:

Real-Time Chat

  • AI Assistant (Lex): 24/7 instant responses, document analysis, case research
  • Human Lawyer: Expert review, strategy, representation (human-in-the-loop)
  • No appointments needed: Chat anytime with AI, lawyer joins when needed
  • Typing indicators: See when others are typing
  • Message history: Full conversation log with timestamps
  • Smart responses: AI provides context-aware answers based on case details

File Management

  • Drag-and-drop upload: Easy file addition
  • AI Auto-categorization: Files organized into 8 categories
    • 📎 Evidence & Documentation
    • 📄 Contracts & Agreements
    • ✉️ Correspondence
    • ⚖️ Court Filings
    • 🪪 ID & Credentials
    • 💰 Financial Records
    • 🏥 Medical Records
    • 📁 Other Documents
  • AI Insights: Smart suggestions for each file category
  • File annotations: Comment on documents
  • Download/Share: Easy file management

Timeline & Activity Log

  • Every action tracked
  • Full audit trail
  • Transparency for all parties
  • Event timeline with icons and timestamps

Multi-Level Access Control

  • Attorney: Full access
  • Paralegal: Limited document access
  • Client: View and participate
  • Advisors/Family: Read-only or custom permissions
  • Expert Witnesses: Specific file access

3. AI-Powered Lawyer Matching

  • Smart filtering by legal area expertise
  • Rich profiles with:
    • Platform username (e.g., @ImmigrationPro_US)
    • Emoji avatar
    • Star rating (4.7-4.9)
    • Cases handled
    • Response time
    • Hourly rate
    • Languages spoken
    • Real-time availability (online/busy/offline)
  • Expertise tags: Up to 3 specialties shown
  • Instant selection: One tap to choose lawyer

Each marked with demand level (🔥 = high demand):

  • 🔥 Immigration Law: Visas, citizenship, asylum, deportation defense
  • 🔥 Family Law: Divorce, custody, adoption, domestic issues
  • 🔥 Criminal Defense: Criminal charges, DUI, white-collar crime
  • 🔥 Employment Law: Wrongful termination, discrimination, wages
  • 🔥 Personal Injury: Accidents, medical malpractice, compensation
  • Real Estate: Property disputes, landlord-tenant, transactions
  • Business & Corporate: Formation, contracts, compliance, M&A
  • Intellectual Property: Patents, trademarks, copyright
  • Estate Planning: Wills, trusts, probate, inheritance
  • Bankruptcy: Debt relief, Chapter 7/13, foreclosure
  • Tax Law: Tax disputes, IRS audits, tax planning
  • Civil Rights: Discrimination, police misconduct, constitutional

🎨 Design System

Mobile-First Principles

  1. Touch targets: Minimum 44x44px (Apple/Android standard)
  2. Responsive grids: 1 col (mobile) → 2-4 (desktop)
  3. Progressive disclosure: Show info when needed, hide complexity
  4. Active states: Visual feedback on tap (active:scale-95)
  5. Optimized typography: Scales from mobile to desktop

Color Palette

  • Primary: Blue-to-Cyan gradient (#3B82F6 → #06B6D4)
  • Success: Green (#10B981)
  • Warning: Yellow (#F59E0B)
  • Error: Red (#EF4444)
  • Neutral: Gray scale (#F3F4F6 → #111827)

Component Patterns

  • Cards: Rounded corners (xl), shadows, hover effects
  • Buttons: Gradients, active states, loading indicators
  • Forms: Large inputs, clear validation, real-time feedback
  • Chat: Message bubbles, typing indicators, avatars
  • Tabs: Underline active state, smooth transitions

📱 Mobile Optimization

Responsive Breakpoints

Mobile:   < 640px   (base, no prefix)
Tablet:   sm: 640px+
Desktop:  lg: 1024px+
Wide:     xl: 1280px+

Touch Interactions

  • Large, tappable buttons
  • Smooth scrolling
  • Swipe-friendly cards
  • Pull-to-refresh (future)
  • Haptic feedback (future)

Performance

  • Lazy loading for heavy components
  • Optimized re-renders (React.memo where needed)
  • Minimal bundle size
  • Fast interaction (<16ms for 60fps)

🔐 Security & Privacy

Data Protection

  • End-to-end encryption: All messages and files encrypted
  • Zero-knowledge architecture: Server can't read data
  • Local processing: AI categorization happens client-side (demo)
  • Secure storage: Encrypted at rest (production)

Access Control

  • Role-based permissions: Attorney, client, paralegal, advisor
  • Granular file access: Per-document permissions
  • Audit trail: Every action logged with timestamp
  • Session management: Auto-logout, secure tokens

Compliance

  • GDPR compliant: Data portability, right to erasure
  • HIPAA ready: For medical record handling
  • Attorney-client privilege: Protected communications
  • Multi-jurisdiction: Adapts to local privacy laws

🚀 User Flow

Step 1: Case Input (Progressive Disclosure)

  1. Jurisdiction: Search or drill-down (US → California → Los Angeles)
  2. Legal Area: Select from 12 categories (high-demand highlighted)
  3. Description: Rich textarea (min 20 chars, validation)
  4. Urgency: Low, Medium, High, Critical (visual indicators)
  5. Files (optional): Drag-and-drop upload

Step 2: Lawyer Matching

  1. AI filters lawyers by expertise
  2. Show matched lawyers (or top 3 if none)
  3. User selects lawyer (one tap)
  4. Case summary displayed

Step 3: AI Workspace

  1. Files auto-organized into categories
  2. AI provides insights per category
  3. Multi-level access control explained
  4. Transparent communication highlighted

Step 4: Data Room (NEW!)

  1. Welcome message: AI + lawyer intro
  2. Live chat: Real-time messaging
  3. File management: Browse, comment, download
  4. Timeline: Activity log
  5. No appointments: Chat anytime, lawyer joins as needed

🧠 AI Capabilities (Current Demo)

Document Analysis

  • Auto-categorization: Filename-based (production: NLP)
  • Key clause extraction: Contract analysis
  • Evidence cross-reference: Find supporting precedents
  • Timeline extraction: Dates and deadlines

Smart Responses

  • Context-aware answers based on:
    • Legal area
    • Jurisdiction
    • Case description
    • Uploaded files
  • Precedent matching
  • Statute references
  • Risk assessment

Future AI Features

  • OCR: Extract text from images
  • Handwriting recognition: Scan handwritten notes
  • Multi-language: Translate documents
  • Predictive analytics: Case outcome probability
  • Auto-drafting: Generate legal documents

👥 Team Collaboration

Role: Attorney

  • Full data room access
  • Can invite other attorneys
  • Set paralegal permissions
  • Manage client access

Role: Client

  • View all files (unless restricted)
  • Chat with AI and attorney
  • Upload new files
  • Invite advisors/family (with permissions)

Role: Paralegal

  • Limited file access (set by attorney)
  • Can't modify critical documents
  • Can add notes and comments

Role: Advisor/Family

  • Read-only access (default)
  • Can be granted specific permissions
  • View conversations (if allowed)

📊 KPIs & Metrics (Honest Tracking)

Current Metrics (Live on Page)

  • Waitlist Members: 0 (honest, updates in real-time)
  • Active Cases: 0
  • Data Rooms Created: 0
  • Expected Launch: Q2 2025

Success Metrics (Future)

  • User satisfaction score
  • Case resolution time
  • AI accuracy rate
  • Lawyer response time
  • Platform uptime
  • File processing speed

🔄 Progressive Disclosure Strategy

What We Hide Initially

  • Complex legal jargon
  • Advanced features
  • Technical details
  • All 130+ jurisdictions (show popular first)

What We Show Progressively

  1. Step 1: Basic case info
  2. Step 2: Lawyer matching (show summary, not full details)
  3. Step 3: Workspace overview (hide file details until click)
  4. Step 4: Data room (tabs hide content until selected)

Mobile Considerations

  • Collapsible sections
  • Expandable cards
  • Tab navigation (instead of showing all at once)
  • "Show more" buttons
  • Bottom sheets (future)

🛠️ Development Guidelines

Code Quality

  • TypeScript: 100% type coverage
  • DRY: No code duplication
  • Modular: Each component self-contained
  • Documented: JSDoc for complex functions
  • Tested: Unit tests for critical paths (future)

Naming Conventions

  • Components: PascalCase (e.g., DataRoomDemo.tsx)
  • Files: camelCase (e.g., jurisdictions.ts)
  • CSS: kebab-case (e.g., data-room-chat)
  • Variables: camelCase (e.g., selectedLawyer)

Git Workflow

  • main: Production-ready code
  • develop: Integration branch (future)
  • feature/: New features
  • fix/: Bug fixes
  • docs/: Documentation updates

📈 Roadmap

Phase 1: MVP (Current)

  • ✅ Hierarchical jurisdictions (130+)
  • ✅ 4-step demo wizard
  • ✅ Interactive data room with chat
  • ✅ AI + human lawyer simulation
  • ✅ Mobile-first responsive design
  • ✅ File upload and categorization

Phase 2: Backend Integration

  • Real lawyer API
  • WebSocket for live chat
  • Database (PostgreSQL/MongoDB)
  • Authentication (Auth0/Clerk)
  • File storage (S3/Azure Blob)
  • Payment processing (Stripe)

Phase 3: AI Enhancement

  • Real NLP for document analysis
  • OCR for image-to-text
  • Predictive case outcomes
  • Auto-drafting legal docs
  • Multi-language support

Phase 4: Platform Features

  • Video consultations
  • E-signatures (DocuSign)
  • Court filing integration
  • Blockchain audit trail
  • Mobile apps (React Native)

🚢 Deployment Strategy

Current: Botsmann Repository

  • Development and prototyping
  • Demo and testing
  • Client feedback

Next: Standalone Project

  1. Extract /app/bots/legal-expert/ to new repo
  2. Rename to lex-platform or similar
  3. Setup CI/CD pipeline (GitHub Actions)
  4. Deploy to Vercel/Netlify (staging)
  5. Custom domain: lex.legal or similar
  6. Production deployment after testing

Infrastructure (Production)

  • Frontend: Vercel Edge Network
  • Backend: AWS/GCP/Azure
  • Database: Managed PostgreSQL
  • File Storage: S3-compatible
  • CDN: CloudFlare
  • Monitoring: Sentry + DataDog

📚 Documentation

For New Engineers

  1. Read this file first - Get full context
  2. Review /demo/README.md - Component architecture
  3. Check MOBILE_FIRST_IMPROVEMENTS.md - UX/UI decisions
  4. See DEMO_IMPROVEMENTS.md - Feature evolution
  5. Run npm install && npm run dev - Start developing

Key Files to Understand

  • DemoSection.tsx: Main demo orchestrator (4-step wizard)
  • DataRoomDemo.tsx: Live chat and file interface
  • JurisdictionSelector.tsx: Hierarchical picker
  • jurisdictions.ts: All 130+ jurisdictions data
  • constants.ts: Legal areas and mock data

🎯 Success Criteria

Demo Must Show

✅ Hierarchical jurisdiction selection (intuitive, fast) ✅ AI lawyer matching (relevant, transparent) ✅ Intelligent file organization (automated, clear) ✅ Real-time chat (AI + human, seamless) ✅ Multi-level access (secure, granular) ✅ Mobile-first UX (responsive, fast) ✅ Progressive disclosure (simple → complex)

User Must Feel

  • Empowered: Easy access to legal help
  • Secure: Data is private and protected
  • Informed: Transparent pricing and process
  • Supported: AI + human always available
  • In control: Full visibility and access management

🤝 Contributing

For Team Members

  1. Create feature branch from main
  2. Follow code style (TypeScript, functional components)
  3. Add JSDoc for exported functions
  4. Test on mobile and desktop
  5. Create PR with clear description
  6. Request review from 1+ team members

For External Contributors

  1. Fork the repository
  2. Create feature branch
  3. Make changes
  4. Submit PR with detailed description
  5. Sign CLA (if required)

📞 Contact & Support

Development Team

  • Project Lead: [To be assigned]
  • Lead Engineer: [To be assigned]
  • Design Lead: [To be assigned]

Resources

  • GitHub Issues: Bug reports and feature requests
  • Slack: #lex-platform (internal)
  • Docs: [Future: docs.lex.legal]
  • API Docs: [Future: api.lex.legal/docs]

🎉 What Makes Lex Special

  1. Human-in-the-Loop AI: Not replacing lawyers, augmenting them
  2. Collaborative Data Rooms: Multi-party secure workspaces
  3. No Appointments: Chat with AI 24/7, lawyer joins when needed
  4. Full Transparency: Every action logged and visible
  5. Democratized Access: Quality legal help for everyone
  6. Mobile-First: Built for how people actually use phones
  7. Progressive Disclosure: Simple on surface, powerful underneath

This is not just a demo—it's the foundation of a revolution in legal services.


Last Updated: January 2025 Version: 1.0.0 Status: Active Development