A warranty claim analysis system with a hybrid rule-based + ML engine for evaluating automotive warranty claims.
TRACE uses FastAPI for the backend with scikit-learn ML models and OpenRouter LLM integration for intelligent claim analysis. The frontend is a vanilla HTML interface served via nginx.
- Docker: Install Docker
- Docker Compose: Install Docker Compose
- Python 3.11+ (for local development without Docker)
- OpenRouter API Key (see below)
- Install sudo apt install tesseract-ocr # (on EC2/Ubuntu) , brew install tesseract
- Visit OpenRouter
- Create a free account or sign in
- Navigate to API Keys in your dashboard
- Create a new API key
- Copy the key (you won't be able to see it again)
git clone <repository-url>
cd capProj-2Create a .env file in the backend directory:
cp backend/.env.example backend/.envEdit backend/.env and add your OpenRouter API key:
OPENROUTER_API_KEY=your-api-key-here
LOG_LEVEL=INFONote: The
.envfile is gitignored and should never be committed to version control.
docker-compose up --buildThis will start:
- Backend: http://localhost:8000
- Frontend: http://localhost:3000
docker-compose up backenddocker-compose logs -fdocker-compose downcd backend
python -m venv venvLinux/macOS:
source venv/bin/activateWindows:
venv\Scripts\activatepip install -r requirements.txtLinux/macOS:
export OPENROUTER_API_KEY=your-api-key-here
export LOG_LEVEL=INFOWindows (CMD):
set OPENROUTER_API_KEY=your-api-key-here
set LOG_LEVEL=INFOWindows (PowerShell):
$env:OPENROUTER_API_KEY="your-api-key-here"
$env:LOG_LEVEL="INFO"uvicorn main:app --reload --port 8000The API will be available at http://localhost:8000
cd backend
python -m pytestpython -m pytest -k "test_name"python -m pytest -vOnce the server is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
curl -X POST http://localhost:8000/analyze \
-H "Content-Type: application/json" \
-d '{
"fault_code": "P0562",
"technician_notes": "Engine overheating",
"voltage": 14.2
}'{
"status": "Approved",
"failure_analysis": "Battery voltage low causing system stress",
"warranty_decision": "Production Failure",
"confidence": 85.0,
"reason": "Low system voltage detected during operation indicates component failure rather than customer misuse",
"matched_complaint": "Engine overheating",
"decision_engine": "Rule+ML"
}capProj-2/
├── backend/
│ ├── main.py # FastAPI endpoints
│ ├── ml_predictor.py # ML predictor + rule engine
│ ├── llm_client.py # OpenRouter LLM client
│ ├── requirements.txt # Python dependencies
│ ├── .env # Environment variables (gitignored)
│ └── tests/ # Unit tests
├── frontend/
│ └── index.html # Single-page frontend
├── docker-compose.yml # Docker orchestration
└── README.md # This file
If you see errors about missing API keys, ensure:
- The
OPENROUTER_API_KEYis set in your environment - The key is valid and has not expired
- You have sufficient credits in your OpenRouter account
If port 8000 or 3000 is already in use, modify docker-compose.yml to use different ports:
ports:
- "8001:8000" # Host:ContainerIf the ML model fails to train, check:
- The dataset file exists:
backend/synthetic_warranty_claims_v2.csv - You have sufficient disk space
- Python dependencies installed correctly
MIT License