Architecture
Interactive Case Study: View implementation source code on GitHub
graph TD
%% Define Nodes with Click Events
User((User Email)) --> Gmail[Gmail API]
Gmail --> Supabase[(Supabase DB)]
Supabase --> Router{LLM Router}
%% Routing logic
Router --> Gemini[Gemini 1.5]
Router --> Claude[Claude 3.5]
Router --> Groq[Groq Llama 3]
Gemini --> Validator[Pydantic Validator]
Claude --> Validator
Groq --> Validator
Validator --> Drafter[Drafting Agent]
Drafter --> CrewAI[CrewAI Orchestration]
%% Apply Click Events to specific nodes
click Router call showDetails("Router") "View Router Logic"
click Validator call showDetails("Validator") "View Validator Logic"
click Drafter call showDetails("Drafter") "View Drafter Logic"
Trade-offs
Discussion on the trade-offs made in the architecture...
Core Components & Reasoning
- LLM Router: The entry point. Reasoning: Abstracting the provider allows for seamless switching without impacting the core business logic.
- Pydantic Validator: Used to enforce output structure. Benefit: Ensures downstream tools receive clean, typed data, reducing runtime crashes.
- CrewAI Orchestration: Orchestrates the "Validator" and "Drafter" agents. Trade-off: Increased latency vs. higher quality control.
Skills Demonstrated
- ✅ LLM API Integration (Gemini, Claude, Groq)
- ✅ Graceful Fallback Design (error handling)
- ✅ Cost Optimization (Groq free-tier strategy)
- ✅ Latency & Rate Limit Strategy
Cost Analysis
Breakdown of expenses and RLS policy efficiency...
| Model | Cost/1K | Speed | Reliability |
|---|---|---|---|
| Gemini Flash | Free | Fast | ⚠️ Low |
| Claude Haiku | $0.15 | Med | ✅ High |
| Groq Llama | Free | Ultra-Fast | ✅ High |
Insight: Groq provides the best balance of speed and cost, making it the primary choice for high-volume processing.
Failure Scenarios
Handling strategies for LLM timeouts and errors...
- Gemini Rate Limit (429): The router detected the limit at 10 AM, immediately switched to Claude, resulting in zero user-facing downtime.
- Claude Credit Depletion: When $5 free credits were exhausted, the system automatically routed to the Groq free tier, keeping the process live.
- Groq Model Deprecation: After a model was deprecated mid-project, I tested and migrated to llama-3.1-8b-instant, demonstrating the value of abstracting LLM calls.