FastAPI service for analyzing inbound email communications with the Gemini API.
The tool accepts email metadata/content, asks Gemini for structured analysis, and returns:
- communication classification with confidence
- urgency and risk levels
- fraud and suspicious-activity indicators
- escalation recommendation
- human-validation status
- audit events
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
copy .env.example .envSet GEMINI_API_KEY in .env.
uvicorn app.main:app --reloadOpen http://127.0.0.1:8000/docs.
{
"message_id": "msg-001",
"sender": {
"email": "client@example.com",
"display_name": "Jane Client",
"domain": "example.com"
},
"recipients": ["operations@genesis.example"],
"subject": "Urgent redemption request",
"body": "Please process this redemption today and confirm receipt.",
"received_at": "2026-06-01T09:30:00Z",
"attachments": [],
"thread_id": "thread-001",
"historical_context": {
"known_sender": true,
"usual_sender_domain": "example.com",
"recent_thread_summary": "Client usually sends monthly fund operations requests."
}
}POST /emails/analyze- analyze a single email with Gemini.POST /validations- record a human validation/override.GET /audit/events- inspect audit history.GET /health- service health.