Group-Alloc

Sequential group numbers for university classes, with zero duplicates under load.

Group-Alloc screenshot

Overview

A multi-tenant tool for course reps: group leaders open a class link and claim the next group number; the rep watches the roster fill in live and exports a PDF presentation schedule for the lecturer.

What makes it work

  • Race-condition-proof allocation: an atomic UPDATE … RETURNING counter row in PostgreSQL guarantees #1, #2, #3 with no duplicates even when everyone submits at once
  • Multi-tenant: one database, tenant_id isolation, and a rep can manage several classes across semesters
  • Two portals - a public, mobile-first submit page per class code, and an authenticated admin dashboard
  • Live roster with 4-second polling, one-click PDF schedule and CSV export
  • Rate limiting and bcrypt-hashed credentials on the admin side

The story

Every semester the same scene: a course rep in a WhatsApp group trying to hand out group numbers, and three groups all claiming to be #4. Group-Alloc replaces that with a link.

The interesting problem is concurrency. Forty group leaders tap submit within the same minute, so the allocation cannot be “read the last number, add one”. Each class has a counter row and the allocation is a single atomic UPDATE … RETURNING in PostgreSQL, which makes duplicates impossible without any locking code in the application.

The rep's dashboard polls every few seconds, so numbers appear as they are claimed, and a PDF roster for the lecturer is one click away.