How lawflow-boop/lawlink works
Purpose and runtime
LawLink is a self-hosted legal matter/project management system for small firms. It implements the operational path from intake and conflict checking through matter work, finance, archive, and export. It runs as a Next.js 16 App Router TypeScript application, backed by PostgreSQL 16 through Prisma and deployed locally or with Docker Compose. Core entry points are src/app/layout.tsx, authenticated application routing in src/app/(app)/layout.tsx, and container definitions in Dockerfile and docker-compose.yml.
Application boundary and access control
The UI is split into public authentication and authenticated application route groups. Credentials-based NextAuth sessions protect the app; server-side permissions are a separate authorization boundary. Relevant paths: src/app/(auth)/login/page.tsx, src/app/api/auth/[...nextauth]/route.ts, src/lib/auth/options.ts, src/lib/permissions/index.ts, and src/proxy.ts. Shared app navigation, notifications, search, and responsive shell are centralized in src/components/layout/app-shell.tsx and src/components/layout/nav-config.ts.
Persistence and core domain model
Prisma owns the relational schema and migration history, making PostgreSQL the system of record for users, firms, clients/contacts, intakes, matters, procedures/parties, documents, finance, approvals, reminders, notifications, and archival records. The schema and initial domain data live in prisma/schema.prisma, prisma/seed.ts, and prisma/migrations/. Application code accesses the database via src/lib/prisma.ts; server action modules form the domain-facing write/read layer rather than exposing generic CRUD APIs.
Intake-to-matter workflow
Intakes collect prospective work, support conflict review and cause recommendations, and can convert into formal matters. Matter lifecycle logic then coordinates the working record, team, parties, procedural information, notes, documents, tasks, reminders, and status transitions. Primary paths: src/app/(app)/intakes/[id]/page.tsx, src/server/intakes/actions.ts, src/server/matters/actions.ts, src/server/matters/lifecycle.ts, and src/app/(app)/matters/[id]/page.tsx. Conflict lookup is a dedicated domain algorithm at src/server/conflicts/algorithm.ts, surfaced by src/app/(app)/conflicts/page.tsx.
Matter operations, finance, and archive
The matter-detail screen is the principal workbench, composed as tabbed panels for procedural tracking, documents/folders, finance/invoices, approvals, preservation, and archive state. Financial records and invoice requests are handled separately from matter lifecycle operations. Closing/archival is guarded by checklist and review logic, then rendered/exported as an archive package. Paths: src/app/(app)/matters/[id]/_components/matter-detail-tabs.tsx, src/server/finance/actions.ts, src/server/invoices/actions.ts, src/server/archive/actions.ts, src/server/archive/guard.ts, and src/app/api/archive/[matterId]/export/route.ts.
Documents, storage, and AI/external integrations
Document and firm-file APIs enforce download/preview boundaries, while the storage abstraction supports local and S3-backed providers, validation, and encryption. Paths: src/server/documents/actions.ts, src/app/api/documents/[id]/download/route.ts, src/lib/storage/provider.ts, src/lib/storage/s3.ts, and src/lib/storage/crypto.ts. Optional AI workflows draft/review documents, parse pleadings/summons/express data, and recommend causes via configurable AI clients; YuanDian enterprise/case services are another external integration. Paths: src/server/ai/actions.ts, src/server/ai/review-document.ts, src/lib/ai/client.ts, and src/lib/yuandian/client.ts.
Scheduling, automation, reporting, and interchange
Schedule/tasks, reminders, notifications, dashboard metrics, reporting, imports, and XLSX exports are supporting operational flows over the same database. Scheduled jobs scan reminders, overdue archives, seal follow-ups, and audit cleanup; deployment must arrange execution of the scheduler/job layer. Paths: src/server/cron/scheduler.ts, src/server/cron/jobs/scan-due-reminders.ts, src/server/reports/analytics.ts, src/app/api/reports/export/route.ts, src/server/imports/actions.ts, and src/app/api/matters/export/route.ts.
Main entry points: prisma.ts Prisma data access · page.tsx Matter workbench · app-shell.tsx Authenticated app shell · actions.ts Intake and matter actions
Components 20
Application UI
Public and authenticated Next.js route groups.
- Next.js App Router · Root layout hosts the self-managed legal operations application.
src/app/layout.tsx - Authentication · Credentials login and NextAuth session endpoint.
src/app/(auth)/login/page.tsx - Authenticated app shell · Provides navigation, search, notifications, and responsive application layout.
src/components/layout/app-shell.tsx - Session and permissions · Separates NextAuth authentication from server-side authorization.
src/lib/auth/options.ts - Intake and conflict UI · Captures prospective work and surfaces conflict review.
src/app/(app)/intakes/[id]/page.tsx - Matter workbench · Tabbed operational view for lifecycle, procedure, documents, finance, approvals, and archive.
src/app/(app)/matters/[id]/page.tsx
Domain workflows
Server actions and workflow logic.
- Intake and matter actions · Domain-facing read/write layer that converts intakes and operates matters.
src/server/matters/actions.ts - Matter lifecycle · Coordinates status transitions and working-record operations.
src/server/matters/lifecycle.ts - Conflict engine · Finds conflicts and supports cause recommendations.
src/server/conflicts/algorithm.ts - Finance and invoices · Manages financial records and invoice requests independently of lifecycle actions.
src/server/finance/actions.ts - Archive workflow · Checks closure readiness and produces archival records.
- Archive export · Renders an archive package for a matter.
src/app/api/archive/[matterId]/export/route.ts - Document service · Manages matter documents and firm files.
src/server/documents/actions.ts - Scheduler and jobs · Runs reminder, archive, follow-up, and audit cleanup scans.
src/server/cron/scheduler.ts - Reports, imports, exports · Provides analytics, interchange, and XLSX exports.
src/server/reports/analytics.ts
Platform and integrations
Persistence, files, external services, and deployment.
- AI and YuanDian clients · Supports drafting, review, parsing, recommendations, and enterprise case services.
src/lib/ai/client.ts - File storage · Validates and encrypts local or S3-backed files.
src/lib/storage/provider.ts - Prisma data access · Application database access point for domain actions.
src/lib/prisma.ts - PostgreSQL system of record · Stores firms, people, intakes, matters, documents, finance, approvals, reminders, and archives.
prisma/schema.prisma - Local and Docker deployment · Runs the application and required local services.
docker-compose.yml
Connections 26
- Next.js App Router → Authentication: serves
- Next.js App Router → Authenticated app shell: hosts
- Authentication → Session and permissions: creates sessions via
- Authenticated app shell → Session and permissions: requires
- Authenticated app shell → Intake and conflict UI: navigates to
- Authenticated app shell → Matter workbench: navigates to
- Intake and conflict UI → Intake and matter actions: submits workflow actions
- Intake and conflict UI → Conflict engine: requests conflict review
- Matter workbench → Intake and matter actions: operates matters through
- Matter workbench → Finance and invoices: manages finance through
- Matter workbench → Document service: manages files through
- Matter workbench → Archive workflow: closes through
- Intake and matter actions → Matter lifecycle: applies
- Intake and matter actions → Prisma data access: reads and writes
- Conflict engine → Prisma data access: searches records
- Finance and invoices → Prisma data access: persists records
- Archive workflow → Prisma data access: checks and records
- Archive workflow → Archive export: enables
- Document service → File storage: stores files in
- Document service → Prisma data access: records metadata in
- Scheduler and jobs → Prisma data access: scans operational records
- Reports, imports, exports → Prisma data access: queries operational data
- AI and YuanDian clients → Document service: drafts and reviews documents
- Prisma data access → PostgreSQL system of record: connects to
- Local and Docker deployment → Next.js App Router: runs
- Local and Docker deployment → Scheduler and jobs: must execute