Production-grade FastAPI + React/Vite automation platform that syncs Gmail inboxes, classifies messages with LLMs, and drafts actionable replies.
Built by Prema Vision LLC, an AI automation consultancy led by Denys Korolkov.
Web UI (Human-in-the-loop Dashboard) 👉 https://prema-inbox-triage-ai.vercel.app
API (Swagger / OpenAPI) 👉 https://prema-inbox-triage-ai.onrender.com/docs
Demo Video (2 min walkthrough) 👉 https://youtu.be/OHVMQciu70U
Short, real-world demo showing:
- Inbox sync (Mock + Real Gmail modes)
- AI classification (Sales / Support / Noise)
- Context-aware reply drafting
- Human review & approval before sending
Inbox Triage AI solves the "buried lead" problem by converting chaotic email streams into structured, actionable workflows. The system ingests messages, applies LLM classification (Lead, Support, Spam), and auto-drafts context-aware replies.
Operators manage the process via a dedicated "human-in-the-loop" dashboard, enabling review and approval in seconds—combining automation speed with operational control.
For businesses drowning in inbound communications, this architecture demonstrates a scalable path to automation:
- Sales Ops: Instantly flag high-value leads and draft initial outreach, reducing speed-to-lead time.
- Support Ops: Auto-triage tickets and draft responses to common queries, freeing agents for complex issues.
- Engineering Quality: Shows how to build AI agents that are testable, observable, and reliable—moving beyond fragile scripts to production-grade software.
- Dual-Mode Sync Engine: Seamlessly switches between real Gmail OAuth integration and a rich Mock Generator for safe demos and testing.
- AI Classification Pipeline: Uses OpenAI (GPT-4o) to categorize emails by intent, priority, and sentiment, while extracting key entities.
- Context-Aware Drafting: Automatically generates reply drafts based on email context and historical patterns.
- Operational Dashboard: Dedicated React/Vite dashboard for reviewing classifications, editing drafts, and managing inbox state.
- Robust Persistence: SQLModel (SQLite) backend ensures data consistency, audit trails, and easy state management.
- Developer Experience: Fully typed codebase (Python/TypeScript), dependency injection, and comprehensive E2E testing (Playwright).
Complete dashboard showing inbox summary with AI-powered categorization, sales lead detection, and reply drafts
Fully responsive mobile interface with touch-optimized controls and summary cards
The system follows a domain-driven design with a clear separation of concerns. A FastAPI backend orchestrates the ingestion, classification, and response workflows, identifying clear boundaries between external providers (Gmail, OpenAI) and core business logic.
graph TD
Client[React Frontend]
subgraph Backend [FastAPI Backend]
API[API Routes]
subgraph Services
Ingestion[Ingestion Service]
Classification[Classification Service]
Reply[Reply Service]
Send[Send Service]
end
subgraph Data [Data Layer]
Repo[Email Repository]
DB[(SQLite DB)]
end
subgraph Providers [Provider Layer]
Gmail[Gmail Provider]
LLM[OpenAI Client]
end
API --> Ingestion & Classification & Reply & Send
Ingestion --> Gmail
Ingestion --> Repo
Classification --> LLM
Classification --> Repo
Reply --> LLM
Reply --> Repo
Send --> Gmail
Send --> Repo
Repo --> DB
end
Client -->|HTTP/JSON| API
Gmail <-->|IMAP/SMTP| ExternalGmail[Gmail API]
LLM <-->|Completion| ExternalAI[OpenAI API]
graph LR
subgraph Providers
Gmail[Gmail API / Mock]
OpenAI[OpenAI API]
end
subgraph Backend_Services
Ingestion[Ingestion Service]
Classify[Classification Service]
Reply[Reply Service]
Send[Send Service]
end
subgraph Data
DB[(SQLite / SQLModel)]
end
subgraph UI
Dashboard[React Dashboard]
end
Gmail -->|Fetch Emails| Ingestion
Ingestion -->|Store Raw| DB
DB -->|Unclassified Emails| Classify
Classify -->|Prompt| OpenAI
OpenAI -->|Category & Tags| Classify
Classify -->|Update Status| DB
DB -->|Classified Emails| Reply
Reply -->|Prompt| OpenAI
OpenAI -->|Draft Content| Reply
Reply -->|Save Draft| DB
DB -->|Sync State| Dashboard
Dashboard -->|Review & Edit| DB
Dashboard -->|Approve Send| Send
Send -->|Dispatch| Gmail
| Layer | Technologies |
|---|---|
| Backend | Python 3.12, FastAPI, SQLModel, Pydantic, Poetry |
| AI & Data | OpenAI API (GPT-4o), SQLite, Vector embeddings (optional integration-ready) |
| Frontend | React 18, TypeScript, Vite, CSS Modules, Axios |
| Testing | Pytest, Playwright, Unittest |
| DevOps | GitHub Actions, Docker (implied), Environment Config Management |
# Install dependencies
poetry install
# Configure environment
cp .env.example .env
# Edit .env to set OPENAI_API_KEY and GMAIL_USE_MOCK=True for testingcd frontend
npm install# Terminal 1: Start Backend
poetry run uvicorn app.main:app --reload
# Terminal 2: Start Frontend
cd frontend
npm run devAccess the dashboard at http://localhost:5173.
- Sync Inbox: Click "Sync" to fetch recent emails. If in Mock mode, this generates realistic test scenarios.
- AI Processing: Watch as the system automatically classifies emails as "Sales", "Support", or "Noise".
- Review Drafts: Click on a "Sales" lead to see the AI-suggested reply.
- Human Override: Edit the draft inline to add a personal touch.
- Send: Click "Send Reply" to dispatch the email (logs to console in Mock mode, sends via API in Real mode).
- Retriage: Use the "Retriage" button to force a re-evaluation if the context changes.
The API is fully documented via Swagger UI at http://localhost:8000/docs.
Sync Emails:
POST /emails/sync
{
"limit": 5
}Get Email Details:
GET /emails/{email_id}Send Reply:
POST /emails/{email_id}/send
{
"body": "Updated reply content..."
}- CTOs & Founders: Evaluating build-vs-buy for internal AI operations tools.
- Enterprise Architects: Looking for reference patterns on integrating LLMs into legacy workflows safely.
- Consultants: Demonstrating the capability to deliver end-to-end AI automation, not just chat interfaces.
- Multi-Provider Support: Abstracted provider pattern allows easy addition of Outlook (Graph API) or HubSpot.
- RAG Integration: Connect
ReplyServiceto a vector database to draft answers based on company knowledge bases. - Background Workers: Move LLM processing to Celery/Redis for high-volume non-blocking throughput.
- WebSockets: Implement real-time frontend updates as emails are processed.
For collaboration, consulting, or questions: Denys Korolkov — Prema Vision LLC