Skip to content
All projects

SaaS · AI video · Billing

Yepic AI — Avatar Video Platform

Backend of Yepic AI, a SaaS for AI video avatars: accounts, a public API, usage-based billing and orchestration of external AI services. Built at Launchist.

My role
Backend developer at Launchist. Worked on the API, billing and payments integration and background processing.
Stack
  • Python
  • FastAPI
  • PostgreSQL
  • MongoDB
  • Redis
  • Lago
  • Stripe
  • Vertex AI

The problem

The product sells AI video generation by usage — through a web studio and a public API — and relies on several external AI services. Usage has to be metered and billed correctly, and long-running jobs such as avatar training and video generation have to survive restarts and report progress.

Architecture

Yepic AI — Avatar Video Platform — Architecture diagramClientsstudio · public APIFastAPIauth · API keysLago · Stripeusage billingVertex AIavatar trainingTavus · Dailyreal-time callsTTS providersCartesia · ElevenLabsPostgreSQLbilling · usersMongoDBtask queueRediscache
The web studio and API clients call a FastAPI backend. Users, subscriptions, invoices and wallets live in PostgreSQL; conversations, personas and the background task queue live in MongoDB; Redis caches responses. The backend meters usage in Lago, takes payments through Stripe, launches avatar training on Vertex AI, starts real-time conversations through Tavus and Daily and generates speech through several TTS providers.

Key decisions

  1. 01Billing webhooks stored before processing

    Why
    Every Lago event is saved first and then dispatched to a dedicated handler per event type — invoice created, paid, overdue, payment failed and so on. If a handler fails, nothing is lost and the event can be processed again.
    Trade-off
    An extra table and a handler class for each event type.
  2. 02External providers behind factories

    Why
    Training backends, text-to-speech engines (Cartesia, ElevenLabs, Google, Amazon Polly) and model versions are selected through factories, so adding a provider or a new model version doesn't touch business logic.
    Trade-off
    More indirection when following a request through the code.
  3. 03Plan-gated API keys in middleware

    Why
    A middleware resolves the API key and checks that the subscription is active and the plan includes API access, so monetization rules are enforced in one place for every endpoint.

What I built

  • FastAPI backend on PostgreSQL (SQLAlchemy, Alembic) and MongoDB (Beanie)
  • Usage-based billing with Lago and Stripe, webhooks for invoices, wallets and subscriptions
  • Public API with keys gated by subscription plan
  • Avatar training on Vertex AI with progress webhooks
  • Real-time AI conversations through Tavus and Daily; pluggable text-to-speech providers
  • Background task queue with dependent tasks: transcript summary → video generation → status checks