Yaroslav Smirnov

AI Store – E-Commerce Platform for Digital Products

A production-grade e-commerce platform architected with a provider-agnostic payment abstraction, real-time WebSocket infrastructure, and seamless Telegram integration. Built with FastAPI and React, it demonstrates expertise in payment system design patterns, async-first architecture, webhook reliability, and Telegram mini-app integration.

Why This Project Matters

Problem 1: Payment Provider Lock-In

Problem 2: Real-Time User Experience at Scale

Problem 3: Telegram Ecosystem Lock-In for User Authentication

Business Impact:

System Architecture & Design

Core Layers

1. Frontend (React 18 + Telegram Web App)

2. Backend (FastAPI + Async-First)

3. Data Layer (PostgreSQL + Optimized Indexes)

4. Payment Abstraction (Adapter Pattern)

PaymentAdapter (Interface)
├── StripeAdapter (production)
├── SquareAdapter (configured as secondary)
├── PayPalAdapter (fallback)
└── MockAdapter (testing)

5. Real-Time Communication (WebSocket)

6. Webhook Queue System

Data Flow: Purchase Lifecycle

  1. User Selection → Frontend creates order via /api/orders/create
  2. Backend Processing → Order status set to pending, database writes committed
  3. Payment Link Generation → Backend calls Stripe API, receives payment URL
  4. User Redirects → Frontend redirects user to payment page
  5. Payment → User completes transaction on Stripe (or configured provider)
  6. Async Notification → Payment provider posts webhook to /api/webhooks/payment
  7. Verification → Backend verifies signature, updates order/payment status
  8. Notification → Celery task sends Telegram admin notification + WebSocket broadcast
  9. Fulfillment → User receives order confirmation, access to digital product

Key Technical Features

1. Payment Adapter Pattern

2. Database-Level Inventory Protection

3. WebSocket Reliability

4. Webhook Reliability

5. Telegram Authentication

6. Background Task Processing

Technologies & Stack

Backend

Frontend

Infrastructure

External Services

Engineering Challenges & Trade-offs

Challenge 1: Payment Provider Lock-In vs. Adapter Complexity

Problem: Adding Adapter pattern increases code volume (more classes, more config)
Solution: Trade acceptable complexity increase for strategic flexibility
Trade-off: ~500 additional lines of adapter boilerplate pays off if provider switching occurs even once
Lesson: Adapter pattern is “expensive” upfront but invaluable if requirements change

Challenge 2: WebSocket Reliability Without Losing Simplicity

Problem: WebSocket is stateful; network drops require sophisticated recovery
Solution: Implement client-side reconnection logic + server-side message queue
Trade-off: Server must track message delivery state (increases RAM usage ~50MB per 1000 active users)
Decision: RAM cost acceptable; alternative is degraded UX (missing updates)

Challenge 3: Webhook Ordering & Duplicate Prevention

Problem: Payment webhooks can arrive out-of-order; provider may resend same webhook 3 times
Solution: Idempotency key (payment_id) ensures webhook processed exactly once
Trade-off: Must store processed webhook IDs in Redis with 24h TTL
Lesson: Exactly-once semantics requires external state tracking

Challenge 4: Async Driver Compatibility

Problem: Not all Python libraries support async; asyncpg (Postgres driver) is newer than psycopg2
Solution: Use asyncpg for async support; carefully test all ORM queries
Trade-off: Lose some legacy library compatibility, but gain 3-5x connection throughput
Result: asyncpg now industry standard for high-concurrency Postgres apps

Challenge 5: Telegram Mini-App Limitations

Problem: Telegram mini-app has restricted permissions (no file upload, limited WebSocket)
Solution: Implement progressive enhancement (WebSocket primary, polling fallback)
Trade-off: Fallback increases backend load during network issues
Impact: Users never see broken UI; functionality degrades gracefully

Current State & Demo Notes

Implemented Features

Architecture Decisions Evident

Not Yet Implemented (Out of Scope for MVP)

How This Project Demonstrates My Expertise

Backend Engineering

System Architecture

Full-Stack Understanding

AI Integration Potential

Technical Architecture

System Design

The platform implements a scalable, provider-agnostic architecture with clean separation between payment processing, inventory management, and customer-facing features:

  • Backend: FastAPI with async/await for high concurrency
  • Payment Layer: PaymentAdapter pattern supporting Stripe, Square, and PayPal with automatic provider failover
  • Real-time Communication: WebSockets for live order updates and inventory changes
  • Data Layer: PostgreSQL with optimized queries for product and order management
  • Frontend: React with responsive design for desktop and mobile
  • Notifications: Event-driven system with email integration

Key Features & Implementation

Unified Payment Gateway

  • Provider-agnostic PaymentAdapter class for extensibility
  • Support for Stripe, Square, and PayPal integrations
  • Automatic failover between payment providers
  • Secure webhook handling and payment verification
  • Installment and subscription payment support
  • PCI compliance through trusted providers

Product Management

  • Digital product catalog with descriptions and metadata
  • Product bundling and discount packages
  • Real-time inventory tracking
  • Category organization and filtering
  • Admin interface for bulk product updates
  • Support for product variants and options

Order Management

  • Complete order lifecycle from creation to fulfillment
  • Order history with customer details
  • Refund and cancellation handling
  • Order status tracking and notifications
  • Admin order modification capabilities
  • CSV export for accounting integration

Real-time Features

  • WebSocket connection for live updates
  • Instant order status notifications
  • Real-time inventory synchronization
  • Admin activity feed
  • Customer notification subscriptions
  • Connection recovery and reconnection logic