Skip to page content

Product desk

LegalLens system

Ten intents, twelve APIs, eighteen services, ten operations, twelve security domains, one production diagram, eight incident phases, ten attorney-review stages, twelve threat categories, ten UX stages, ten audit layers, twelve business-logic domains, ten schema domains, fourteen API wiring rows, twelve event streams, twelve performance domains, ten recovery layers, twelve cost domains, ten deploy layers, twenty V–Z governance layers, four live desks. LegalLens picks the engine. Worksheets are not a filing. Not legal advice.

Routing matrix

System architecture

  1. 1. Data ingestion. Court, USCIS, DOS, and Federal Register crawls. Each page is hashed and timestamped.
  2. 2. NLP processing. Heading NLP segments sections and maps them to form fields on Diff the Law snapshots.
  3. 3. Change detection. Line and section diffs for instructions, regulations, and case-law pages.
  4. 4. Learning. Training JSON and extracted rules store on each change. News embeddings refresh from those summaries.
  5. 5. Knowledge. Frozen form catalog, jurisdiction profiles, and rule JSON. Catalog is never auto-written from a crawl.
  6. 6. RAG. Gemini 1024-d embeddings in Supabase pgvector. Chat and Like cases retrieve current records.
  7. 7. Reasoning. DeepSeek-R1, then Saul, then Vistral. Hard rule engine stays in front of the models.
  8. 8. Form filling. Instruction engine, skip logic, evidence rules, Argos display, finalization validator.
  9. 9. Risk flags. Criminal, immigration, relationship, and naturalization flags that stop auto-finalize.
  10. 10. Data reuse. Name, address, employment, travel, marriage, and immigration history from the signed-in record.
  11. 11. Multilingual. Argos plus standing rules. English instructions stay canonical for official answers.
  12. 12. Attorney review. Dashboard, audit trail, document hash, model version, and human approval before export.

Production architecture

Seven bands on the hosts that already run. Catalog stays frozen. Crawls do not retrain. User data is not training data.

  1. User clients

  2. API gateway

  3. Core desks

  4. Model layer

  5. Data and storage

  6. Security and compliance

  7. DevOps and deployment

User clients
  Attorneys • Paralegals • Clients     /profile
           |
API gateway
  Auth • Routing • Rate limit • Log    POST /api/system
           |
Core desks
  Auth                                 /profile
  Ingest • Version • NLP • Changes     /diff-the-law
  Rules • Schema • Forms • Risk        /form-filler
  Evidence • Reuse • Review            /form-filler
  RAG                                  /like-cases
  Reasoning                            /chat
  Translate                            Argos
  Scan                                 /document-scanner
           |
Model layer
  DeepSeek-R1 then Saul then Vistral   POST /api/chat
  Crawls do not retrain
           |
Storage
  Supabase Postgres + pgvector 1024-d
  Parse droplet extract-only
           |
Security
  Signed-in AI • BotID • TLS           GET /api/system/security
  Frozen catalog • no auto-file
           |
DevOps
  encoding + python-backend            GET /api/system/ops
  Vercel production legallens.news

System APIs

Twelve contracts on the desks that already run. Catalog stays frozen until a person reviews a Diff the Law change.

System services

Eighteen services on the same four desks. Each can be updated in place. Catalog stays frozen until a person reviews a Diff the Law change.

Operations

Ten operations on Vercel, GitHub Actions, and Supabase. Encoding and python-backend gate every merge. Catalog stays frozen. Crawls do not retrain models.

Security and compliance

Twelve controls on the hosts that already run. Chat is signed-in. User data is not training data. Catalog stays frozen. No auto-file.

Incident response

Eight phases on live controls. Classify on POST /api/system/incident. That call does not isolate hosts, rotate secrets, or file.

  1. 1. Detection and alerting

    GET /api/metrics

    BotID, AI tool 429s, Vercel runtime logs, and /api/metrics. Three failed logins is suspicious. Ten is brute force.

  2. 2. Classification

    POST /api/system/incident

    Level 4 is privileged-data breach, intrusion, or model poisoning. Level 3 is stolen credentials, exfiltration attempt, or rule/schema corruption. POST classifies. It does not isolate hosts.

  3. 3. Containment

    POST /api/form-assistant

    Form finalize already needs humanReviewed and no blocking flags. Catalog stays frozen. Rate limits wrap AI routes. This playbook does not rotate secrets by itself.

  4. 4. Forensic analysis

    POST /api/system

    Signed-in job log, Diff the Law SHA-256 snapshots, and Form Filler findings. Last-72-hour scope is the job log plus Vercel logs.

  5. 5. Eradication

    GET /api/form-instructions

    Frozen catalog plus evaluateFormCompliance. Crawls do not rewrite instructions. Models are not retrained from user worksheets.

  6. 6. Recovery

    GET /api/system/ops

    Supabase point-in-time recovery. Encoding and python-backend gate every return to production. npm run test:n400-i130 and test:form-compliance.

  7. 7. Notification and compliance

    POST /api/cron/digest

    Level 3: attorneys within 24 hours. Level 4: attorneys and clients within 12 hours. Digest and case-follows carry product alerts. This route does not send the notice.

  8. 8. Post-incident review

    GET /api/system/security

    Review within 72 hours on /system. Update Diff the Law watch, Form Filler human review, and the security map. Not a certification claim.

