# khalidh1b/pokedex architecture

> Architecture diagram of the GitHub repository khalidh1b/pokedex, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khalidh1b/pokedex
- Repository: https://github.com/khalidh1b/pokedex

## Overview

#### 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: [`src/routes/router.tsx`](https://github.com/khalidh1b/pokedex/blob/main/src/routes/router.tsx) (Route map), [`src/context/pokemonContext.tsx`](https://github.com/khalidh1b/pokedex/blob/main/src/context/pokemonContext.tsx) (Pokémon context), [`src/components/main/main.tsx`](https://github.com/khalidh1b/pokedex/blob/main/src/components/main/main.tsx) (Catalog main), [`src/components/pokemon-detail/pokemon-detail.tsx`](https://github.com/khalidh1b/pokedex/blob/main/src/components/pokemon-detail/pokemon-detail.tsx) (Pokémon detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime &amp; Deployment"]
  node_vite{{"Vite runtime<br/>build runtime<br/>[vite.config.ts]"}}
  node_firebase_hosting{{"Firebase hosting<br/>deployment target<br/>[firebase.json]"}}
  node_deploy_workflow["Deploy workflow<br/>CI deployment<br/>[deploy.yml]"]
end

subgraph group_app["Application Shell"]
  node_entry["React entry<br/>bootstrap<br/>[main.tsx]"]
  node_router["Route map<br/>routing<br/>[router.tsx]"]
  node_layout["Shared layout<br/>application shell<br/>[layout.tsx]"]
end

subgraph group_state["Pokémon Data Pipeline"]
  node_pokemon_context[("Pokémon context<br/>state boundary<br/>[pokemonContext.tsx]")]
  node_context_hook["Context consumer hook<br/>state access"]
  node_fetch_hook["PokéAPI fetch hook<br/>data acquisition<br/>[useFetchPokemon.ts]"]
  node_search_hook["Search transform<br/>catalog transform"]
  node_filter_hook["Type filter transform<br/>catalog transform<br/>[useHandleFilter.ts]"]
  node_sort_hook["Sort transform<br/>catalog transform"]
  node_pokemon_types["Pokémon contracts<br/>domain types<br/>[pokemon.ts]"]
end

subgraph group_ui["Catalog &amp; Detail UI"]
  node_catalog["Catalog main<br/>catalog orchestration<br/>[main.tsx]"]
  node_infinite_scroll["Infinite scrolling<br/>list progression"]
  node_catalog_controls["Filter &amp; sort controls<br/>catalog controls<br/>[filter.tsx]"]
  node_card["Pokémon card<br/>item presentation<br/>[card.tsx]"]
  node_header["Header search<br/>global navigation<br/>[header.tsx]"]
  node_detail["Pokémon detail<br/>detail view<br/>[pokemon-detail.tsx]"]
  node_not_found["Pokémon not found<br/>fallback view"]
end

node_vite -->|"serves"| node_entry
node_entry -->|"mounts"| node_router
node_router -->|"renders within"| node_layout
node_router -->|"catalog route"| node_catalog
node_router -->|"detail route"| node_detail
node_router -.->|"unmatched lookup"| node_not_found
node_fetch_hook -->|"populates"| node_pokemon_context
node_pokemon_types -.->|"types state"| node_pokemon_context
node_context_hook -->|"consumes"| node_pokemon_context
node_pokemon_context -->|"source collection"| node_search_hook
node_search_hook -->|"searched collection"| node_filter_hook
node_filter_hook -->|"filtered collection"| node_sort_hook
node_sort_hook -->|"visible collection"| node_catalog
node_catalog_controls -->|"updates filters and order"| node_pokemon_context
node_catalog -->|"progresses list"| node_infinite_scroll
node_catalog -->|"renders items"| node_card
node_card -->|"selects Pokémon"| node_detail
node_header -->|"navigates"| node_router
node_detail -->|"reads Pokémon state"| node_context_hook
node_deploy_workflow -->|"deploys"| node_firebase_hosting

