# Bankruptcy AI Service

## New Multi-Document Verification Endpoint

### POST `/api/v1/prompt/verify-documents`

Unified request body supporting multiple file URLs (images or PDFs) and dynamic data schema based on `file_type`.

#### Supported `file_type` values
- `bank_statement`
- `residence_documents`
- `billing_address_document`
- `vehicle_document`
- `business_documents` (NEW)

#### Request (Bank Statement Example)
```json
{
	"file_type": "bank_statement",
	"file_urls": [
		"https://example.com/storage/assets/stmt_may.pdf",
		"https://example.com/storage/assets/stmt_june.pdf"
	],
	"data": {
		"first_name": "MP",
		"middle_name": "",
		"last_name": "Convergent",
		"bank_name": "Bank of America",
		"account_type": "Saving",
		"balance": "10000.00"
	}
}
```

#### Request (Residence Document Example)
```json
{
	"file_type": "residence_documents",
	"file_urls": ["https://example.com/uploads/lease_pg1.jpg"],
	"data": {
		"first_name": "John",
		"middle_name": "",
		"last_name": "Doe",
		"city": "Dummy City",
		"state": "Toronto",
		"county": "Canada",
		"zip_code": "90001",
		"street_name": "Street 7",
		"house_number": "134"
	}
}
```

#### Request (Business Document Example)
```json
{
	"file_type": "business_documents",
	"file_urls": [
		"https://example.com/uploads/business_license.png"
	],
	"data": {
		"ein": "B2",
		"type": "Stock Broker",
		"location": "LK",
		"business_name": "Business2"
	}
}
```

#### Response (Bank Statement – abbreviated)
```json
{
	"success": true,
	"message": "Bank statement verification completed. Files processed: 2.",
	"bank_statement_results": [
		{
			"file_url": "https://example.com/storage/assets/stmt_may.pdf",
			"months_covered": ["2025-05"],
			"provided_final_balance": "10000.00",
			"statement_final_balance": "10000.00",
			"final_balance_matches": true,
			"name_matches": {"first_name": true, "middle_name": true, "last_name": true},
			"bank_name_matches": true,
			"account_type_matches": true,
			"errors": []
		}
	],
	"aggregated_months_covered": ["2025-05"],
	"aggregated_missing_months": ["2025-01","2025-02","2025-03","2025-04","2024-12"],
	"original_file_urls": ["https://example.com/storage/assets/stmt_may.pdf","https://example.com/storage/assets/stmt_june.pdf"],
	"timestamp": "2025-11-12T10:00:00"
}
```

### Notes
- PDFs are converted to images (first 2 pages) using PyMuPDF when present.
- Bank statements support multiple files; coverage and balances are aggregated.
- For address documents, each provided field is matched with confidence scoring and haze detection.

### Quick Run (PowerShell)
```powershell
uvicorn src.main:app --reload --host 0.0.0.0 --port 8000
```