Attorney review

Ten stages on Form Filler, Document Scanner, and Argos. Three outcomes: approved, approved with conditions, rejected. POST /api/system/review classifies. It does not set humanReviewed, export, or file.

  1. 1. Intake and pre-review

    POST /api/form-assistant

    Form Filler collects answers, skip logic, and instruction flags. The attorney sees answers, flags, inconsistencies, evidence, translations, and form, rule, and model versions.

  2. 2. Identity verification

    POST /api/document-extract

    Document Scanner OCR and extract. Parse droplet stays PDF extract. Attorney compares names, dates, and documents.

  3. 3. Rule compliance

    GET /api/form-instructions

    Frozen instruction catalog plus jurisdiction profiles. Sources stay USCIS instructions, DOS FAM, INA, and CFR as published. Crawls do not rewrite the catalog.

  4. 4. Risk-flag review

    POST /api/form-assistant

    evaluateFormCompliance writes the flags. Attorney can clear, request more evidence, or mark critical. Arrests and CIMT block worksheet export until a person reviews.

  5. 5. Evidence review

    GET /api/form-instructions

    Form Filler checklist from frozen instructions: identity, immigration history, marriage, criminal records, travel, and employment.

  6. 6. Inconsistency detection

    POST /api/form-assistant

    Form Filler contradiction findings. Attorney corrects, requests clarification, or rejects. This route does not rewrite answers.

  7. 7. Multilingual verification

    POST /api/legal-translation

    Argos plus standing rules. Display can be Arabic. Official answers stay English. Critical check: criminal history, immigration violations, marriage history, eligibility rules.

  8. 8. Final rule-engine validation

    POST /api/form-assistant

    evaluateFormCompliance on Form Filler. A failed rule keeps canExportWorksheet false. This catalog does not export and does not file.

  9. 9. Attorney approval

    POST /api/system/review

    Three outcomes. POST classifies. It does not set humanReviewed. Live export stays on Form Filler after humanReviewed and no blocking flags.

  10. 10. Finalization and audit trail

    POST /api/system

    Signed-in job log plus Form Filler findings. isFinal stays false. Worksheets are not a filing. This route does not write the log by itself.

Threat model

Twelve attack surfaces on the hosts that already run. POST /api/system/threat classifies. It does not lock accounts, rotate secrets, crawl, retrain, isolate, or file.

User experience

Ten stages from welcome through filing guidance. POST /api/system/ux classifies. It does not create profiles, set humanReviewed, export, or file.

  1. 1. Welcome and intake

    GET /api/profile

    Home language plus signed-in profile. Form Filler loads after the category is known. This route does not create an account.

  2. 2. Smart form selection

    GET /api/form-instructions

    classifyLegalSystemIntent plus canonicalFormId. Latest USCIS or DOS text stays on Diff the Law. The worksheet catalog is frozen until a person reviews.

  3. 3. Guided interview

    POST /api/form-assistant

    Form Filler applies skip logic and instruction constraints. Answers stay structured JSON on the signed-in worksheet. This route does not write those answers.

  4. 4. Real-time validation

    POST /api/form-assistant

    evaluateFormCompliance on Form Filler. Like-cases can explain a stored record. Flags stay on the worksheet until a person reviews.

  5. 5. Evidence collection

    POST /api/document-extract

    Document Scanner OCR plus Form Filler checklist from frozen instructions. Parse stays PDF extract. This route does not classify fraud by itself.

  6. 6. Multilingual review

    POST /api/legal-translation

    Argos plus standing rules. Display can be Arabic, Somali, or Urdu. Official answers stay English. This route does not rewrite the worksheet language.

  7. 7. Risk summary

    POST /api/form-assistant

    Form Filler findings plus POST /api/system/review outcomes. CIMT and arrests stay red until a person reviews. This route does not escalate to an attorney inbox.

  8. 8. Attorney review portal

    POST /api/system/review

    The ten-stage attorney-review catalog. Three outcomes: approved, approved with conditions, rejected. POST classifies. It does not set humanReviewed.

  9. 9. Finalization and export

    POST /api/form-assistant

    Live export stays on Form Filler after ready_for_human, humanReviewed, and no blocking flags. isFinal stays false. This catalog does not export or file.

  10. 10. Filing guidance

    GET /api/form-instructions

    Frozen instruction catalog plus Diff the Law hashes of official pages. Crawls never rewrite fees or filing addresses. A person reviews before anyone files.