click node_vite "https://github.com/khalidh1b/pokedex/blob/main/vite.config.ts"
click node_entry "https://github.com/khalidh1b/pokedex/blob/main/src/main.tsx"
click node_router "https://github.com/khalidh1b/pokedex/blob/main/src/routes/router.tsx"
click node_layout "https://github.com/khalidh1b/pokedex/blob/main/src/layout/layout.tsx"
click node_pokemon_context "https://github.com/khalidh1b/pokedex/blob/main/src/context/pokemonContext.tsx"
click node_context_hook "https://github.com/khalidh1b/pokedex/blob/main/src/hooks/usePokemonContext.ts"
click node_fetch_hook "https://github.com/khalidh1b/pokedex/blob/main/src/hooks/useFetchPokemon.ts"
click node_search_hook "https://github.com/khalidh1b/pokedex/blob/main/src/hooks/useSearchPokemon.ts"
click node_filter_hook "https://github.com/khalidh1b/pokedex/blob/main/src/hooks/useHandleFilter.ts"
click node_sort_hook "https://github.com/khalidh1b/pokedex/blob/main/src/hooks/useHandleSorting.ts"
click node_pokemon_types "https://github.com/khalidh1b/pokedex/blob/main/src/types/pokemon.ts"
click node_catalog "https://github.com/khalidh1b/pokedex/blob/main/src/components/main/main.tsx"
click node_infinite_scroll "https://github.com/khalidh1b/pokedex/blob/main/src/hooks/useInfiniteScrolling.ts"
click node_catalog_controls "https://github.com/khalidh1b/pokedex/blob/main/src/components/ui/filter.tsx"
click node_card "https://github.com/khalidh1b/pokedex/blob/main/src/components/ui/card.tsx"
click node_header "https://github.com/khalidh1b/pokedex/blob/main/src/components/header/header.tsx"
click node_detail "https://github.com/khalidh1b/pokedex/blob/main/src/components/pokemon-detail/pokemon-detail.tsx"
click node_not_found "https://github.com/khalidh1b/pokedex/blob/main/src/components/pokemon-not-found/pokemon-not-found.tsx"
click node_firebase_hosting "https://github.com/khalidh1b/pokedex/blob/main/firebase.json"
click node_deploy_workflow "https://github.com/khalidh1b/pokedex/blob/main/.github/workflows/deploy.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_vite,node_firebase_hosting,node_deploy_workflow toneBlue
class node_entry,node_router,node_layout toneAmber
class node_pokemon_context,node_context_hook,node_fetch_hook,node_search_hook,node_filter_hook,node_sort_hook,node_pokemon_types toneMint
class node_catalog,node_infinite_scroll,node_catalog_controls,node_card,node_header,node_detail,node_not_found toneRose
```

## Components

### Runtime & Deployment

- [Vite runtime](https://github.com/khalidh1b/pokedex/blob/main/vite.config.ts): build runtime · `vite.config.ts`
- [Firebase hosting](https://github.com/khalidh1b/pokedex/blob/main/firebase.json): deployment target · `firebase.json`
- [Deploy workflow](https://github.com/khalidh1b/pokedex/blob/main/.github/workflows/deploy.yml): CI deployment · `.github/workflows/deploy.yml`

### Application Shell

- [React entry](https://github.com/khalidh1b/pokedex/blob/main/src/main.tsx): bootstrap · `src/main.tsx`
- [Route map](https://github.com/khalidh1b/pokedex/blob/main/src/routes/router.tsx): routing · Separates catalog and detail navigation. · `src/routes/router.tsx`
- [Shared layout](https://github.com/khalidh1b/pokedex/blob/main/src/layout/layout.tsx): application shell · `src/layout/layout.tsx`

### Pokémon Data Pipeline

- [Pokémon context](https://github.com/khalidh1b/pokedex/blob/main/src/context/pokemonContext.tsx): state boundary · Owns Pokémon data and catalog UI state. · `src/context/pokemonContext.tsx`
- [Context consumer hook](https://github.com/khalidh1b/pokedex/blob/main/src/hooks/usePokemonContext.ts): state access · `src/hooks/usePokemonContext.ts`
- [PokéAPI fetch hook](https://github.com/khalidh1b/pokedex/blob/main/src/hooks/useFetchPokemon.ts): data acquisition · Retrieves and normalizes remote Pokémon responses. · `src/hooks/useFetchPokemon.ts`
- [Search transform](https://github.com/khalidh1b/pokedex/blob/main/src/hooks/useSearchPokemon.ts): catalog transform · `src/hooks/useSearchPokemon.ts`
- [Type filter transform](https://github.com/khalidh1b/pokedex/blob/main/src/hooks/useHandleFilter.ts): catalog transform · `src/hooks/useHandleFilter.ts`
- [Sort transform](https://github.com/khalidh1b/pokedex/blob/main/src/hooks/useHandleSorting.ts): catalog transform · `src/hooks/useHandleSorting.ts`
- [Pokémon contracts](https://github.com/khalidh1b/pokedex/blob/main/src/types/pokemon.ts): domain types · `src/types/pokemon.ts`

### Catalog & Detail UI

- [Catalog main](https://github.com/khalidh1b/pokedex/blob/main/src/components/main/main.tsx): catalog orchestration · Coordinates visible items and loading behavior. · `src/components/main/main.tsx`
- [Infinite scrolling](https://github.com/khalidh1b/pokedex/blob/main/src/hooks/useInfiniteScrolling.ts): list progression · `src/hooks/useInfiniteScrolling.ts`
- [Filter & sort controls](https://github.com/khalidh1b/pokedex/blob/main/src/components/ui/filter.tsx): catalog controls · `src/components/ui/filter.tsx`
- [Pokémon card](https://github.com/khalidh1b/pokedex/blob/main/src/components/ui/card.tsx): item presentation · `src/components/ui/card.tsx`
- [Header search](https://github.com/khalidh1b/pokedex/blob/main/src/components/header/header.tsx): global navigation · `src/components/header/header.tsx`
- [Pokémon detail](https://github.com/khalidh1b/pokedex/blob/main/src/components/pokemon-detail/pokemon-detail.tsx): detail view · `src/components/pokemon-detail/pokemon-detail.tsx`
- [Pokémon not found](https://github.com/khalidh1b/pokedex/blob/main/src/components/pokemon-not-found/pokemon-not-found.tsx): fallback view · `src/components/pokemon-not-found/pokemon-not-found.tsx`

## Connections

- 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
