How khalidh1b/pokedex works
Purpose and Runtime
Pokedex is a React/TypeScript single-page application for browsing Pokémon, searching/filtering/sorting the catalog, and viewing detail pages with PokéAPI-backed data. It runs through Vite in development and is configured for Firebase hosting deployment. Key runtime entry/configuration paths: src/main.tsx, vite.config.ts, firebase.json.
Application Bootstrap and Routing
src/main.tsx mounts the React tree. Routing is centralized in src/routes/router.tsx, separating catalog and Pokémon-detail navigation concerns. The shared shell in src/layout/layout.tsx provides the persistent page structure around route content.
Shared Pokémon State Boundary
src/context/pokemonContext.tsx is the application state boundary for Pokémon data and catalog UI state. Components consume it through src/hooks/usePokemonContext.ts, avoiding direct context coupling across the UI. Domain contracts reside in src/types/pokemon.ts and src/types/tab-content.ts.
Data Acquisition and Catalog Pipeline
src/hooks/useFetchPokemon.ts owns external PokéAPI retrieval and converts remote Pokémon responses into state consumed by the catalog and detail views. Catalog transformations are isolated into focused hooks: search in src/hooks/useSearchPokemon.ts, type filtering in src/hooks/useHandleFilter.ts, and ordering in src/hooks/useHandleSorting.ts. This forms the primary flow: PokéAPI → context state → transformed visible collection → UI.
Main Catalog Experience
src/components/main/main.tsx orchestrates catalog rendering and user-facing loading behavior. Infinite-list progression is encapsulated by src/hooks/useInfiniteScrolling.ts; item presentation is in src/components/ui/card.tsx, with loading placeholders from src/components/ui/card-skeleton.tsx. Filtering and sorting controls are represented by src/components/ui/filter.tsx and src/components/ui/sort.tsx.
Navigation, Detail, and Empty States
The global navigation and search-oriented controls are housed in src/components/header/header.tsx. Selecting a catalog item routes to src/components/pokemon-detail/pokemon-detail.tsx, which renders detailed Pokémon information. Failed or unmatched lookup/navigation cases are handled by src/components/pokemon-not-found/pokemon-not-found.tsx.
Presentation System and Deployment
Reusable primitives and visual domain mapping live under src/components/ui, especially src/components/ui/button.tsx, src/components/ui/input.tsx, and src/components/ui/theme.tsx. Theme state/behavior is isolated in src/hooks/useThemeToggle.ts; global styling begins at src/index.css. Framer Motion supports UI animation, while Firebase deployment is automated through .github/workflows/deploy.yml and project selection is defined in .firebaserc.
Main entry points: router.tsx Route map · pokemonContext.tsx Pokémon context · main.tsx Catalog main · pokemon-detail.tsx Pokémon detail
Components 20
Runtime & Deployment
- Vite runtime
vite.config.ts - Firebase hosting
firebase.json - Deploy workflow
.github/workflows/deploy.yml
Application Shell
- React entry
src/main.tsx - Route map · Separates catalog and detail navigation.
src/routes/router.tsx - Shared layout
src/layout/layout.tsx
Pokémon Data Pipeline
- Pokémon context · Owns Pokémon data and catalog UI state.
src/context/pokemonContext.tsx - Context consumer hook
src/hooks/usePokemonContext.ts - PokéAPI fetch hook · Retrieves and normalizes remote Pokémon responses.
src/hooks/useFetchPokemon.ts - Search transform
src/hooks/useSearchPokemon.ts - Type filter transform
src/hooks/useHandleFilter.ts - Sort transform
src/hooks/useHandleSorting.ts - Pokémon contracts
src/types/pokemon.ts
Catalog & Detail UI
- Catalog main · Coordinates visible items and loading behavior.
src/components/main/main.tsx - Infinite scrolling
src/hooks/useInfiniteScrolling.ts - Filter & sort controls
src/components/ui/filter.tsx - Pokémon card
src/components/ui/card.tsx - Header search
src/components/header/header.tsx - Pokémon detail
src/components/pokemon-detail/pokemon-detail.tsx - Pokémon not found
src/components/pokemon-not-found/pokemon-not-found.tsx
Connections 20
- Vite runtime → React entry: serves
- React entry → Route map: mounts
- Route map → Shared layout: renders within
- Route map → Catalog main: catalog route
- Route map → Pokémon detail: detail route
- Route map → Pokémon not found: unmatched lookup
- PokéAPI fetch hook → Pokémon context: populates
- Pokémon contracts → Pokémon context: types state
- Context consumer hook → Pokémon context: consumes
- Pokémon context → Search transform: source collection
- Search transform → Type filter transform: searched collection
- Type filter transform → Sort transform: filtered collection
- Sort transform → Catalog main: visible collection
- Filter & sort controls → Pokémon context: updates filters and order
- Catalog main → Infinite scrolling: progresses list
- Catalog main → Pokémon card: renders items
- Pokémon card → Pokémon detail: selects Pokémon
- Header search → Route map: navigates
- Pokémon detail → Context consumer hook: reads Pokémon state
- Deploy workflow → Firebase hosting: deploys