Audit trail

Ten layers on the job log, Diff the Law hashes, Form Filler findings, and attorney review. POST /api/system/audit classifies. It does not insert a job, seal a hash chain, export, or file.

  1. 1. Immutable log storage

    GET /api/diff-the-law

    Diff the Law stores SHA-256 snapshots of official pages. Signed-in job rows are inserts. This route does not seal a daily hash chain or delete a row.

  2. 2. Multi-channel logging

    GET /api/system

    Signed-in GET /api/system lists jobs. BotID and AI rate limits write security 429s. Vercel hosts the function logs. Parse and Argos stay on separate droplets. This route does not tail those hosts.

  3. 3. Legal event logging

    GET /api/diff-the-law

    Diff the Law change rows plus Form Filler findings plus POST /api/system/review outcomes. Crawls never rewrite the catalog. Events stay timestamped on those desks.

  4. 4. Version tracking

    GET /api/form-instructions

    Frozen form_instructions carry a version. Heading NLP stays heading-nlp-v1. Embeddings stay 1024-d. Attorney-review and UX catalogs publish SYSTEM_REVIEW_VERSION and SYSTEM_UX_VERSION. This route does not bump a version.

  5. 5. Chain of custody

    POST /api/document-extract

    Document Scanner extract plus signed-in worksheets. humanReviewed is the approval gate. This route does not record a viewer list.

  6. 6. Model traceability

    POST /api/like-cases

    Like-cases and story chat return the model id that answered. DeepSeek-R1, Saul, and Vistral stay named. User worksheets are not training data. This route does not write an inference row.

  7. 7. Rule-engine traceability

    POST /api/form-assistant

    evaluateFormCompliance findings name the rule and whether it blocks export. Official English instructions stay the source. This route does not insert a rule log.

  8. 8. Attorney-review audit trail

    POST /api/system/review

    POST /api/system/review classifies approved, approved with conditions, or rejected. It does not set humanReviewed. Live export stays on Form Filler after humanReviewed and no blocking flags.

  9. 9. Export and filing audit

    POST /api/form-assistant

    canExportWorksheet stays on Form Filler after ready_for_human, humanReviewed, and no blocking flags. isFinal stays false. This catalog does not export or file.

  10. 10. Compliance and retention

    GET /api/system/security

    trainsOnUserData stays false. Chat and forms are signed-in. Apply the signed-in job log SQL. This route does not set a retention clock or transmit worksheets off-host.

Business logic

Twelve domains from intent through audit. Schema mismatch never rewrites the catalog. POST /api/system/logic classifies. It does not write answers, set humanReviewed, export, or file.

User input
→ Intent
→ Form schema
→ Skip logic
→ Rule engine
→ Validation
→ Evidence
→ Multilingual
→ RAG
→ Reasoning
→ Risk flags
→ Attorney review
→ Audit
→ Worksheet (not a filing)
  1. 1. User intent

    POST /api/system

    classifyLegalSystemIntent plus the ten UX stages. Signed-in POST /api/system routes. This route does not write a job.

  2. 2. Form schema

    GET /api/form-instructions

    Mismatch writes a Diff the Law change row and outdated_source. form_instructions stay frozen until a person reviews. This route does not rewrite the catalog.

  3. 3. Skip logic

    POST /api/form-assistant

    Form Filler skip logic from frozen instructions. This route does not save an answer.

  4. 4. Rule engine

    POST /api/form-assistant

    evaluateFormCompliance. Blocking findings keep canExportWorksheet false until a person reviews.

  5. 5. Validation

    POST /api/form-assistant

    Form Filler findings. Marriage date before birth date is an inconsistency. This route does not rewrite answers.

  6. 6. Evidence

    POST /api/document-extract

    Form Filler checklist plus Document Scanner OCR. Parse stays PDF extract. This route does not classify fraud by itself.

  7. 7. Multilingual

    POST /api/legal-translation

    Argos plus standing rules. Display can be Arabic. Official answers stay English. This route does not rewrite the worksheet language.

  8. 8. RAG retrieval

    POST /api/like-cases

    Gemini 1024-d neighbours in Supabase pgvector. Story chat answers from the stored record. This route does not reindex.

  9. 9. Reasoning

    POST /api/chat

    Hard rules stay in front of the models. Chat is signed-in. This route does not invent a statute.

  10. 10. Risk flags

    POST /api/form-assistant

    CIMT, arrests, and blocking flags stay red until a person reviews. This route does not escalate to an attorney inbox.

  11. 11. Attorney review

    POST /api/system/review

    POST /api/system/review classifies. It does not set humanReviewed. Live export stays on Form Filler after humanReviewed and no blocking flags.

  12. 12. Audit

    POST /api/system/audit

    The ten audit layers. POST classifies. It does not insert a job, seal a hash chain, export, or file.

