22
33## Overview
44
5- Legal Case provides a REST API built with FastAPI. Interactive documentation available at ` /docs ` when running locally.
5+ JurisFind provides a REST API built with FastAPI. Interactive documentation available at ` /docs ` when running locally or in production .
66
77## Base URL
8+
9+ Local development:
810```
911http://localhost:8000/api
1012```
1113
14+ Production:
15+ ```
16+ http://20.186.113.106/api
17+ ```
18+
19+ Interactive Swagger UI (production): ` http://20.186.113.106/docs `
20+ Interactive Swagger UI (local): ` http://localhost:8000/docs `
21+
1222## Endpoints
1323
1424### Health Check
1525- ** GET** ` /health `
16- - ** Response** : ` {"status": "healthy"} `
26+ - ** Response** :
27+ ``` json
28+ {"status" : " healthy" , "message" : " Legal case search service is running" , "total_cases" : 46456 }
29+ ```
1730
1831### Search
1932- ** POST** ` /search `
2033- ** Body** :
34+ ``` json
35+ {"query" : " breach of contract" , "top_k" : 5 }
36+ ```
37+ - ** Response** :
2138 ``` json
2239 {
23- "query" : " contract terms" ,
24- "top_k" : 5
40+ "success" : true ,
41+ "query" : " breach of contract" ,
42+ "results" : [
43+ {"filename" : " case_001.pdf" , "score" : 0.94 , "similarity_percentage" : 94.3 }
44+ ],
45+ "total_results" : 5
2546 }
2647 ```
27- - ** Response** : Array of search results with scores and metadata
2848
29- ### Document Analysis
30- - ** POST** ` /analyze `
49+ ### Unified Document Analysis
50+ - ** POST** ` /unified/ analyze `
3151- ** Body** :
3252 ``` json
33- {
34- "filename" : " document.pdf" ,
35- "query" : " summarize key points"
36- }
53+ {"filename" : " case_001.pdf" , "source" : " database" }
3754 ```
38- - ** Response** : AI-generated analysis
55+ ` source ` is ` "database" ` for PDFs from the main index or ` "uploaded" ` for a confidential upload.
56+ - ** Response** : ` {success, filename, text_length, embedding_status, summary, message} `
3957
40- ### Chat
41- - ** POST** ` /chat `
58+ ### Unified Document Q&A
59+ - ** POST** ` /unified/ask `
4260- ** Body** :
4361 ``` json
44- {
45- "message" : " What are the main arguments?" ,
46- "context" : " document.pdf"
47- }
62+ {"filename" : " case_001.pdf" , "question" : " What was the ruling?" , "source" : " database" }
4863 ```
49- - ** Response** : Conversational response
64+ - ** Response** : ` {success, filename, question, answer} `
65+
66+ ### Serve PDF
67+ - ** GET** ` /pdf/{filename} `
68+ - ** Response** : PDF binary stream (` application/pdf ` ). Downloads from Azure Blob Storage, or falls back to local ` api/data/pdfs/ ` .
5069
5170### Document Statistics
5271- ** GET** ` /document-stats/{filename} `
53- - ** Response** : Document metadata and statistics
72+ - ** Response** : ` {success, filename, stats} ` with embedding metadata for the analyzed document.
73+
74+ ### Upload Confidential PDF
75+ - ** POST** ` /upload-confidential-pdf `
76+ - ** Body** : ` multipart/form-data ` with a ` file ` field containing the PDF
77+ - ** Response** : ` {success, filename, message} `
78+ - The file is saved to the ephemeral ` confidential_tmp ` Docker volume and never reaches Blob Storage.
79+
80+ ### Retrieve Similar Cases
81+ - ** POST** ` /retrieve-similar-cases?filename={name}&top_k=5 `
82+ - Finds cases in the main FAISS index semantically similar to the uploaded confidential PDF.
83+ - ** Response** : ` {success, filename, similar_cases, total_found} `
84+
85+ ### Cleanup Confidential Session
86+ - ** DELETE** ` /cleanup-confidential/{filename} `
87+ - ** Response** : ` {success, message} ` — deletes the uploaded PDF and its embeddings.
88+
89+ ### Legal Chatbot
90+ - ** POST** ` /legal-chat `
91+ - ** Body** :
92+ ``` json
93+ {"question" : " What constitutes fair use under copyright law?" }
94+ ```
95+ - ** Response** : ` {success, response, is_legal, domain_filtered} `
96+ - ` is_legal ` : ` false ` if the question was detected as non-legal and filtered.
97+
98+ ### Additional Utility Endpoints
99+ - ** GET** ` /list-pdfs ` — list all available PDFs in Blob or local storage
100+ - ** POST** ` /analyze-document?filename={name} ` — analyze a single database PDF (legacy route)
101+ - ** POST** ` /ask-question ` ` {filename, question} ` — Q&A on a database PDF (legacy route)
102+ - ** DELETE** ` /cleanup-embeddings/{filename} ` — remove cached embeddings for a document
103+ - ** DELETE** ` /legal-chat/clear ` — reset chatbot conversation history
104+ - ** GET** ` /legal-chat/stats ` — chatbot session statistics
105+ - ** POST** ` /upload-pdf-to-azure ` ` multipart/form-data ` — upload a PDF to Blob Storage directly
106+ - ** POST** ` /generate-embeddings-from-azure ` — rebuild FAISS index from Blob PDFs (admin operation)
54107
55108## Authentication
56109
@@ -73,8 +126,7 @@ Error responses include:
73126
74127## Rate Limiting
75128
76- - Default: 100 requests per minute per IP
77- - Configurable in environment variables
129+ Nginx enforces 30 requests per minute per IP by default. Requests exceeding this limit receive HTTP 429. The limit is configured in ` nginx.conf ` and can be adjusted on the VM.
78130
79131## CORS
80132
0 commit comments