01. Product & System Overview¶
What the product does¶
DRT AI Platform processes tribunal case PDFs into OCR markdown, structured extraction (entities / attributes / relationships), and UC1 automated factsheets that prefill application fields with provenance.
It is a private monorepo (backend/ + frontend/ + infra/) aimed at Debt Recovery Tribunal document workflows, with additional use cases described in plans but not yet coded.
Primary users and workflows¶
| User (intended) | Workflow in this checkout |
|---|---|
| Registry / operator | Upload PDF → watch job stages → inspect OCR and extraction |
| Case worker | Select documents → generate factsheet → review fields + provenance |
| Admin / developer | Re-run OCR/extraction/merge stages; delete documents/factsheets |
There is no login or RBAC UI. Access control is effectively “whoever can reach the API.”
Use-case status¶
| ID | Name | Status |
|---|---|---|
| UC1 | Automated Fact Sheet | Implemented (uc1_factsheet/) |
| UC2 | Scrutiny Automation | Planned (plans/phase_5_uc2_scrutiny.md) |
| UC3 | AI Search (orders/judgments) | Planned (plans/phase_7_uc3_search.md) |
| UC4 / UC5 | Predictive analytics / STT | Out of scope for Phase 1 (PRD) |
Major subsystems¶
| Subsystem | Responsibility |
|---|---|
| FastAPI | Ingestion, job control, factsheet CRUD/status |
| Celery workers | Chunked OCR, extraction, merge, factsheet tasks |
| PostgreSQL | Documents, jobs, stages, chunks, artifacts, factsheets |
| MinIO | Raw PDF object storage |
| LiteLLM | VLM OCR, extraction LLM, factsheet LLM |
| OCR adapters | vlm, sarvam, layout (Paddle OCR service) |
| React console | Upload, jobs, documents, factsheets |
High-level architecture¶
graph TD
classDef default fill:#1e293b,stroke:#38bdf8,stroke-width:2px,color:#f8fafc
classDef highlight fill:#065f46,stroke:#34d399,stroke-width:2px,color:#f0fdf4
Upload["POST /documents"]:::highlight
Job["DocumentJob + stages/chunks"]
OCR["OCR stage"]
Ext["EXTRACTION stage"]
Merge["MERGE stage"]
Art["Artifacts JSON / MD"]
FS["POST /factsheet/generate"]:::highlight
P1["Phase1 discriminators"]
P2["Phase2 sub-models"]
P3["Phase3 assemble + provenance"]
Upload --> Job
Job --> OCR --> Ext --> Merge --> Art
Art --> FS --> P1 --> P2 --> P3
linkStyle default stroke:#64748b,stroke-width:2px
Shared document pipeline feeds UC1. Search/vector services are optional infra only.
Request-to-result: document processing¶
%%{init: {
"theme": "base",
"themeVariables": {
"primaryColor": "#1e293b",
"primaryTextColor": "#f8fafc",
"primaryBorderColor": "#38bdf8",
"lineColor": "#64748b",
"actorBackground": "#1e293b",
"actorBorder": "#38bdf8",
"actorTextColor": "#f8fafc",
"labelBoxBorderColor": "#38bdf8",
"labelBoxBkgColor": "#1e293b",
"labelTextColor": "#f8fafc",
"noteBorderColor": "#fbbf24",
"noteBkgColor": "#78350f",
"noteTextColor": "#fffbeb"
}
}}%%
sequenceDiagram
actor User
participant UI as React
participant API as FastAPI
participant S3 as MinIO
participant W as Celery
participant LLM as LiteLLM / OCR
User->>UI: Upload PDF
UI->>API: POST /api/v1/documents
API->>S3: Store object
API->>W: Enqueue process_document_task
API-->>UI: Document + job accepted
W->>LLM: OCR chunks
W->>LLM: Extract chunks
W->>W: Merge
UI->>API: Poll document/job status
API-->>UI: COMPLETED + artifacts
Request-to-result: factsheet¶
%%{init: {
"theme": "base",
"themeVariables": {
"primaryColor": "#1e293b",
"primaryTextColor": "#f8fafc",
"primaryBorderColor": "#38bdf8",
"lineColor": "#64748b",
"actorBackground": "#1e293b",
"actorBorder": "#38bdf8",
"actorTextColor": "#f8fafc",
"noteBorderColor": "#fbbf24",
"noteBkgColor": "#78350f",
"noteTextColor": "#fffbeb"
}
}}%%
sequenceDiagram
actor User
participant API as FastAPI
participant W as Celery
participant DB as Postgres
participant LLM as LiteLLM
User->>API: POST /factsheet/generate
API->>DB: Create Factsheet PENDING
API->>W: Enqueue factsheet task
API-->>User: 202 + job_id
W->>LLM: Phase1 discriminators
W->>LLM: Phase2 sub-model fields
W->>W: Phase3 assemble + provenance
W->>DB: Store result COMPLETED
User->>API: GET factsheet status / detail
Key technical bets¶
| Bet | Tradeoff |
|---|---|
| Stage/chunk job model in Postgres | More schema complexity; enables resume and partial failure |
| Pluggable OCR engines behind one pipeline | Uneven metadata richness across engines |
| Structured LLM extraction + factsheet phases | Prompt/schema maintenance; LLM cost/latency |
| Docs/plans ahead of search & auth | Onboarding clarity vs code/docs drift |
Interview answer: "What did you build?"¶
"A DRT document platform: upload PDFs, run a resumable OCR and structured-extraction pipeline on Celery, then generate multi-document factsheets with field-level provenance. UC1 is live; scrutiny and search are designed but not wired yet. The interesting part is treating jobs as stage/chunk state machines and driving factsheet fields from discriminators instead of one giant prompt."