Database schema

Ten domains mapped onto Diff the Law, frozen form_instructions, article_embeddings, profiles, and Form Filler. POST /api/system/schema classifies. It does not create a table, migrate, reindex, export, or file.

  1. 1. Official documents

    documents, document_versions → law_tracked_pages, law_page_snapshots, law_page_changes

    Diff the Law stores SHA-256 hashes of USCIS, DOS, court, and Federal Register pages. Crawls never rewrite form_instructions. This route does not ingest a page.

  2. 2. NLP extraction

    extracted_sections, extracted_instructions, extracted_rules → law_page_snapshots, form_instructions

    Heading NLP stays heading-nlp-v1 on Diff the Law snapshots. Extracted rules stay in the frozen catalog until a person reviews. This route does not parse a document.

  3. 3. Form schemas

    forms, form_fields, form_skip_logic → form_instructions

    Frozen form_instructions plus the code catalog. Mismatch writes outdated_source. This route does not add a field or rewrite skip logic.

  4. 4. Rule engine

    rules, rule_versions → form_instructions

    evaluateFormCompliance on Form Filler. Rule versions live on Diff the Law change rows. This route does not insert a rule.

  5. 5. RAG vectors

    rag_chunks, rag_index_metadata → article_embeddings

    Gemini 1024-d neighbours in article_embeddings. User worksheets are not training data. This route does not reindex.

  6. 6. User answers and sessions

    user_sessions, user_answers → profiles

    Signed-in profiles plus Form Filler worksheets. Worksheets are not a filing. This route does not save an answer.

  7. 7. Evidence

    evidence_items, user_evidence → translation_orders

    Document Scanner OCR plus Form Filler checklist. Parse stays PDF extract. This route does not store a blob.

  8. 8. Risk flags

    risk_flags → form_instructions

    evaluateFormCompliance findings: CIMT, fraud, INA, marriage, naturalization. Blocking flags keep export closed until a person reviews. This route does not insert a flag row.

  9. 9. Attorney review

    attorney_reviews, attorney_actions → profiles

    POST /api/system/review classifies pending, approved, approved with conditions, or rejected. It does not set humanReviewed.

  10. 10. Audit and logging

    audit_log → law_page_changes

    Ten audit layers plus Diff the Law hashes plus the signed-in job log. Apply the job log SQL. This route does not insert a log row.

API wiring

Fourteen dump endpoints mapped onto live desks, business logic, and stores. POST /api/system/wiring classifies. It does not crawl, retrain, write answers, set humanReviewed, export, or file.

API Gateway
→ API Endpoint
→ Business Logic Layer
→ Live desks
→ Frozen catalog / RAG / DeepSeek-R1
→ Postgres + pgvector
→ Audit catalog
  1. 1. Auth → identity

    POST /auth/login → GET /api/profile

    Supabase Auth plus GET /api/profile. Attorney, paralegal, and client share the signed-in account. This route does not create a session.

  2. 2. Ingest → NLP + versioning

    POST /ingest/uscis → GET /api/diff-the-law

    Diff the Law hashes USCIS, DOS, court, and Federal Register pages. Heading NLP stays heading-nlp-v1. A change row waits for a person. Catalog is never auto-updated. Models are never retrained from a crawl. This route does not ingest a page.

  3. 3. Version → change detection

    POST /version/compare → GET /api/diff-the-law

    SHA-256 snapshots on law_page_snapshots. A new hash writes law_page_changes. This route does not compare a page.

  4. 4. NLP → extraction

    POST /nlp/extract-rules → GET /api/diff-the-law

    heading-nlp-v1 writes structured rules onto change_stats. Frozen form_instructions stay frozen until a person reviews. This route does not extract a rule.

  5. 5. Changes → update pipeline

    POST /changes/detect → GET /api/diff-the-law

    Mismatch writes a Diff the Law change row and outdated_source. form_instructions stay frozen. Models are never retrained from a crawl. This route does not rewrite the catalog.

  6. 6. Rules → evaluation

    POST /rules/validate → POST /api/form-assistant

    Form Filler compliance on the frozen catalog. Blocking findings keep export closed until a person reviews. This route does not insert a rule.

  7. 7. Form schema → form logic

    GET /forms/{form_id} → GET /api/form-instructions

    Frozen form_instructions plus the code catalog. This route does not add a field or rewrite skip logic.

  8. 8. RAG → retrieval

    POST /rag/query → POST /api/like-cases

    Gemini 1024-d neighbours in article_embeddings. User worksheets are not training data. This route does not reindex.

  9. 9. Reasoning → DeepSeek-R1 + rules

    POST /reasoning/answer → POST /api/system

    Hard rules stay in front of DeepSeek-R1, then Saul, then Vistral. Chat is signed-in. This route does not invent a statute.

  10. 10. Form fill → validation

    POST /forms/fill → POST /api/form-assistant

    POST /api/form-assistant. Export stays on Form Filler after ready_for_human, humanReviewed, and no blocking flags. This route does not save an answer, export, or file.

  11. 11. Translate → alignment

    POST /translate/form → POST /api/legal-translation

    Argos plus standing rules. Display can be Arabic. Official answers stay English. This route does not rewrite the worksheet language.

  12. 12. Risk → flags

    GET /risk/{session_id} → POST /api/form-assistant

    Form Filler findings: CIMT, fraud, INA, marriage, naturalization. Blocking flags keep export closed until a person reviews. This route does not insert a flag.

  13. 13. Attorney review → human-in-the-loop

    POST /review/approve → POST /api/system/review

    POST /api/system/review classifies pending, approved, approved with conditions, or rejected. It does not set humanReviewed. isFinal stays false.

  14. 14. Audit → trail

    GET /audit/{session_id} → POST /api/system/audit

    Ten audit layers plus Diff the Law hashes. This route does not insert a log row, export, or file.

