The Team Builder (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Navi-27/Proyecto-UPC/llms.txt
Use this file to discover all available pages before exploring further.
GET /equipo) lets every registered user assemble a personal roster of up to 6 Pokémon. Unlike My Pokédex, which is populated automatically by browsing, building a team is an intentional action — you choose exactly which Pokémon to include by clicking Add to Team on each individual detail page. Your team is independent of every other user’s, and you can swap members in and out at any time.
Authentication Requirement
The team page and all team-management routes are protected. Unauthenticated requests to/equipo, /equipo/agregar/..., and /equipo/eliminar/<pokemon_id> are all redirected to /login.
Full Workflow
Browse to a Pokémon's detail page
Navigate to
http://localhost:5000/pokemon/<nombre> for any Pokémon you want to add — for example, http://localhost:5000/pokemon/charizard. The detail page shows the sprite, types, height, weight, and base stats.Click 'Add to Team'
When logged in, a green ➕ Agregar a mi equipo button appears at the bottom of the stat card. Clicking it sends a All the information needed to store the Pokémon (ID, name, sprite URL, and types JSON string) is passed directly in the URL path, so the server needs no additional lookup.
GET request to:Server validates and inserts
The route handler calls
Equipo.agregar_pokemon(usuario_id, pokemon_id, pokemon_nombre, pokemon_imagen, pokemon_tipos). The method performs two checks before inserting:- Team is full — if
len(equipo) >= Equipo.MAX_POKEMONES(i.e. ≥ 6), it returns(False, "El equipo ya esta completo (6 Pokemones)")without writing to the database. - Duplicate Pokémon — if the Pokémon’s
pokemon_idalready appears in any team row for this user, it returns(False, "El pokemon ya se encuentra en tu equipo"). - Success — otherwise, the Pokémon is inserted into the
equipostable and the method returns(True, "Pokemon Agregado").
Flash message confirms the result
After
agregar_pokemon() returns, the route calls flash(mensaje, "success" if exito else "Error") and redirects back to the Pokémon’s detail page (/pokemon/<nombre>). A green success banner or a red error banner appears at the top of the page to confirm what happened.View your full team at /equipo
Navigate to
http://localhost:5000/equipo to see your complete roster. The page header shows your current count in the format n/6 pokemones. Each team slot is displayed as a card with:- nombre — Pokémon name (capitalised)
- imagen — official front sprite
- tipos — coloured type badges, parsed from the stored JSON string using the
parse_tiposJinja2 filter
Remove a Pokémon from your team
Each team card includes a red Eliminar button. Clicking it calls:The route calls
Equipo.eliminar_pokemon(usuario_id, pokemon_id), which verifies the Pokémon belongs to this user’s team and then runs DELETE FROM equipos WHERE usuario_id = ? AND pokemon_id = ?. A flash message confirms removal, and you are redirected back to /equipo.Team Constraints
The following hard limits are enforced server-side by the
Equipo model — they cannot be bypassed by crafting a URL manually, because the validation runs inside Equipo.agregar_pokemon() before any database write occurs.- Maximum 6 Pokémon per team — enforced by
Equipo.MAX_POKEMONES = 6. Attempting to add a seventh Pokémon returns the error messageEl equipo ya esta completo (6 Pokemones). - No duplicate Pokémon — each
pokemon_idmay appear at most once per user. Adding a Pokémon already on your team returnsEl pokemon ya se encuentra en tu equipo. - Teams are per-user — the
equipostable is keyed onusuario_id. Every registered account maintains a completely independent roster; changes to one user’s team never affect another’s.
Equipo Database Schema
Each row in the equipos table stores everything the team page needs to render a card without any additional lookup:
| Column | Type | Description |
|---|---|---|
usuario_id | int | Foreign key linking the entry to a registered user |
pokemon_id | int | National Pokédex number (used for deduplication and removal) |
pokemon_nombre | str | Pokémon name slug (e.g. charizard) |
pokemon_imagen | str | Absolute sprite URL (e.g. https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/6.png) |
pokemon_tipos | str | JSON-encoded list of type slugs (e.g. '["fire", "flying"]') decoded at render time by the parse_tipos filter |