Skip to content
reaatech

Files · AI Discovery Doc Review for Small Litigation Firm

91 (1 binary, 704.5 kB total)attempt 1

README.md·3830 B·markdown
markdown
# AI Discovery Doc Review for Small Litigation Firm
 
> Make document review economic for small cases with automated summarization and privilege flagging.
 
A tutorialized reference solution from [reaatech.com](https://reaatech.com), demonstrating how to build production-grade AI systems with the `@reaatech/*` package family.
 
## Problem
 
Small litigation firms face disproportionate discovery review costs — associates spend hundreds of hours manually reading, summarizing, and flagging privileged content in document sets. This pipeline automates OCR, summarization, privilege analysis, cost tracking, and golden-comparison validation, cutting review time by 80% while maintaining defensible quality standards.
 
## Architecture
 
```
┌─────────────┐     ┌─────────────────────────────────────────────────────────┐
│  Document   │     │                  Pipeline Flow                          │
│   Upload    │     │                                                         │
│  (API POST) │────▶│  OCR ──▶ Summarize ──▶ Privilege Analysis ──▶ Cost      │
└─────────────┘     │                    Tracking ──▶ Goldens Comparison      │
                    │                              ──▶ Review Output           │
                    └─────────────────────────────────────────────────────────┘


                    ┌─────────────────────────┐
                    │   @ai-sdk/openai (GPT)  │
                    │   @upstash/vector (DB)  │
                    └─────────────────────────┘
```
 
## Getting Started
 
```bash
pnpm install
cp .env.example .env    # fill in OPENAI_API_KEY, UPSTASH_VECTOR_REST_URL, UPSTASH_VECTOR_REST_TOKEN
pnpm dev                # next dev — open http://localhost:3000
```
 
## Packages Used
 
### REAA Packages
| Package | Version |
|---------|---------|
| `@reaatech/media-pipeline-mcp-doc-extraction` | `0.3.0` |
| `@reaatech/rag-eval-core` | `0.1.0` |
| `@reaatech/agent-eval-harness-golden` | `0.1.0` |
| `@reaatech/llm-cost-telemetry` | `0.2.0` |
| `@reaatech/mcp-server-tools` | `1.0.1` |
 
### Third-Party Packages
| Package | Version |
|---------|---------|
| `ai` | `6.0.207` |
| `zod` | `4.4.3` |
| `@ai-sdk/openai` | `3.0.72` |
| `@upstash/vector` | `1.2.3` |
 
## API Routes
 
| Method | Path | Description | Request | Response |
|--------|------|-------------|---------|----------|
| POST | `/api/documents` | Create document | `{ artifactId, caseRef? }` | `201 { id, status }` |
| GET | `/api/documents` | List documents | `?status=` | `200 [{ id, status, ... }]` |
| GET | `/api/documents/:id` | Get document | — | `200 { id, ... }` or `404` |
| POST | `/api/documents/:id/process` | Process document through pipeline | — | `200 { summary, privilegeFlags, cost }` |
| GET | `/api/review` | List reviews | `?status=,?caseRef=` | `200 [{ ... }]` |
| GET | `/api/review/:id` | Get review | — | `200 { ... }` or `404` |
| GET | `/api/health` | Health check | — | `200 { status, uptime, version }` |
 
## Testing
 
```bash
pnpm test    # vitest run with coverage (thresholds: lines, branches, functions, statements ≥ 90%)
```
 
Tests use MSW (Mock Service Worker) for HTTP-level mocking of OpenAI and Upstash endpoints. Test files mirror the `src/` structure inside `tests/`.
 
## License
 
MIT — see [LICENSE](./LICENSE).