Event streams

Twelve dump streams mapped onto Diff the Law hashes, frozen form_instructions, Form Filler findings, and attorney review. POST /api/system/events classifies. It does not emit a bus event, crawl, retrain, rewrite the catalog, export, or file.

Official page hash
→ DocumentIngested
→ heading-nlp-v1 + snapshot
→ ChangeDetected (person reviews)
→ Catalog stays frozen / modelRetrain stays false
→ User answers
→ Form Filler findings
→ Risk flags until a person reviews
→ Attorney review classifies
→ Worksheet (not a filing)
  1. 1. Document ingested

    DocumentIngested → GET /api/diff-the-law

    Diff the Law hashes USCIS, DOS, court, and Federal Register pages. Heading NLP stays heading-nlp-v1. This route does not ingest a page.

  2. 2. Document version created

    DocumentVersionCreated → GET /api/diff-the-law

    SHA-256 snapshots on law_page_snapshots. A new hash writes law_page_changes. This route does not write a snapshot.

  3. 3. Change detected

    ChangeDetected → GET /api/diff-the-law

    Mismatch writes a change row and outdated_source. form_instructions stay frozen until a person reviews. Models are never retrained from a crawl. This route does not rewrite the catalog.

  4. 4. Form schema updated

    FormSchemaUpdated → GET /api/form-instructions

    Frozen form_instructions plus the code catalog. Crawls never POST a schema update. This route does not add a field.

  5. 5. Rule updated

    RuleUpdated → POST /api/form-assistant

    Form Filler compliance on the frozen catalog. Human review writes rules. This route does not insert a rule.

  6. 6. Model retrain requested

    ModelRetrainRequested → GET /api/diff-the-law

    A change row waits for a person. Models are never retrained from a crawl. heading-nlp-v1 stays heading-nlp-v1. This route does not start training.

  7. 7. Model retrained

    ModelRetrained → GET /api/diff-the-law

    No model is promoted from a crawl. RAG stays Gemini 1024-d neighbours. This route does not swap a model.

  8. 8. Embeddings updated

    EmbeddingsUpdated → POST /api/like-cases

    Gemini 1024-d neighbours in article_embeddings. User worksheets are not training data. This route does not reindex.

  9. 9. User answer saved

    UserAnswerSaved → POST /api/form-assistant

    Form Filler findings. This route does not save an answer, export, or file.

  10. 10. Evidence uploaded

    EvidenceUploaded → POST /api/document-extract

    Document Scanner OCR. Parse stays PDF extract. This route does not classify fraud by itself.

  11. 11. Risk flag raised

    RiskFlagRaised → POST /api/form-assistant

    CIMT, fraud, INA, marriage, and naturalization findings. Blocking flags keep export closed until a person reviews. This route does not insert a flag.

  12. 12. Attorney review completed

    AttorneyReviewCompleted → POST /api/system/review

    POST /api/system/review classifies pending, approved, approved with conditions, or rejected. It does not set humanReviewed. isFinal stays false. There is no auto-file step.

Performance

Twelve dump domains mapped onto Vercel, Supabase, Upstash, and frozen form_instructions. POST /api/system/performance classifies. It does not retune indexes, autoscale, reindex, crawl, retrain, export, or file.

