The Roulette is the core feature of SpinAI. A single spin randomly assigns every active team member to an upcoming Friday meeting slot, eliminating manual scheduling and any perception of bias. The wheel is rendered on an HTML5 canvas, the animation runs for approximately 3.5 seconds, and once it stops you can review all assignments before committing them to the database.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fmoraga01/SpinAI/llms.txt
Use this file to discover all available pages before exploring further.
How the wheel works
The wheel is drawn using the browser’s Canvas 2D API onto a 300×300 pixel surface (scaled bydevicePixelRatio for crisp rendering on high-DPI screens). Each active team member occupies an equal-angle segment of the wheel, with segments alternating between two dark surface tones (#141724 and #0e101a).
A fixed blue pointer triangle (#2C40FF) sits at the top of the canvas on a separate overlay layer, so it never rotates with the wheel. When the wheel stops, the winning segment is highlighted in blue:
- Segment fill:
#2C40FF22with ashadowBlur: 20glow - Segment border:
#2C40FF55 - Initials label:
#2C40FF - Outer ring: stroked in
#2C40FFwithshadowBlur: 12
−π/2 radians).
Bulk assignment logic
Spinning the wheel does not assign one person — it assigns all active members at once. The functionbuildBulkAssignmentPreview() in lib/storage.ts handles the full computation:
Fetch current data
Load all members and assignments from Supabase, filtering to only active members.
Identify unassigned slots
Collect future slots where
member_id is null (created when a member was removed). These are filled first, before any new Friday dates are created.Calculate required Fridays
Call
getNextFridays(count) to generate enough upcoming Friday dates, skipping any dates that are already taken.Fisher-Yates shuffle
Shuffle the active members array using the Fisher-Yates algorithm so the order is uniformly random.
0 is the one whose segment lands under the pointer — they receive the soonest upcoming slot.
Spin → preview → confirm flow
After the wheel stops, the UI transitions from the Spin button to a two-button Confirm / Cancel panel:Spin
Click ¡Girar! to start the canvas animation. The button is disabled while the animation plays and if no active members exist.
Review preview
A scrollable list appears showing every assignment in order: member initials, full name, and the formatted Friday date. The first entry (the wheel winner) is highlighted in blue.
getNextFridays(count) utility
getNextFridays(count) returns an array of count upcoming Friday dates as YYYY-MM-DD strings. It works by:
- Finding the current day of the week (
Date.getDay()). - Computing how many days until the next Friday — if today is already Friday it skips to the following one (7 days ahead), if it is Saturday it jumps 6 days.
- Iterating forward in 7-day increments to collect the requested number of Fridays.
buildBulkAssignmentPreview() calls this with needed + data.assignments.length + 4 to ensure there are always enough candidate dates even when the schedule is already heavily populated.
Managing team members
Team members are managed from the Equipo panel. The following operations are available:Add member
Creates a new member record and immediately inserts one assignment slot: one Friday after the last existing scheduled date, or the next upcoming Friday if no assignments exist yet.
Toggle active / inactive
Calls
toggleMember(id) to flip the active boolean. Inactive members are hidden from the wheel and will not receive new slots on the next spin.Rename
Calls
updateMemberName(id, name), which atomically updates the members, assignments, and templates tables so the name stays consistent everywhere.Set email
Calls
updateMemberEmail(id, email). The email is used for automated reminder notifications.Remove
Calls
removeMember(id). Future assignment slots are not deleted — they are marked unassigned (member_id: null, member_name: null) so the scheduled Friday dates are preserved. Past assignments are deleted.Only active members appear as segments on the roulette wheel and are included in bulk assignment previews. Inactive members retain their existing scheduled slots but will not receive new ones.