Skip to main content

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.

The Pokédex index page (GET /) is the main entry point of the application, presenting all 1025 Pokémon as a responsive card grid. Each card shows the Pokémon’s sprite, National Dex number, name, and type badges. From here you can search for any Pokémon by name or instantly narrow the grid to a single type — no page reload needed beyond submitting the filter form.

Query Parameters

The index route accepts two optional query parameters that control which Pokémon are displayed.
ParameterDescriptionExample value
busquedaCase-insensitive substring match against Pokémon nameschar
tipoExact type slug to filter byfire

Name Search — ?busqueda=<name>

Passing busqueda calls Pokedex.buscar_por_nombre(), which iterates over every cached Pokémon and returns those whose nombre contains the query string (lowercased for comparison). The match is a substring check, so short queries return broad results.
http://localhost:5000/?busqueda=char
This returns Charmander, Charmeleon, Charizard, and any other Pokémon whose name contains char.

Type Filter — ?tipo=<type>

Passing tipo calls PokeAPI.obtener_por_tipo(), which queries the SQLite cache_pokemon table directly with a LIKE clause against the JSON-encoded tipos column. The result set contains only Pokémon that have the requested type (primary or secondary).
http://localhost:5000/?tipo=fire

Supported Pokémon Types

All 18 standard Pokémon types are available as filter buttons in the UI and as valid tipo values in the URL:
TypeTypeType
normalfirewater
electricgrassice
fightingpoisonground
flyingpsychicbug
rockghostdragon
darksteelfairy

Caching Logic

On the very first request to /, the application checks whether the cache_pokemon table is populated by calling PokeAPI.validacion(). This method runs SELECT COUNT(*) FROM cache_pokemon — if the count is zero, the cache is empty and the app must fetch data from PokéAPI.
# services/poke_api.py
def validacion(self):
    conn = get_connection()
    count = conn.execute("SELECT COUNT(*) FROM cache_pokemon").fetchone()[0]
    if count == 0:
        return False
    else:
        return True
When the cache is empty (validacion() returns False), PokeAPI.obtener_lista_pokemones(limite=1025) is called. It fetches the full list of 1025 Pokémon from https://pokeapi.co/api/v2/pokemon?limit=1025, then fetches each individual Pokémon’s data, constructs a Pokemon object, and persists everything to cache_pokemon via INSERT OR IGNORE. On every subsequent request, PokeAPI.validacion() returns True and PokeAPI.cargar_desde_db() reads all rows from cache_pokemon into memory — no outbound HTTP calls are made:
# services/poke_api.py
def cargar_desde_db(self):
    conn = get_connection()
    rows = conn.execute("SELECT * FROM cache_pokemon").fetchall()
    conn.close()
    pokedex = Pokedex()
    for row in rows:
        pokemon = Pokemon(
            id=row["id"],
            nombre=row["nombre"],
            tipos=json.loads(row["tipos"]),
            ...
        )
        pokedex.agregar_pokemon(pokemon)
    return pokedex
Searching and type filtering are mutually exclusive. If both busqueda and tipo are present in the URL, the name search takes priority — the tipo parameter is ignored entirely. Only one filter is applied per request.
Bookmark type filter URLs like http://localhost:5000/?tipo=dragon for instant one-click access to your favourite type. You can share these links directly — no login required to browse the Pokédex.

Build docs developers (and LLMs) love