Caching → frozen catalog + Vercel
Batching → like-cases neighbours
Scaling → Vercel serverless
Rate limits → Upstash
Inference → DeepSeek-R1 then Saul then Vistral
RAG → 1024-d pgvector
Rules → Form Filler
Updates → Diff the Law hashes
Attorney review → classify only
Audit → catalog
Postgres → Supabase
Global → production aliases
  1. 1. API gateway

    POST /api/system · vercel

    Next.js on Vercel. BotID and Upstash rate limits run before model calls. This route does not change a rate limit.

  2. 2. Microservice caching

    GET /api/form-instructions · vercel

    Frozen form_instructions stay in the code catalog. Crawls never rewrite that catalog. This route does not add a cache host.

  3. 3. Database

    GET /api/diff-the-law · supabase

    Supabase Postgres plus pgvector. Diff the Law snapshots and article_embeddings already live there. This route does not migrate or retune an index.

  4. 4. RAG retrieval

    POST /api/like-cases · supabase

    Gemini 1024-d neighbours in article_embeddings. User worksheets are not training data. This route does not reindex.

  5. 5. Model inference

    POST /api/chat · vercel

    Hugging Face router on the Next.js host. heading-nlp-v1 stays heading-nlp-v1. This route does not start training or add a GPU node.

  6. 6. Rule engine

    POST /api/form-assistant · vercel

    Form Filler compliance on the frozen catalog. Blocking findings keep export closed until a person reviews. This route does not insert a rule.

  7. 7. Form filling

    POST /api/form-assistant · vercel

    Export stays on Form Filler after ready_for_human, humanReviewed, and no blocking flags. This route does not save an answer, export, or file.

  8. 8. Update pipeline

    GET /api/diff-the-law · vercel

    Diff the Law SHA-256 snapshots. Mismatch writes a change row. Catalog stays frozen. This route does not emit a bus event.

  9. 9. Attorney review

    POST /api/system/review · vercel

    POST /api/system/review classifies. It does not set humanReviewed. isFinal stays false.

  10. 10. Audit logging

    POST /api/system/audit · supabase

    Ten audit layers plus Diff the Law hashes. This route does not insert a log row, export, or file.

  11. 11. Scaling

    GET /api/cron/warm-desks · vercel

    Vercel scales with traffic. Warm-desks every ten minutes. No extra model GPU host on this product. This route does not change an autoscale rule.

  12. 12. Global resilience

    GET /api/system/ops · vercel

    legallens.news and www.legallens.news after production READY. Preview ships on every pull request. This route does not fail over a region.

Disaster recovery

Ten dump layers mapped onto Vercel aliases, Supabase point-in-time recovery, frozen form_instructions, and Diff the Law hashes. POST /api/system/recovery classifies. It does not fail over a region, promote a replica, reindex, crawl, retrain, export, or file.

Vercel production aliases
→ Supabase Postgres + point-in-time recovery
→ pgvector 1024-d
→ Document Scanner + parse extract
→ DeepSeek-R1 then Saul then Vistral
→ Frozen form_instructions
→ Diff the Law hashes
→ Vercel serverless
→ Incident playbook
→ Audit catalog (not a filing)
  1. 1. Production aliases

    Multi-Region Deployment → GET /api/system/ops

    Vercel production aliases after READY. Preview ships on every pull request. This route does not fail over a region.

  2. 2. Database continuity

    Database Replication → GET /api/diff-the-law

    Supabase holds Postgres. Point-in-time recovery is on that project. This route does not promote a replica or migrate a table.

  3. 3. RAG continuity

    Vector DB (RAG) Replication → POST /api/like-cases

    Gemini 1024-d neighbours in article_embeddings. This route does not reindex or sync a second vector store.

  4. 4. Evidence and documents

    Blob Storage Replication → POST /api/document-extract

    Parse stays PDF extract. Official USCIS and DOS pages live as Diff the Law hashes. This route does not copy a blob to a second region.

  5. 5. Model continuity

    ML/DL/NLP Model Registry Replication → POST /api/chat

    Hugging Face router on the Next.js host. Models are never retrained from a crawl. This route does not promote a model snapshot.

  6. 6. Rule and schema continuity

    Rule Engine & Form Schema Replication → GET /api/form-instructions

    form_instructions stay frozen until a person reviews. This route does not rewrite skip logic or insert a rule.

  7. 7. Update pipeline continuity

    Event-Driven Failover → GET /api/diff-the-law

    Diff the Law hashes keep official pages. This route does not emit a bus event or miss a hash because a region is down.

  8. 8. Compute continuity

    Kubernetes Failover → GET /api/cron/warm-desks

    Vercel scales with traffic. Warm-desks every ten minutes. This route does not reschedule a node or run a blue-green cutover.

  9. 9. Recovery runbook

    Disaster-Recovery Runbook → GET /api/system/incident

    Eight incident phases already on the System desk. This route does not freeze writes or promote a secondary region.

  10. 10. Audit preservation

    Audit-Trail Preservation → POST /api/system/audit

    Official page hashes plus the audit catalog. This route does not seal a hash chain, export, or file.

