A Local Legal Research Application
Summary
The ASP.NET Core API and Blazor UI that search the sample, run the workflow, and expose a health check.
Companion code: 12-production in indian-legal-ai-lab.
Previous: Part 11: Evaluation, Security, and Reliability
The labs meet in two hosts: an ASP.NET Core API and a Blazor UI. Both call the same library. AWS is not required.
The API
`Program.Main` registers health checks, one `LegalResearchLibrary`, one `ResearchWorkflow`, a `SessionStore` under `data/sessions`, an `IngestionPipeline`, and OpenTelemetry ASP.NET Core instrumentation plus an `ActivitySource` named `LegalAiLab`. No exporter is configured, so traces stay in-process until you add one.
The routes are:
- `GET /health`
- `GET /` with the educational notice
- `GET /cases` with optional `q`, `court`, and `year`
- `GET /cases/{id}`
- `POST /research` with `{ "question": "..." }`, which saves a session and returns the report
- `GET /sessions/{id}` and `DELETE /sessions/{id}`
- `POST /ingest` for a case id already in the manifest
- `GET /citations/{id}`
`WebApplicationFactory<Program>` covers health, a Thappar search, and a research call that must contain `refused` for "Will I win my case?".
The UI
`LegalAiLab.Web` uses static Blazor rendering. Forms need `UseAntiforgery`, which is called before the components are mapped. Pages are home, search, case detail, research, ingestion status, and history. Search reads `q` and `court` from the query string and calls `SearchCases`. Research runs the workflow in `OnParametersSetAsync` and stores the state. History reloads that file.
dotnet run --project src/LegalAiLab.Api --urls http://127.0.0.1:5088
dotnet run --project src/LegalAiLab.Web --urls http://127.0.0.1:5089During the build recorded in `docs/evaluations/results.md`, `GET /health` returned `Healthy`, case search for Romesh Thappar returned `1950 INSC 14`, and `GET /search?q=Romesh%20Thappar` returned HTTP 200. Docker Compose was not run. The solution targets `net8.0`.
The UI check was an HTTP GET, not a browser session. pgvector and S3 remain optional. The product notice on the home page is the boundary: educational research over the sample, not advice and not a prediction.
Earlier RAG and MCP essays stay in the writing archive.
The Blazor research form uses `method="post"` and `SupplyParameterFromForm`. Opening `/research` does not run the workflow. The recorded HTTP check was the search page, not this form.
Verified in this revision
The API registers `FileIngestionQueue` under `data/ingestion` and `AddProblemDetails`. A blank research question or case id returns a validation problem. When `Api:Token` is set, POST and DELETE require `X-Api-Key`. Unset, the local tests stay open. That unset mode is local only. This revision was not deployed.
More in Applied AI
Evaluation, Security, and Reliability
Fixed checks for retrieval, unknown citations, hidden instructions in a judgment, and tools that are not allowed.
LLM Fundamentals in C#
A supplied judgment can be summarized only from passages you pass in. The same client, with no passage, names a citation that the catalog rejects.
Simple RAG over Indian Court Judgments
Chunk a versioned judgment manifest, embed it locally, and return the passage with its character offsets.