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.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.
The Nine Tiers
Players progress through nine leagues in the following order, with each tier represented by a distinct icon and color:| Order | League Key | Display Name | Icon | Color |
|---|---|---|---|---|
| 0 | bronze | Bronce | 🥉 | #cd7f32 |
| 1 | silver | Plata | 🥈 | #c0c0c0 |
| 2 | gold | Oro | 🥇 | #ffd700 |
| 3 | sapphire | Zafiro | 💙 | #0f52ba |
| 4 | emerald | Esmeralda | 💚 | #50c878 |
| 5 | diamond | Diamante | 💎 | #b9f2ff |
| 6 | master | Maestro | 🔮 | #9b59b6 |
| 7 | champion | Campeón | 👑 | #f1c40f |
| 8 | heroic | Heroico | ⚔️ | #ff4444 |
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 aLeagueRoom document for their current tier. Rooms hold up to 30 members and are created on demand when an existing room fills up.
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. TheaddLeagueXP(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
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:
- Sorts members by
xpEarneddescending - Promotes the top 10 members to the next tier (if not already
heroic) - Demotes the bottom 10 members to the previous tier (if not already
bronze) - Keeps all remaining members in their current tier
- Calls
LeagueRoom.assignUserto place every member into a new room for the upcoming week - Marks the room as
processed: true
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
| Method | Endpoint | Description |
|---|---|---|
GET | /api/leagues/me | Returns the authenticated user’s current league tier, room data, and weekly XP ranking among room members |
GET | /api/leagues/info | Returns the full list of all 9 league tiers with their display names, icons, and colors |
POST | /api/leagues/process | Admin-only endpoint that manually triggers processWeeklyLeagues() — useful for testing or recovery after a cron failure |