TANVEER HUSSAIN / AI ENGINEER
← All work Experience Certs Get in touch →
Case Study · Backend & Algorithms

Automated Participant
Grouping API

A FastAPI backend that automatically sorts event participants into compatible groups based on exclusion rules and age, then exposes it as a clean API a no-code frontend can call. Read-only and safe against the live database. Built solo, end to end.

Role: Sole Engineer & Architect Domain: Backend / Algorithmic API Stack: FastAPI · Supabase

[ 01 ] The business problem

Organizing people into groups for outdoor events was manual and error-prone. Some attendees bring kids or dogs, others want to avoid them, and groups also needed sensible sizing and age balance. Doing this by hand for every event didn't scale and led to bad pairings.

[ 02 ] The technical solution

An API that pulls participants for an event, applies clear compatibility rules, balances by age, sizes the groups dynamically, and returns ready-made groups, all without touching the live database, so it slots into the existing app safely.

// how it works

From attendees to groups

1

Export participants

For a given event, the API reads the participant list from the existing Supabase schema, strictly read-only, so production data is never modified.

FastAPISupabaseRead-Only Export
2

Compatibility rules

Participants are matched only if compatible: anyone avoiding kids or dogs is never placed with someone bringing them. The exclusion logic is the core of the algorithm.

Rule EngineExclusion LogicConstraint Matching
3

Dynamic group sizing

Group count adapts to headcount, small events get one group, larger ones split into balanced groups sized for the number of attendees.

Dynamic SizingBalancing
4

Age-balanced distribution

Within compatible groups, members are sorted by age and distributed round-robin so each group stays age-balanced rather than lopsided.

Age SortingRound-RobinEven Distribution
5

API response & export

Results come back as clean JSON for the frontend, plus a grouped CSV. Designed for direct integration with a no-code app.

REST APIJSONCSV ExportNo-Code Integration
POST /group-event/{id} → balanced, compatible groups

One call does it all. A single endpoint turns a raw participant list into compatible, age-balanced, correctly sized groups, ready for the app to display.

// engineering depth

Hard problems solved

~ constraints

Real constraint logic

Grouping under exclusion rules (avoid vs bring) is a genuine constraint-satisfaction problem, not a simple split. The logic guarantees no incompatible pairing.

~ balance

Fair, balanced groups

Dynamic sizing plus round-robin age distribution keeps groups even in both size and age, instead of dumping everyone into one bucket.

~ safety

Zero-risk to production

The whole system is read-only against the live database and works off exports, so it adds capability without any chance of corrupting existing data.

~ integration

Clean API for no-code

Simple, predictable REST endpoints with JSON responses make it trivial to wire into a no-code frontend, no backend knowledge needed on their side.

~ testability

Logic that runs standalone

The grouping algorithm runs and is tested independently of the database, via CSV, so the core logic is verifiable without any live connection.

~ ownership

Solo, full backend

API, models, database layer, business logic, and tests, designed and shipped end to end by one engineer.

// stack

Built with

Backend
PythonFastAPIPydanticUvicornGunicorn
Data
SupabasePostgreSQLSQL SchemaCSV ProcessingRead-Only Queries
Logic
Constraint MatchingExclusion RulesDynamic SizingRound-RobinAge Balancing
API
RESTJSONEndpoint DesignError HandlingHealth Checks
Integration
No-Code FrontendFlutterFlowHTTP API
Domain
Event ManagementAlgorithmic GroupingBackend ArchitectureSolo Delivery
// outcome

The result

Manual → API
Grouping fully automated
0
Incompatible pairings allowed
Read-Only
Zero risk to production data
100%
Designed & built solo, end to end
// let's build

Have a problem that needs a system?

I turn messy business problems into reliable systems, APIs, hardware control, voice agents, content platforms, RAG, and automation, designed and shipped solo.

Tanveer Hussain · AI Engineer · Building systems that never sleep.