Quick Start Guide
Prerequisites
- Python 3.8+
- MongoDB instance
- Environment variables configured
- JWT authentication service
Setup
-
Clone and navigate to the evaluate service:
cd /Users/ericngo/Desktop/projects/dudu/evaluate -
Install dependencies:
pip install -r requirements.txt
# or using uv
uv sync -
Configure environment variables:
cp .env.example .env
# Edit .env with your configuration -
Start the server:
python server.py
The API will be available at http://localhost:5049
First API Call
-
Get a JWT token from your authentication service:
# Use your auth service or shared auth module
python get_jwt_token.py -
Test the health endpoint:
curl http://localhost:5049/health -
Create an outcome:
curl -X POST "http://localhost:5049/api/outcomes/upload" \
-H "Authorization: Bearer <your-jwt-token>" \
-H "Content-Type: application/json" \
-d '{
"decision_id": "test_decision_123",
"customer_id": "test_user",
"outcome": "success - test outcome"
}' -
Get statistics:
curl -X GET "http://localhost:5049/api/stats/overall" \
-H "Authorization: Bearer <your-jwt-token>"
Workflow Example
1. Create Decision Outcome
curl -X POST "http://localhost:5049/api/outcomes/upload" \
-H "Authorization: Bearer <jwt-token>" \
-H "Content-Type: application/json" \
-d '{
"decision_id": "decision_456",
"customer_id": "customer_123",
"outcome": "success - customer satisfied with recommendation"
}'
2. Get Decision Statistics
curl -X GET "http://localhost:5049/api/stats/decision/decision_456" \
-H "Authorization: Bearer <jwt-token>"
3. Analyze Trends
curl -X GET "http://localhost:5049/api/stats/trends?days=7" \
-H "Authorization: Bearer <jwt-token>"
4. Compare Performance
curl -X GET "http://localhost:5049/api/stats/comparison?limit=5" \
-H "Authorization: Bearer <jwt-token>"
Common Use Cases
Monitoring Recommendation Performance
- Log outcomes from recommendation decisions
- Track success rates over time
- Compare different recommendation strategies
- Identify top-performing decision types
Quality Assurance
- Monitor data completeness and consistency
- Track error rates and response times
- Analyze outcome patterns
- Generate performance reports
Business Intelligence
- Analyze customer satisfaction trends
- Track decision effectiveness
- Monitor system performance metrics
- Generate executive summaries
Integration Examples
With Recommend Service
# After getting recommendations
recommendation_response = requests.post(
"http://localhost:5051/api/recommend/recommend",
headers={"Authorization": f"Bearer {token}"},
json=request_data
)
# Log the outcome
outcome_response = requests.post(
"http://localhost:5049/api/outcomes/upload",
headers={"Authorization": f"Bearer {token}"},
json={
"decision_id": recommendation_response.json()["decision_id"],
"customer_id": customer_id,
"outcome": "success" if customer_purchased else "no_purchase"
}
)
Batch Processing
# Process multiple outcomes
outcomes = [
{
"decision_id": f"decision_{i}",
"customer_id": customer_id,
"outcome": f"outcome_{i}"
}
for i in range(10)
]
for outcome in outcomes:
response = requests.post(
"http://localhost:5049/api/outcomes/upload",
headers={"Authorization": f"Bearer {token}"},
json=outcome
)
Next Steps
- Read the API Overview for detailed endpoint information
- Check Authentication for security details
- Review Outcomes API for outcome management
- Explore Statistics API for analytics features
Troubleshooting
Common Issues
401 Unauthorized
- Check your JWT token is valid and not expired
- Ensure token is properly formatted in Authorization header
404 Not Found
- Verify the endpoint URL is correct
- Check that decision_id or outcome_id exists
500 Internal Server Error
- Check MongoDB connection
- Verify environment variables are set correctly
- Check server logs for detailed error information
Debug Mode
Enable debug logging by setting:
DEBUG=true
LOG_LEVEL=DEBUG
Health Checks
Monitor service health:
curl http://localhost:5049/health