Back to Home

A provably fair competition platform built on cryptographic trust.

Full-stack prize competition platform for a UK automotive business — where every draw is transparent, verifiable, and cryptographically secure.

PM Competitions platform screenshot
ClientProcter Motor Competitions
IndustryAutomotive / Prize Competitions
RegionUnited Kingdom
Stack
Next.jsReactTypeScriptSupabaseStripeVercel

The Challenge

The UK prize competition market is crowded — and plagued by scepticism. Entrants routinely question whether draws are legitimate, and operators struggle to prove they are. For a new entrant like Procter Motor, launching into this space without a clear answer to “how do I know this is fair?” was a non-starter.

Procter Motor came to us with a clear objective: build a competition platform for high-value automotive giveaways that people could actually trust. Not through branding or reassurance copy — through verifiable proof.

The platform needed to:

Run cryptographically secure, independently verifiable prize draws
Handle high-volume concurrent ticket sales without errors or duplicates
Meet UK Gambling Commission regulations out of the box
Process payments safely with full transactional integrity

Off-the-shelf solutions couldn't deliver on the core requirement. They rely on basic random number generation that can't be audited, lack the concurrency controls needed for popular competitions, and treat regulatory compliance as an afterthought. A custom build was the only path.

The Solution

01

Provably Fair Draw System

Trust was the central design constraint, so we started with the draw engine.

The winner selection system is built directly into the database layer using PostgreSQL's pgcrypto extension — the same cryptographic library used to generate SSL/TLS certificates. The draw logic never touches application code, eliminating any possibility of manipulation at the API layer.

When an admin triggers a draw, four things happen in sequence:

01

Cryptographic seed

A 256-bit cryptographic seed is generated using hardware-backed random number generation sourced from the server's entropy pool.

02

SHA-256 hash

The seed is combined with the competition ID and a precise timestamp, then hashed using SHA-256 — the algorithm that underpins the Bitcoin network.

03

Winner selection

The hash is converted to an index that maps to a specific ticket in the pool. The winning ticket is selected.

04

Proof stored permanently

The complete cryptographic proof — public seed, SHA-256 hash, verification hash, winning index, and algorithm identifier — is stored permanently alongside the result.

A public verification endpoint allows anyone to independently recalculate and confirm the result. No login required. Enter the competition ID, and the system re-derives the hash from the stored seed and metadata, confirms it matches the original, and proves the winner was selected correctly.

No trust required — just maths.

Admin triggers draw
Seed Generation

256-bit hardware entropy

SHA-256 Hash

Combined with competition ID + timestamp

Winner Selection

Hash mapped to ticket index

Proof Stored

Seed, hash, index — all persisted

Public Verification

Anyone can re-derive the hash and confirm the result — no login required

The entire draw process runs inside the database — the application layer never touches it

02

Concurrent Ticket Sales

Popular competitions can see hundreds of users purchasing tickets simultaneously. A single duplicate ticket number or a failed allocation under load would undermine the fairness the draw system is designed to protect.

The platform pre-generates a complete ticket pool for each competition at creation time. When a user purchases tickets, the system uses PostgreSQL's row-level locking to atomically claim available tickets from the pool. Each allocation is isolated — concurrent transactions skip locked rows and claim the next available tickets, guaranteeing uniqueness even under heavy load.

If any part of a transaction fails, the entire allocation rolls back cleanly. No duplicate ticket numbers. No gaps in the pool. No race conditions.

User A
User B
User C
Ticket PoolRow-level locking
A
A
B
B
C

Concurrent transactions skip locked rows — no duplicates, no race conditions

03

Payment Integrity

The checkout flow was designed around a single principle: no user should ever be left in an ambiguous state. A failed payment should never result in allocated tickets lingering in limbo, and a successful payment should never leave a user without their ticket numbers.

The system achieves this through a staged transaction model:

01

Pre-allocation

Tickets are reserved from the pool and an order is created in a pending state before the user enters payment details.

02

Payment processing

Stripe handles the transaction with full PCI compliance.

03

Confirmation

On successful payment, the order is marked complete, tickets are activated, and a confirmation email is dispatched.

04

Rollback

On failure, the pending order is cancelled and tickets are released back into the available pool automatically.

This guarantees the ticket pool remains consistent at all times, regardless of what happens during checkout.

No user is ever charged without tickets — no tickets are ever stranded without payment.

Pre-allocate

Reserve tickets, create pending order

Payment

Stripe processes transaction

Confirm

Order complete, tickets activated

Rollback

Order cancelled, tickets released

Pool Consistent
04

Regulatory Compliance

UK Gambling Commission regulations require prize competitions to include a skill element to distinguish them from lotteries. This isn't optional — it's a legal requirement.

The platform enforces this at the API level. Each competition can be configured with a skill-based question that participants must answer correctly before they can proceed to checkout. The validation happens server-side — a user cannot create a payment intent without a verified answer on record.

All answers are stored and auditable, giving the operator a clear compliance trail without adding noticeable friction to the purchase flow.

Compliance enforced at the API level — not through policy documents.

05

Automated Communications

Customer communication spans the full competition lifecycle, handled by six email templates built as React components and rendered server-side:

The draw reminder system runs as a Deno-based edge function on a cron schedule, identifying upcoming competitions, grouping ticket holders by user, and dispatching personalised emails.

Ticket Confirmation
Draw Reminder
Winner Announcement
Welcome Email
Postal Entry
Non-winner Notification

Technical Architecture

Swipe for more →

Frontend

Next.js 16 / React 19 / TypeScript / Tailwind CSS / Radix UI

Backend

Next.js API Routes / React Server Components

Database

Supabase (PostgreSQL + pgcrypto + Row-Level Security)

Auth

Supabase Auth (JWT-based)

Payments

Stripe Payment Elements + Webhooks

Email

Resend API + React Email

Storage

Supabase Storage (S3-backed CDN)

Scheduled Tasks

Supabase Edge Functions (Deno runtime)

Hosting

Vercel (Edge Network)

Key Architecture Decisions

Key Features

Provably fair draws

SHA-256 cryptographic proof with public verification endpoint

Concurrent ticket sales

Atomic allocation with row-level locking under load

Transactional payments

Pre-allocate → pay → confirm/rollback cycle via Stripe

Regulatory compliance

Skill question enforcement at API level

Multi-competition support

Parallel competitions with independent ticket pools and draw dates

Real-time progress tracking

Live sales stats via PostgreSQL materialized views

Admin dashboard

Competition management, one-click draws, winner management, CSV exports

Multi-item cart

Purchase tickets across competitions in a single Stripe checkout

Automated email lifecycle

Six templates covering the full competition lifecycle — purchase to draw result

CDN-backed media

Image uploads via Supabase Storage with edge delivery

Mobile-first UI

Responsive design built with Radix UI primitives and Tailwind CSS

Database-level security

Row-level security policies enforced on every table

Looking for a platform built on trust?

Whether you need cryptographic security, high-concurrency systems, or regulatory compliance built in from day one — we'd love to talk.

Get in Touch →