Part 3: Real-World Code

From concepts to production

Three Production Systems

Going beyond basic Web apps

  1. Vianet Marketing — Email marketing platform
  2. OrbitFour — full featured domain registration platform
  3. Vianet Admin — Multi-site LiveView dashboard

Vianet Marketing

Sending emails through AWS Simple Email Service (SES)

Vianet Marketing email campaign dashboard

The Challenge

Send 500,000+ personalized marketing emails

  • Emails need to be sent individually so each one is trackable.
  • Ensure we send one and only one email per recipient!
  • Handle bounces, complaints, and delivery notifications
  • Each email generates 3–4 API requests — needs to run concurrently without blocking the app
  • With AWS SES, if you exceed your rate limit, they...
    silently drop your emails.

Our Solution

  • Scheduler Worker queries recipients, creates Oban jobs
  • Oban picks up each job and triggers a Mailer Worker
  • Mailer Worker validate → personalize → rate-check → send
  • Rate Limiter ensures we never exceed the AWS SES limit

Scheduling 500k Jobs

Stream records in chunks — constant memory usage


def perform(%Oban.Job{args: args}) do
  member_ids = Campaigns.member_ids!(args["campaign_id"])

  # Stream from DB → chunk → bulk insert jobs
  Repo.transaction(fn ->
    Repo.stream(member_ids(campaign), max_rows: 2_000)
    |> Stream.chunk_every(2_000)
    |> Enum.each(fn member_ids ->
      member_ids
      |> Enum.map(&build_mailer_job(&1, campaign))
      |> Oban.insert_all()
    end)
  end, timeout: :infinity)
end
        

The Mailer Worker

Pattern matching handles every possible failure


def perform(%Oban.Job{args: args} = job) do
  campaign_id = Map.get(args, "campaign_id")
  member_id = Map.get(args, "member_id")

  with(
    {:ok, member}         <- get_member_with_site(member_id),
    {:ok, _}              <- validate_email(member.email),
    {:ok, campaign}       <- get_campaign_with_site(campaign_id),
    {:ok, _}              <- EmailRateLimiter.ready?()
  ) do
    send_campaign_email(campaign, member)
  else
    {:not_ready, :exceeded_rate}  -> {:snooze, 1}
    {:already_sent}               -> {:discard, :already_sent}
    {:invalid_email}              -> {:discard, :invalid_email}
    {:error, result}              -> {:error, result}
  end
end
        

The Rate Limiter

A GenServer using a token bucket algorithm


defmodule Marketing.EmailRateLimiter do
  use GenServer

  defstruct tokens: 0.0, rate: 100.0

  # Public API — other code just calls this
  def ready?, do: GenServer.call(__MODULE__, :acquire)

  def handle_call(:acquire, _from, state) do
    if state.tokens >= 1.0 do
      {:reply, {:ok, :token}, %{state | tokens: state.tokens - 1.0}}
    else
      {:reply, {:not_ready, :exceeded_rate}, state}
    end
  end
end
        

OrbitFour Domain Registry

Taking ownership of our core functions

OrbitFour homepage

What is OrbitFour?

A domain registrar — think GoDaddy, but built by a small team in West Michigan.

  • Talks directly to Verisign via persistent TCP — EPP protocol
  • Full lifecycle: search → register → DNS → renew → transfer
  • Billing, RDAP/WHOIS, customer portal, marketing site — all one Phoenix app
  • 16 background workers — syncing, renewals, health checks

The Core Function

OrbitFour is a domain registrar and needs to communicate with registries like Verisign via EPP as our core function.

  • Originally an open-source PHP EPP library was used.
  • Open-source is great for non-core features.
  • We needed to own the protocol layer: persistent TCP/TLS, connection pooling, automatic recovery

Elixir made this possible — the BEAM was literally built for managing network connections.

OrbitFour EPP Health Monitor

The Real Win

OrbitFour replaced five separate services with one Elixir app

  • PHP EPP service — domain registration
  • Java RDAP service — domain lookups
  • PHP WHOIS service — WHOIS queries
  • Craft CMS — marketing site
  • Nuxt/Vue.js — customer portal

These services took years to build originally.
With Elixir + Claude Code,
we replaced them all in under six months.

Internal Admin

Multi-site LiveView dashboard

Vianet Admin photo review dashboard

The Philosophy

Instead of building admin features into each app...

  • Customer apps stay focused — no admin routes, no admin UI, no admin auth
  • Admin app iterates fast — internal tool, no public-facing risk
  • One dashboard — manage all sites from a single place
  • LiveView — real-time updates, interactive tables, presence tracking

Multi-Database Architecture

Connects to five databases simultaneously. Each Repo is a supervised connection pool to a different PostgreSQL database.


defmodule VianetAdmin.Application do
  use Application

  def start(_type, _args) do
    children = [
      VianetAdmin.Repo,            # Admin's own database
      VianetAdmin.PuppiesRepo,     # Puppies.com database
      VianetAdmin.RRRepo,          # ReputableRooms database
      VianetAdmin.RoommatesRepo,   # Roommates database
      VianetAdmin.GeocodeRepo,     # Geocoding database
      VianetAdmin.ConnectionMonitor,
      VianetAdmin.Presence,        # ← Track which admins are online
    ]

    opts = [strategy: :one_for_one, name: VianetAdmin.Supervisor]
    Supervisor.start_link(children, opts)
  end
end
        

Wrap-up

What We Covered

  1. Why Elixir? — The BEAM, 40 years of reliability
  2. The Language — Pattern matching, processes, supervision, LiveView
  3. Real-World Code — marketing emails, a domain registrar, multi-site admin
  • Concurrency is the default, not an afterthought
  • Errors are handled by design, not by hope
  • Real-time features come for free

It's a different paradigm — and once it clicks, it's hard to go back.

Getting Started

Thank You

Torey Heinz

Vianet Management / Shopflow

github.com/toreyheinz/2026-GR-WebDevElixirTalk

Questions?