How hildelio/js-developer-pokedex works
Project type and purpose
• This is a single-page, front-end Pokedex application built in vanilla JavaScript, HTML and CSS.
• It loads in the browser (index.html + CSS), fetches Pokémon data from an external API (pokeapi.co), applies a client-side data model, and renders results dynamically.
File structure
• index.html: the HTML entry point and root of the document.
• assets/css/global.css & pokedex.css: styling rules for layout and Pokémon-specific UI.
• assets/js/main.js: orchestrates user interactions, ties together view updates and service/model calls.
• assets/js/poke-api.js: encapsulates all HTTP calls to the external Pokémon API (e.g., using fetch).
• assets/js/pokemon-model.js: defines the in-memory data structures (e.g., Pokemon class/object) and any mapping or transformation logic.
Key insights from the README
• Very concise title: “Trilha JS Developer – Pokedex”
• No built-in backend or database; relies entirely on a third-party REST API.
Components
a. Browser (Client)
• index.html (static entry point)
• CSS modules (global.css, pokedex.css)
• JavaScript modules (main.js, poke-api.js, pokemon-model.js)
b. Presentation Layer (main.js + DOM)
• Listens for user events (search, pagination, click on a Pokémon)
• Updates view templates or DOM elements
c. Service Layer (poke-api.js)
• Exposes functions like getPokemonList(), getPokemonDetails(id)
• Uses Fetch API to call https://pokeapi.co
d. Data Model Layer (pokemon-model.js)
• Defines Pokemon entity with fields (id, name, stats, sprites)
• Transforms raw JSON into your front-end model
e. External API
• pokeapi.co (public REST endpoints)
f. In-memory Store
• Temporary cache of loaded Pokémon to avoid re-fetching
Relationships and interactions
1. User interacts with UI in Browser.
2. main.js captures the event (e.g., “load list” or “show details”).
3. main.js calls the Service Layer function in poke-api.js.
4. poke-api.js issues HTTP request to pokeapi.co and returns JSON.
5. pokemon-model.js transforms JSON into a JS object (Pokemon).
6. main.js receives the model instance(s), updates the DOM (view).
7. CSS styles are applied immediately by the browser.
Architectural patterns & principles
• Separation of concerns:
• View (HTML + CSS)
• Orchestration/Controller (main.js)
• Service/API wrapper (poke-api.js)
• Domain model (pokemon-model.js)
• Client-side MVC/MV* flavor (thin view layer, simple controller + model).
• Stateless on server side; state is ephemeral in the browser.