Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DerBasilisk/SEA-ServicioEvaluaconAsistida/llms.txt

Use this file to discover all available pages before exploring further.

Leagues add a competitive, time-boxed dimension to Sealearn’s learning loop. Every week, players compete within a room of up to 30 peers at the same tier. At the end of the week the top performers advance to the next tier, the bottom performers drop down, and everyone else stays put. The cycle resets every Monday, giving every student a fresh opportunity to climb the ranks.

The Nine Tiers

Players progress through nine leagues in the following order, with each tier represented by a distinct icon and color:
OrderLeague KeyDisplay NameIconColor
0bronzeBronce🥉#cd7f32
1silverPlata🥈#c0c0c0
2goldOro🥇#ffd700
3sapphireZafiro💙#0f52ba
4emeraldEsmeralda💚#50c878
5diamondDiamante💎#b9f2ff
6masterMaestro🔮#9b59b6
7championCampeón👑#f1c40f
8heroicHeroico⚔️#ff4444
The current league for each user is stored on the User model as the league field, constrained to this exact enum. All new accounts start at bronze.

League Rooms

Each week a player is assigned to a LeagueRoom document for their current tier. Rooms hold up to 30 members and are created on demand when an existing room fills up.
// LeagueRoom model fields
{
  league:     String,   // one of the 9 tier keys
  weekStart:  Date,     // Monday 00:00 of the current ISO week
  members:    [{ user, xpEarned, promoted, demoted, joinedAt }],
  processed:  Boolean,  // true after weekly processing has run
  roomNumber: Number,   // sequential room number within the tier/week
}
LeagueRoom.assignUser(userId, league) handles placement: it first checks whether the user already has a room for the current week, then finds an existing room with available space, and creates a new numbered room if none exists.

XP Contribution

Every XP reward earned in Sealearn feeds into a player’s league standing. The addLeagueXP(userId, xpAmount) service function increments members.$.xpEarned in the player’s current LeagueRoom document. It is called automatically:
  • After completing a lesson (with the adaptive XP reward)
  • After winning or completing a duel
If the player is not yet in a room for the current week, addLeagueXP auto-assigns them one and then applies the XP increment.

Weekly Processing

The weekly processing job (processWeeklyLeagues) is triggered every Monday at 00:00 by a cron scheduler. It finds all LeagueRoom documents with processed: false whose weekStart is earlier than the current week, then for each room:
  1. Sorts members by xpEarned descending
  2. Promotes the top 10 members to the next tier (if not already heroic)
  3. Demotes the bottom 10 members to the previous tier (if not already bronze)
  4. Keeps all remaining members in their current tier
  5. Calls LeagueRoom.assignUser to place every member into a new room for the upcoming week
  6. Marks the room as processed: true
const PROMOTE_COUNT = 10;
const DEMOTE_COUNT  = 10;
Weekly processing runs every Monday at 00:00. The weekStart date is always the Monday of the ISO week, calculated by LeagueRoom.getWeekStart(). Rooms are locked once processed: true — past room data is preserved for historical reference.

API Endpoints

MethodEndpointDescription
GET/api/leagues/meReturns the authenticated user’s current league tier, room data, and weekly XP ranking among room members
GET/api/leagues/infoReturns the full list of all 9 league tiers with their display names, icons, and colors
POST/api/leagues/processAdmin-only endpoint that manually triggers processWeeklyLeagues() — useful for testing or recovery after a cron failure

Build docs developers (and LLMs) love