nocturn

Knowledge that pays off.

Full-stack engineerTeam projectnocturn.app

A live Nocturn quiz room, with players and the current question on screen.

01What it does

Nocturn is a live quiz platform. A host builds a quiz alone, with collaborators, or with an AI agent, then runs it live for players and spectators. The host can lock a SOL or USDC prize pool in an on-chain escrow, and the winners claim from it.

I built the real-time core: the socket system, the queue that moves a quiz from phase to phase, and the leaderboard. I also wrote the escrow program, the payments, the deploy pipeline and most of the frontend.

Role
Full-stack engineer. Real-time core, escrow program, payments and frontend
Team
A small team. The AI quiz agent was led by a teammate
Stack
Next.js, Express, Redis, Bull, Postgres and an Anchor program
Status
Live at nocturn.app

02The stack

Frontend
Next.js 15React 19Tailwind 4ZustandFramer MotionGSAPRive
Backend
Express 5wsBullHono on WorkersDodo Payments
Data
Postgres 16Prisma 7RedisS3
Chain
AnchorSolana escrow PDAsWallet adapter
Infra
GitHub ActionsGHCRDocker Compose on EC2nginx

03Backend

What I solved on the backend

01

Four roles, one room, many servers

A host, players, spectators and co-editors all share a room, and they are not on the same server.

Each role has its own socket manager with its own rules. Redis Pub/Sub carries every room event between server instances, so a room works no matter where each person is connected.

  • ws
  • Redis Pub/Sub
  • Role managers
02

Quiz phases run on a queue

A quiz moves from reading, to answering, to results. Timers inside one server die with that server.

Each phase change is a job on a Bull queue. A worker in a separate service picks it up and publishes the change to the room. A Redis key that expires ends any game that was left behind.

  • Bull
  • Worker service
  • Key expiry events
03

A leaderboard that stays fast

The first version read every score and sorted them in JavaScript after each answer.

Scores moved to Redis sorted sets, written in one pipeline. The server now sends the top few rows plus each player's own rank, and nothing else.

  • Sorted sets
  • Pipelines
  • Top K
04

Database writes off the hot path

Writing each answer to Postgres during a live question slowed the room down.

Answers, sessions and quiz updates go through a write-behind queue with three tries. The room reads from Redis while the database catches up.

  • Write-behind
  • Bull
  • Postgres
05

A prize escrow on Solana

Winners need to trust that the prize is real before they play.

An Anchor program with seven instructions holds the pool in an escrow account. A claim is tied to a claim token and a hash of the winner's email, with an expiry. Prizes nobody claims can be taken back by the host.

  • Anchor
  • PDAs
  • CPI transfers

04Design

What I solved on the design side

01

A hero that plays the product

A screenshot cannot show that the product is live.

The landing hero is a small browser window that plays a chat turning into a quiz. A live activity card reorders its avatars, and reactions float up when you click them.

  • Framer Motion
  • Scripted sequence
02

Staking that reads like a form

Locking a prize on chain is the scariest step for a host.

The stake step sits inside the quiz builder as one more panel, with the amount, the token and the split in plain view before anything is signed.

  • Quiz builder
  • Wallet flow
The Nocturn quiz builder with the panel for staking a Solana prize pool.
03

Small physical touches

Quiz apps tend to look like spreadsheets with a timer.

Avatars fall and pile up with real physics, cards glow where the cursor is, and buttons lift onto a hard offset shadow when you hover them.

  • matter-js
  • Cursor glow