Cost

Twelve dump domains mapped onto Vercel serverless, Hugging Face chat, Supabase, Upstash, and frozen form_instructions. POST /api/system/cost classifies. It does not autoscale, reindex, crawl, retrain, export, or file.

Compute → Vercel serverless
Inference → DeepSeek-R1 then Saul then Vistral
RAG → 1024-d pgvector
Database → Supabase
Evidence → Document Scanner
Updates → Diff the Law hashes
Audit → catalog
Network → Upstash + BotID
DevOps → encoding + python-backend
Lifecycle → frozen catalog
Global → production aliases
  1. 1. Compute

    Compute Cost Optimization → GET /api/cron/warm-desks

    Next.js on Vercel. No extra GPU node on this product. This route does not add a node pool.

  2. 2. Microservice scaling

    Microservice Scaling Optimization → GET /api/cron/warm-desks

    Vercel scales with traffic. Warm-desks every ten minutes. This route does not change an autoscale rule.

  3. 3. Model inference

    ML/DL/NLP Inference Cost Optimization → POST /api/chat

    Cheaper Hugging Face models first. Haiku is last. This route does not start training or add a GPU node.

  4. 4. RAG

    RAG Cost Optimization → POST /api/like-cases

    Gemini 1024-d neighbours in article_embeddings. This route does not reindex or prune a second vector store.

  5. 5. Database

    Database Cost Optimization → GET /api/diff-the-law

    One Postgres project. This route does not partition a table, add a replica, or migrate.

  6. 6. Evidence storage

    Blob Storage Cost Optimization → POST /api/document-extract

    Parse stays PDF extract. Official pages stay hashes. This route does not move evidence to a cool tier.

  7. 7. Update pipeline

    Event-Driven Pipeline Cost Optimization → GET /api/diff-the-law

    Diff the Law hashes. This route does not emit a bus event or compact a topic.

  8. 8. Audit logging

    Audit Logging Cost Optimization → POST /api/system/audit

    Audit catalog plus official page hashes. This route does not insert a log row, archive, export, or file.

  9. 9. Network

    Network Cost Optimization → POST /api/system

    Vercel plus Upstash rate limits. This route does not peer a virtual network or add a CDN host.

  10. 10. DevOps

    DevOps Cost Optimization → GET /api/system/ops

    Merge gates stay encoding and python-backend. This route does not add a pipeline host.

  11. 11. Storage lifecycle

    Storage Lifecycle Optimization → GET /api/form-instructions

    form_instructions stay in code. This route does not archive a session or move evidence to a deep archive.

  12. 12. Global deployment

    Global Optimization → GET /api/system/ops

    Production aliases after READY. This route does not fail over a region or stand up active-passive ingestion.

Deployment automation

Ten dump layers mapped onto GitHub Actions, Vercel preview then production, Hugging Face chat, and frozen form_instructions. POST /api/system/deploy classifies. It does not apply a plan, sync a cluster, reindex, crawl, retrain, export, or file.

Infrastructure → Vercel + Supabase
Source of truth → GitHub
Packaging → Next.js routes
Release → preview then production READY
GitOps → encoding + python-backend
Regions → legallens.news aliases
Models → DeepSeek-R1 then Saul then Vistral
RAG → 1024-d pgvector
Recovery → catalog
  1. 1. Infrastructure

    Terraform Layer → GET /api/system/ops

    One product host. This route does not provision a cluster or add a node pool.

  2. 2. Source of truth

    Terraform State Management → GET /api/system/ops

    GitHub holds the tree. This route does not lock remote state or apply a plan.

  3. 3. Service packaging

    Helm Layer → GET /api/system/ops

    Desks stay Next.js routes. This route does not apply a chart.

  4. 4. Release strategy

    Helm Release Strategy → GET /api/system/ops

    Preview then production after READY. This route does not start a canary or a shadow model.

  5. 5. GitOps sync

    GitOps Deployment → GET /api/system/ops

    GitHub then Vercel. This route does not sync a cluster or enforce a desired cluster state.

  6. 6. GitOps workflow

    GitOps Workflow → GET /api/system/ops

    Merge gates stay encoding and python-backend. This route does not build an image or rewrite a values file.

  7. 7. Regions

    Multi-Region Deployment Automation → GET /api/system/ops

    Production aliases after READY. This route does not stand up a second region or a cold standby.

  8. 8. Model rollout

    ML/DL/NLP Model Deployment Automation → POST /api/chat

    Cheaper Hugging Face models first. This route does not package a model, run a canary, or promote a registry tag.

  9. 9. RAG index

    RAG Index Deployment Automation → POST /api/like-cases

    Gemini 1024-d neighbours in article_embeddings. This route does not generate embeddings, reindex, or archive an index.

  10. 10. Disaster recovery

    Disaster-Recovery Automation → GET /api/system/recovery

    Recovery catalog plus production aliases. This route does not fail over a region or rebuild a primary.

