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.

This page covers everything you need to install and configure Pokédex Web App for local development. You will find the exact system requirements, instructions for creating an isolated Python environment, a breakdown of every dependency, details on how the SQLite database is initialised automatically, and guidance on securing the Flask secret key before deploying to production.

Prerequisites

Before you begin, make sure the following are available on your system:
  • Python 3.8 or later — the app uses f-strings, sqlite3, and other features that require Python 3.8+. Verify with python --version.
  • pip — Python’s package installer, bundled with all modern Python distributions.
  • git — required to clone the repository from GitHub.
  • Internet access — needed on first run to fetch all 1025 Pokémon from https://pokeapi.co/api/v2. Subsequent starts work fully offline from the local SQLite cache.

Virtual Environment Setup

Always install the project inside a virtual environment to avoid conflicts with other Python projects on your system.
python -m venv venv
venv\Scripts\activate
You should see (venv) prepended to your command prompt, indicating the environment is active. To deactivate later, run deactivate.

Dependencies

Install all dependencies in one step:
pip install -r requirements.txt
The requirements.txt file specifies four packages:
PackageRole in this project
flaskCore web framework. Handles routing, the request/response cycle, session management, and Jinja2 template rendering for all pages (index.html, detalle.html, equipo.html, etc.).
requestsHTTP client used by the PokeAPI service class to call https://pokeapi.co/api/v2 — both for the bulk 1025-Pokémon download on first run and for individual lookups when a Pokémon is not found in the cache.
gunicornProduction-grade WSGI server. Defined in Procfile as web: gunicorn application:application so the app can be deployed to any compatible platform without code changes.
werkzeugSecurity and utility library bundled with Flask. Used for password hashing and verification in the Usuario model to safely store and authenticate user credentials.

Database Initialisation

No manual database setup is required. When the Flask application starts, init_db() is called automatically inside an application context:
# application.py
with application.app_context():
    init_db()
init_db() (defined in models/database.py) connects to pokedex.db at the project root and runs CREATE TABLE IF NOT EXISTS statements for four tables:
TablePurpose
usuariosStores registered user accounts (username + hashed password).
equiposStores each user’s team — up to 6 Pokémon with their ID, name, image URL, and types.
cache_pokemonLocal cache of all 1025 Pokémon fetched from PokéAPI (id, name, types, height, weight, image, stats).
pokedex_usuarioRecords which Pokémon each user has viewed, with a timestamp.
If pokedex.db does not exist, SQLite creates it automatically. The schema is fully idempotent — restarting the app never drops or modifies existing data.

Secret Key Configuration

The Flask app sets a default secret key used to cryptographically sign session cookies:
# application.py
application.secret_key = "pokesecretkey123"
This hardcoded value is only suitable for local development. For any internet-facing or production deployment, replace it with a strong randomly generated key. Use Python’s secrets module to generate one:
import secrets
print(secrets.token_hex(32))
Copy the printed value and set it in application.py:
application.secret_key = "<your-generated-key>"
Store the key securely — for example, as an environment variable — and never commit it to version control.

Production Deployment

Pokédex Web App ships with a Procfile that configures Gunicorn as the production WSGI server:
web: gunicorn application:application
The format is gunicorn <module>:<wsgi_callable>. Here, application (the module, i.e. application.py) exposes the Flask instance also named application. To start the production server manually, run:
gunicorn application:application
Gunicorn will bind to 0.0.0.0:8000 by default and handle concurrent requests using its pre-fork worker model, making it safe and performant for real traffic.
The Flask development server (application.run(debug=True)) is configured in application.py’s __main__ block. Never run with debug=True in production. Debug mode enables an interactive in-browser debugger that allows arbitrary code execution on your server. Always use Gunicorn (or another production WSGI server) for any publicly accessible deployment.

Build docs developers (and LLMs) love