Skip to content

Commit 46addc9

Browse files
author
Sagar
committed
Doc fixes
1 parent 26ee2ed commit 46addc9

12 files changed

Lines changed: 2346 additions & 441 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,4 @@ confidential_uploads/
104104
private_cases/
105105
temp_analysis/
106106

107-
TECHNICAL_DOCUMENTATION.md
108107
jurisfind-backend_key.pem

README.md

Lines changed: 172 additions & 404 deletions
Large diffs are not rendered by default.

api/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def create_app():
3939
"http://localhost:5173", # Vite dev server
4040
"http://localhost:3000", # React dev server
4141
"http://20.186.113.106", # Azure VM public IP
42-
# Add your Azure Static Web App URL here after deploying:
43-
# "https://your-app.azurestaticapps.net",
42+
"https://blue-cliff-0dfeb910f.2.azurestaticapps.net", # Azure Static Web App
4443
],
4544
allow_credentials=True,
4645
allow_methods=["*"],

api/upload_to_blob.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""
2+
Run this once to upload FAISS index files to Azure Blob Storage.
3+
Usage: python upload_to_blob.py
4+
"""
5+
import os
6+
from azure.storage.blob import BlobServiceClient
7+
8+
# ── Paste your connection string here ──────────────────────────────────────────
9+
CONNECTION_STRING = "YOUR_CONNECTION_STRING_HERE"
10+
CONTAINER_NAME = "data"
11+
# ───────────────────────────────────────────────────────────────────────────────
12+
13+
FILES = {
14+
"faiss_store/legal_cases.index": r"e:\Sagar\AI_ML_DL_DS\projects\legal-case\JurisFind\api\data\faiss_store\legal_cases.index",
15+
"faiss_store/id2name.json": r"e:\Sagar\AI_ML_DL_DS\projects\legal-case\JurisFind\api\data\faiss_store\id2name.json",
16+
}
17+
18+
def upload():
19+
client = BlobServiceClient.from_connection_string(CONNECTION_STRING)
20+
container = client.get_container_client(CONTAINER_NAME)
21+
22+
# Create container if it doesn't exist
23+
try:
24+
container.create_container()
25+
print(f"Created container: {CONTAINER_NAME}")
26+
except Exception:
27+
print(f"Container '{CONTAINER_NAME}' already exists.")
28+
29+
for blob_name, local_path in FILES.items():
30+
size_mb = os.path.getsize(local_path) / (1024 * 1024)
31+
print(f"Uploading {blob_name} ({size_mb:.1f} MB)...")
32+
with open(local_path, "rb") as f:
33+
container.upload_blob(blob_name, f, overwrite=True)
34+
print(f" ✓ Done")
35+
36+
print("\nAll files uploaded successfully!")
37+
print(f"Blobs in container '{CONTAINER_NAME}':")
38+
for blob in container.list_blobs():
39+
print(f" - {blob.name}")
40+
41+
if __name__ == "__main__":
42+
if CONNECTION_STRING == "YOUR_CONNECTION_STRING_HERE":
43+
print("ERROR: Set your CONNECTION_STRING in this script first.")
44+
else:
45+
upload()

docs/api_reference.md

Lines changed: 74 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,108 @@
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
```
911
http://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

docs/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## System Overview
44

5-
Legal Case uses a microservices architecture with three main layers:
5+
JurisFind uses a microservices architecture with three main layers:
66

77
```
88
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐

0 commit comments

Comments
 (0)