V–Z governance

Twenty dump layers from monitoring, security, compliance, reliability, and AI safety, mapped onto /api/metrics, Supabase Auth, BotID, frozen form_instructions, and attorney review. POST /api/system/governance classifies. It does not scrape, page, inject a fault, rotate a secret, reindex, crawl, retrain, export, or file.

V monitoring → GET /api/metrics
W security → GET /api/system/security
X compliance → POST /api/system/audit
Y reliability → GET /api/system/recovery
Z safety → POST /api/system/review
Chat → DeepSeek-R1 then Saul then Vistral
RAG → 1024-d pgvector
Rules → frozen form_instructions
NLP → heading-nlp-v1
Merge → encoding + python-backend
  1. V.1 Metrics

    Metrics → GET /api/metrics

    Prometheus text at /api/metrics. This route does not add a second metrics host or invent dump histogram names.

  2. V.2 Structured logs

    Logs → POST /api/system/audit

    Audit catalog plus Vercel logs. This route does not ship a log index or move logs to a cold tier.

  3. V.3 Traces

    Traces → GET /api/system/wiring

    Fourteen wiring rows are the live trace map. This route does not open a trace backend.

  4. V.4 Dashboards

    Dashboards → GET /api/metrics

    Grafana already scrapes /api/metrics. This route does not create a dashboard or annotate a deploy.

  5. V.5 Alerts

    Alerting → GET /api/system/incident

    Incident playbook is the live alert map. This route does not page an on-call or open a ticket.

  6. W.6 Zero-trust identity

    Zero-Trust Identity → POST /api/system

    Signed-in chat, BotID, and the shared AI rate limit. This route does not issue a mesh certificate.

  7. W.7 Secrets

    Secrets Management → GET /api/system/security

    Secrets live in Vercel and Supabase. This route does not rotate a secret or open a vault.

  8. W.8 Network isolation

    Network Isolation → POST /api/system

    Edge BotID plus HTTPS. This route does not segment a subnet or attach a private endpoint.

  9. W.9 RBAC

    RBAC/ABAC → GET /api/profile

    Supabase Auth and isAdminUser. This route does not grant evidence access or mint a new role.

  10. X.10 SOC2

    SOC2 → POST /api/system/audit

    Audit catalog plus merge gates. This route does not emit a SOC2 evidence pack.

  11. X.11 ISO 27001

    ISO 27001 → GET /api/system/security

    Security and threat catalogs are the live asset list. This route does not open a risk register.

  12. X.12 ABA ethics

    ABA & State Bar Ethics → POST /api/system/review

    Attorney-review stages stay on Form Filler. This route does not show evidence to a model trainer.

  13. X.13 GDPR/CCPA

    GDPR/CCPA → GET /api/system/audit

    This route classifies. It does not export a session or delete a row.

  14. Y.14 Resilience

    Resilience patterns → GET /api/system/recovery

    Chat fallback and recovery catalog. This route does not trip a circuit breaker.

  15. Y.15 Chaos

    Fault Injection → GET /api/system/incident

    Incident catalog classifies dump scenarios. This route does not kill a service or drop a message.

  16. Y.16 Load testing

    Load Testing → GET /api/system/performance

    Performance catalog plus warm-desks. This route does not run a k6 burst.

  17. Y.17 Auto-healing

    Auto-Healing → GET /api/system/recovery

    Vercel plus the recovery catalog. This route does not reschedule a pod or replace a node.

  18. Z.18 Alignment

    Alignment Guardrails → GET /api/form-instructions

    Official instructions stay canonical. This route does not score a hallucination or rewrite a rule.

  19. Z.19 Model lifecycle

    Model Lifecycle → POST /api/chat

    Cheaper Hugging Face models first. This route does not start shadow inference or pin a registry tag.

  20. Z.20 Safety filters

    Safety Filters → POST /api/system/review

    Attorney review is the live safety gate. This route does not auto-file or set humanReviewed.

Job log

Routed work will appear here after you sign in. Apply the system jobs SQL if the log stays empty.

LegalLens routes work across desks. Worksheets and drafts are not a filing and not legal advice.

Reading comfort

Hide sidebars and newsletter prompts while reading.