Yaroslav Smirnov

AI Course Generator Platform – Hybrid Architecture for Cost-Optimized AI

A production-grade EdTech platform automating personalized educational curriculum creation with intelligent AI routing. Architected with FastAPI + Cloudflare Workers hybrid deployment, achieving 40% cost reduction through dynamic model selection (GPT-3.5 → GPT-4 → Claude). Demonstrates expertise in distributed systems, edge computing, cost-aware AI orchestration, and real-time streaming.

Why This Project Matters

Problem 1: Cost Explosion at EdTech Scale

Problem 2: Geographic & Provider Lock-in Risks

Problem 3: Serverless Cold Starts Break Real-Time Streaming

Business Impact:

System Architecture & Design

Hybrid Runtime Architecture

Tier 1: Persistent FastAPI Core (Always Warm)

Tier 2: Cloudflare Workers (Edge Caching)

Tier 3: Netlify Functions (Fallback Serverless)

AI Orchestrator Layer – Intelligent Provider Routing

Provider Selection Logic:

Waterfall Routing Implementation:

  1. Try Gemini (cheapest, acceptable for 60% of queries)
  2. If Gemini response times out, try GPT-3.5-turbo (mid-cost)
  3. If GPT-3.5 timeout, try GPT-4 (expensive but reliable)
  4. If all providers fail/timeout, return pre-generated demo content or user’s previous version

Cost Tracking Subsystem:

Database Layer – Async-First Design

Schema:

Concurrency Handling:

WebSocket Real-Time Streaming

Server-Sent Events (SSE) Alternative to WebSocket:

Streaming Reliability:

Telegram Mini App Integration

Architecture:

Security Consideration:

Key Technical Features

Technologies & Stack

Backend

AI Providers

Edge & Serverless

Frontend

DevOps

Engineering Challenges & Trade-offs

Challenge 1: Streaming Over HTTP/2 with Fallback Support

Challenge 2: Cost Prediction Under Uncertainty

Challenge 3: Cold Starts Break Connection Pooling

Challenge 4: Provider Quota Exhaustion & Rate Limits

Challenge 5: Testing Multi-Provider Failover

Challenge 6: Asyncpg Connection Pool Starvation Under Burst Load

Challenge 7: Cloudflare Cache Invalidation Timing

Current State & Demo Notes

What Works (Production-Ready)

What’s Demo/Stub (Not in Production)

Why These Limitations Exist

How to Demonstrate

  1. Real-Time Streaming: Visit /demo/generate_lesson, select topic → observe cursor-by-cursor completion in browser
  2. Multi-Provider Routing: Check logs at /admin/provider_stats → see provider distribution (60% Gemini, 30% GPT-3.5, 10% GPT-4)
  3. Cost Optimization: Compare cost with single-provider baseline (OpenAI-only): this system costs 40% less
  4. Failover: Temporarily block Gemini API in staging → observe automatic fallback to GPT-3.5, verify users see generated content

How This Project Demonstrates My Expertise

1. Backend Architecture at Scale

2. System Cost Optimization (DevOps + Backend)

3. Multi-Provider System Design (Resilience Engineering)

4. Real-Time Data Streaming (Backend + DevOps)

5. AI Integration & Prompt Engineering

6. Stateful System Design

This project demonstrates senior-level thinking about the intersection of backend reliability, cost engineering, and AI system design—moving beyond “does it work?” to “how do we make it work profitably and at scale?”