# LegalFlow — Lean MVP PRD

> Generated: 2026-04-22
> Source: law-firm-evidence-deadline-workflow__scored-demand__20260422-1858.md
> Decision: BUILD (D1 + D2 + D4 integrated)

---

## 1. Problem & User

**Target User**: Paralegals and associate attorneys at small-to-mid litigation firms (5–50 attorneys) in the United States who manage multiple active cases simultaneously.

**Core Pain**: Missing a court filing deadline is the #1 cause of legal malpractice claims (ABA data). Meanwhile, evidence chain-of-custody tracking is done via manual logs and spreadsheets, risking case dismissal if custody gaps are discovered. Existing solutions are either too expensive (Clio at $79–$149/user/mo, Filevine at enterprise pricing) or too narrow (LawToolBox handles deadlines only, CaseFleet handles evidence only). No affordable tool integrates evidence custody + deadline calculation + cross-case conflict detection in one workflow.

## 2. Target Outcome & KPIs

**Primary Outcome**: A paralegal can log evidence custody events and have all related court deadlines auto-calculated and conflict-checked within a single session.

| KPI | Target (90-day) |
|-----|-----------------|
| Core workflow completion rate (evidence intake → deadline generated) | ≥ 80% |
| Deadline accuracy vs. manual calculation | 100% (zero miscalculations) |
| Cross-case conflict detection rate | ≥ 95% of same-day overlaps flagged |
| Trial-to-paid conversion | ≥ 8% |
| 7-day retention | ≥ 40% |

## 3. MVP Scope (In)

- **Case/Matter CRUD**: Create cases with jurisdiction, case type, and key dates
- **Evidence chain-of-custody logging**: Record who handled what evidence, when, with timestamped audit trail
- **Court deadline calculator**: Input trigger event (e.g., complaint served) → auto-calculate response/filing deadlines per FRCP + top 5 state rules (CA, NY, TX, FL, IL)
- **Calendar dashboard**: Unified view of all deadlines across all cases per attorney
- **Cross-case conflict detection**: Auto-flag when two deadlines/hearings overlap on the same day for the same attorney
- **Email deadline alerts**: Automated reminders at 7-day, 3-day, and 1-day before each deadline
- **Audit log**: Immutable record of all evidence custody changes and deadline modifications

## 4. Out of Scope

- Native mobile apps (web-responsive only for MVP)
- AI-powered rule interpretation (manual rule database for MVP)
- Document management / DMS integration
- Billing or time-tracking features
- Integration with e-filing systems (PACER, state portals)
- Client portal or client-facing features
- State rules beyond the initial 5 jurisdictions
- Multi-language support

## 5. User Flow (Happy Path)

1. **Login** → Paralegal signs in via email/password
2. **Create Case** → Enters case name, jurisdiction (e.g., "CA Superior Court"), case type ("Civil Litigation"), and parties
3. **Log Evidence** → Adds evidence item (description, type, physical/digital), records initial custody entry (received from client, logged by paralegal, timestamped)
4. **Set Trigger Event** → Selects trigger event ("Complaint Filed: 2026-04-15") for deadline calculation
5. **View Deadlines** → System auto-generates applicable deadlines (e.g., "Answer Due: 2026-05-15 (30 cal days per CCP §412.20)")
6. **Check Conflicts** → Dashboard highlights: "⚠️ May 15: Answer due in Smith v. Jones AND Motion hearing in Doe v. Roe"
7. **Transfer Evidence** → Logs custody transfer to outside expert; audit trail updated
8. **Receive Alert** → Email reminder 3 days before Answer deadline

## 6. Functional Requirements (P0)

| ID | Requirement |
|----|------------|
| FR-1 | System shall store cases with: name, jurisdiction, case_type, parties[], created_at, status |
| FR-2 | System shall record evidence items with: description, evidence_type (physical/digital), current_custodian, case_id |
| FR-3 | Each evidence custody event shall log: from_custodian, to_custodian, timestamp, notes, logged_by (immutable after creation) |
| FR-4 | Given a jurisdiction + case_type + trigger_event + trigger_date, system shall calculate all applicable deadlines using stored court rules |
| FR-5 | Deadline calculation shall handle: business days vs. calendar days, weekend/holiday adjustments, service method extensions |
| FR-6 | Calendar dashboard shall display all deadlines across all cases for the logged-in user, sortable by date |
| FR-7 | System shall flag same-day deadline conflicts for the same assigned attorney with a visual warning |
| FR-8 | System shall send email alerts at 7, 3, and 1 day(s) before each deadline |
| FR-9 | All evidence custody changes and deadline modifications shall be written to an append-only audit log |

## 7. Minimal Data Model

```
User { id, email, password_hash, name, role, firm_id }
Firm { id, name }
Case { id, firm_id, name, jurisdiction, case_type, status, created_at }
CaseAssignment { case_id, user_id, role }
Evidence { id, case_id, description, evidence_type, current_custodian, created_at }
CustodyEvent { id, evidence_id, from_custodian, to_custodian, timestamp, notes, logged_by }
CourtRule { id, jurisdiction, case_type, trigger_event, deadline_name, days_offset, day_type, service_extension_days }
Deadline { id, case_id, court_rule_id, trigger_date, due_date, assigned_to, status, alert_sent_7d, alert_sent_3d, alert_sent_1d }
AuditLog { id, entity_type, entity_id, action, actor_id, timestamp, diff_json }
```

## 8. API / Integration Notes

