vitrin

A feed system built to learn how the real thing works

Vitrin is a polyglot, event-driven social platform — fourteen services, five languages, no shared databases. The domain (posts about movies, series, games) is intentionally simple. The distributed-systems mechanics underneath it are the actual point.

01

Fourteen services, five languages

Every language was picked for the concurrency shape of the job, not preference — CRUD in NestJS, fan-out/fan-in in Go, one process per connection in Elixir, saga orchestration in Kotlin, the ML ecosystem forcing Python.

  • NestJSuser-serviceUsers, follows, auth (merged)
  • NestJSpost-servicePosts, outbox, comments, reactions
  • Gofeed-serviceFollowing feed reads, home feed sessions
  • Gofanout-serviceBulk Redis timeline writes on post.created
  • Gorecommendation-serviceHome feed scatter/gather + ranking
  • Gograph-serviceNeo4j traversal, social signals
  • Goingestion-serviceSingle writer for all ClickHouse events
  • Pythonml-serviceLightGBM scoring, training, model lifecycle
  • Elixirmessaging-serviceEncrypted envelopes, receipts
  • Elixirrealtime-gatewayWebSocket, presence, typing
  • Kotlinworkflow-serviceSaga orchestration
02

Two feeds, opposite trade-offs

"The feed" is two products behind one UI: one precomputed to make reads free, one assembled fresh because there's no order to precompute for relevance.

Following feedpost.created → fanout-service (Redis writes) → feed-service (ZREVRANGE)

Precomputed on write. The read is a single Redis lookup, fast by construction.

Home feedrecommendation-service ⇉ graph · vector · trending · exploration → ml-service (LightGBM) → rerank

Assembled on read. Four sources in parallel, scored fresh for every request.

Messagingclient ⇄ realtime-gateway (Phoenix Channel) ⇄ messaging-service (encrypted envelope, Postgres)

One BEAM process per connection — a crash in one never touches another.

03

Fifteen patterns, written up

Reliability patterns, feed architecture, how the ML behaves once it's serving real requests, and the orchestration underneath it all — each post covers what we tried, what it cost, and why we kept it.

Browse the build log →