discovery-desktop
Development skill for CaseMark's discovery-desktop application - a legal e-discovery platform for document upload, OCR processing, and semantic search. Built with Next.js 16, React 19, Drizzle ORM, and Case.dev APIs. Use this skill when: (1) Working on or extending the discovery-desktop codebase, (2) Integrating with Case.dev APIs for OCR, semantic search, or vault management, (3) Modifying the database schema or queries, (4) Building e-discovery workflow features, or (5) Deploying/configuring the application.
When & Why to Use This Skill
This Claude skill serves as a specialized development assistant for CaseMark's discovery-desktop, a legal e-discovery platform. It streamlines the development lifecycle by providing expert guidance on Next.js 16, React 19, and Drizzle ORM, while simplifying complex integrations with Case.dev APIs for OCR and semantic search. It effectively solves the technical challenges of building secure, high-performance legal document management systems.
Use Cases
- Accelerating codebase onboarding and feature extension for the discovery-desktop Next.js application.
- Integrating and debugging Case.dev APIs for automated document OCR processing and natural language semantic search.
- Managing and evolving SQLite database schemas and migrations using Drizzle ORM best practices.
- Developing secure e-discovery workflows, including password-protected vault management and document production tracking.
- Optimizing application deployment and environment configurations for legal tech software.
| name | discovery-desktop |
|---|---|
| description | | |
| when | (1) Working on or extending the discovery-desktop codebase, (2) Integrating |
Discovery Desktop Development Guide
A web application for e-discovery teams to manage case vaults, upload legal documents, perform OCR, and execute semantic searches.
Live site: https://discovery-desktop.casedev.app/
Architecture
src/
├── app/
│ ├── api/cases/ # Case CRUD operations
│ ├── cases/[caseId]/ # Case dashboard (upload, search, documents)
│ └── page.tsx # Home - case listing
├── components/
│ ├── ui/ # shadcn/ui primitives
│ ├── upload/ # Drag-drop upload, progress tracking
│ └── search/ # Search bar, results, export
└── lib/
├── db/ # Drizzle schema, client
├── casedev/ # Case.dev API wrapper
└── utils.ts # cn(), formatters
Core Workflow
Create Case → Upload Documents → OCR Processing → Semantic Search → Export
↓ ↓ ↓ ↓ ↓
Vault API Case.dev Upload Automatic via Natural CSV with
password- bulk Case.dev API language relevance
protected queries scores
Tech Stack
| Layer | Technology |
|---|---|
| Frontend | Next.js 16, React 19, Tailwind CSS |
| Backend | Next.js API Routes |
| Database | SQLite + Drizzle ORM |
| External APIs | Case.dev (Vaults, OCR, Search, LLMs) |
| Deployment | Orbit / Node.js compatible |
Case.dev API Integration
All document processing uses Case.dev APIs. See references/casedev-api.md for detailed patterns.
Authentication
// lib/casedev/client.ts pattern
const CASEDEV_API_KEY = process.env.CASEDEV_API_KEY;
headers: {
'Authorization': `Bearer ${CASEDEV_API_KEY}`,
'Content-Type': 'application/json'
}
Key Operations
| Operation | Purpose |
|---|---|
| Vault Management | Create password-protected storage per case |
| Document Upload | Send files (PDF, DOC, images) for OCR |
| OCR Status | Poll for processing completion |
| Semantic Search | Natural language queries with relevance scores |
Database Operations
SQLite with Drizzle ORM. See references/database-schema.md for complete schema.
Commands
npm run db:generate # Generate migrations from schema changes
npm run db:push # Push schema to database (dev)
npm run db:studio # Open Drizzle Studio GUI
Core Tables
- cases: id, name, description, passwordHash, vaultId, createdAt
- documents: id, caseId, filename, status, casedevDocId, ocrText
Development
Setup
npm install
cp .env.example .env.local
# Add CASEDEV_API_KEY to .env.local
npm run db:push
npm run dev
Environment
CASEDEV_API_KEY=sk_case_... # Required - get from app.case.dev
Build & Deploy
npm run build
npm start
Common Tasks
Adding a New API Route
// src/app/api/cases/[caseId]/newfeature/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { db } from '@/lib/db';
export async function POST(
request: NextRequest,
{ params }: { params: { caseId: string } }
) {
// Implementation
}
Extending Database Schema
- Modify
src/lib/db/schema.ts - Run
npm run db:generate - Run
npm run db:push
Adding Case.dev Integration
See references/casedev-api.md for endpoint patterns, error handling, and rate limits.
E-Discovery Context
See references/ediscovery-glossary.md for legal terminology.
Key concepts: Discovery, document production, privilege review, relevance scoring, ESI (electronically stored information).
Supported File Formats
| Type | Formats |
|---|---|
| Documents | PDF, DOC, DOCX, TXT |
| Images | JPG, JPEG, PNG, TIFF |
| Bulk | Hundreds of files per upload session |
Troubleshooting
| Issue | Solution |
|---|---|
| OCR stuck | Check Case.dev status, verify file format |
| No search results | Confirm OCR complete, check vault_id |
| Auth errors | Verify CASEDEV_API_KEY |
| Migration fails | Check schema syntax, use db:push for dev |