- **Stack**: Next.js 14 (App Router) + PostgreSQL + Prisma ORM
- **Auth**: NextAuth.js with email/password credentials provider
- **Email alerts**: Resend API (free tier supports 100 emails/day, sufficient for beta)
- **Hosting**: Vercel (frontend) + Supabase or Railway (PostgreSQL)
- **Court rules**: Seeded as JSON fixtures; no external API dependency for MVP
- **Key endpoints**:
  - `POST /api/cases` — create case
  - `POST /api/evidence` — log evidence item
  - `POST /api/custody-events` — record custody transfer
  - `POST /api/deadlines/calculate` — trigger deadline calculation for a case
  - `GET /api/deadlines?userId=X` — fetch all deadlines for calendar view
  - `GET /api/conflicts?userId=X` — check cross-case conflicts

## 9. Acceptance Criteria

- [ ] Creating a case with jurisdiction "CA Superior Court" and trigger event "Complaint Filed" generates ≥ 3 correct deadlines per CCP rules
- [ ] Evidence custody event is immutable: API returns 403 on PUT/DELETE to `/api/custody-events/:id`
- [ ] Calendar view shows deadlines from all cases assigned to the current user
- [ ] When two deadlines fall on the same date for the same attorney, a conflict warning badge appears
- [ ] Deadline falling on Saturday/Sunday is auto-adjusted to the next Monday
- [ ] Audit log entry is created for every evidence custody change and deadline status update
- [ ] Email alert is sent 3 days before a deadline (verifiable via Resend dashboard or test inbox)

## 10. Delivery Plan

### Milestone 1: Data Foundation + Case & Evidence CRUD (Day 1–3)
**Files**:
- `prisma/schema.prisma` — all models (User, Firm, Case, Evidence, CustodyEvent, CourtRule, Deadline, AuditLog)
- `prisma/seed.ts` — seed court rules for FRCP + CA + NY + TX + FL + IL
- `app/api/cases/route.ts` — POST/GET cases
- `app/api/evidence/route.ts` — POST/GET evidence items
- `app/api/custody-events/route.ts` — POST only (immutable); GET by evidence_id
- `lib/audit.ts` — audit log helper (append-only writes)

**Rationale**: Data model and core CRUD must exist before deadline calculation or UI can be built.

**Exit criteria**: `POST /api/cases` returns 201 with valid body; `POST /api/custody-events` returns 201 and subsequent PUT returns 403; `prisma db seed` populates ≥ 30 court rules across 6 jurisdictions.

### Milestone 2: Deadline Engine + Conflict Detection (Day 4–6)
**Files**:
- `lib/deadline-calculator.ts` — core calculation logic (business days, holidays, service extensions)
- `lib/holidays.ts` — US federal holidays + state court holidays for top 5 states
- `app/api/deadlines/calculate/route.ts` — POST: given case_id + trigger_event + trigger_date, generate all applicable deadlines
- `app/api/deadlines/route.ts` — GET deadlines by user
- `app/api/conflicts/route.ts` — GET same-day conflicts by user
- `__tests__/deadline-calculator.test.ts` — unit tests for day-type calculations, weekend adjustments, holiday handling

**Rationale**: The deadline engine is the core differentiator and most complex logic; it must be correct and well-tested before building UI on top.

**Exit criteria**: `POST /api/deadlines/calculate` for a CA civil case generates Answer deadline at exactly 30 calendar days; weekend deadlines shift to Monday; conflict endpoint returns flagged items when two deadlines share a date; all unit tests pass.

### Milestone 3: Dashboard UI + Email Alerts (Day 7–8)
**Files**:
- `app/(dashboard)/layout.tsx` — authenticated layout with sidebar nav
- `app/(dashboard)/cases/page.tsx` — case list + create form
- `app/(dashboard)/cases/[id]/page.tsx` — case detail: evidence list, custody log, deadline list
- `app/(dashboard)/calendar/page.tsx` — unified calendar view with conflict badges
- `components/ConflictBadge.tsx` — visual warning component
- `components/CustodyTimeline.tsx` — evidence custody chain visualization
- `lib/email-alerts.ts` — Resend integration for deadline reminders
- `app/api/cron/alerts/route.ts` — Vercel cron handler to check & send due alerts

**Rationale**: UI and alerts are the user-facing layer; building last ensures all APIs are stable.

**Exit criteria**: Calendar page renders deadlines from multiple cases; conflict badge appears on overlapping dates; creating a custody event updates the timeline in real-time; cron endpoint sends email for deadlines due in 3 days (verified via Resend logs).

## 11. Risks & Mitigations

| Risk | Impact | Mitigation |
|------|--------|------------|
| Court rule data inaccuracy | Malpractice liability for users | Seed only well-documented rules (FRCP, CCP); add disclaimer "verify with local rules"; plan for lawyer-reviewed rule updates |
| Scope creep into full practice management | Delayed MVP, lost focus | Strict Out of Scope enforcement; no billing, no DMS, no client portal in MVP |
| Low initial adoption (cold start) | Insufficient validation signal | Launch with free beta (3 months); target 2-3 law firm beta partners via legal tech communities |
| Email deliverability for alerts | Missed deadline notifications | Use Resend (high deliverability); add in-app notification fallback in M3 |

## 12. Chargeability Rationale

Missing a court deadline is the single most expensive mistake a litigation firm can make — it triggers malpractice claims averaging $30K–$150K. LegalFlow directly prevents this by automating deadline calculation and conflict detection, while also solving evidence custody compliance. At $29/user/mo (vs. $79–$149 for competitors), the tool pays for itself if it prevents even one missed deadline per year, making the ROI immediately obvious and the price trivially justifiable.
