# lawvia/pokeboi-v2 architecture

> Architecture diagram of the GitHub repository lawvia/pokeboi-v2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lawvia/pokeboi-v2
- Repository: https://github.com/lawvia/pokeboi-v2

## Overview

##### Project type and purpose
- This is a single-page, front-end React/TypeScript application built with Vite and Tailwind CSS.
- Purpose: A Poké-style interface (“Pokeboi V2”) that lets users view Pokémon data, catch and manage a party, battle, and view statistics.
- No back-end server or database is present—it operates on static data files under src/data and uses browser storage.

##### File structure
- Top-level configuration: vite.config.ts, tsconfig.json variants, tailwind.config.js, postcss.config.js, eslint.config.js.
- Entry point: index.html → main.tsx.
- Core application code under src:
- pages: high-level views (CatchPage, BattlePage, StatisticsPage)
- components: reusable UI organized by feature (pokemon, battle, catch, statistics, common, layout)
- hooks: custom React hooks encapsulating logic (useEncounter, useCatchPokemon, useStatisticsData, etc.)
- data: static data files (pokemon list, legendaryPokemon)
- utils: helper functions (battle logic, date formatting, localStorage wrapper, inventory management)
- types: TypeScript interfaces for Pokemon, party, statistics.
- styles: global CSS and utility classes.
- No server, but browser localStorage acts as a persistent store for caught Pokémon.

##### README for additional insights
- Confirms feature set: starter/legendary Pokémon, catching and party management, battling, statistics.
- Live demo link implies a static-hosted build.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser and Entry
    Browser["Browser Container"]:::external --> IndexHTML["index.html"]:::pages
    IndexHTML --> Main["src/main.tsx"]:::pages
    Main --> App["src/App.tsx"]:::pages

    %% Pages Layer
    subgraph "Pages"
        direction TB
        CatchPage["CatchPage"]:::pages
        BattlePage["BattlePage"]:::pages
        StatisticsPage["StatisticsPage"]:::pages
    end

    App -->|"routes to"| CatchPage
    App -->|"routes to"| BattlePage
    App -->|"routes to"| StatisticsPage

    %% Components Layer
    subgraph "Components"
        direction TB
        subgraph "Layout Components"
            MainLayout["MainLayout"]:::components
            Sidebar["Sidebar"]:::components
            NavLink["NavLink"]:::components
        end
        subgraph "Pokemon Components"
            PokemonGrid["PokemonGrid"]:::components
            PokemonDetail["PokemonDetail"]:::components
            PokemonCard["PokemonCard"]:::components
            PokemonStats["PokemonStats"]:::components
            PokemonTypeTag["PokemonTypeTag"]:::components
        end
        subgraph "Catch Components"
            CatchAnimation["CatchAnimation"]:::components
            WildPokemonArea["WildPokemonArea"]:::components
            PartyPokemonCard["PartyPokemonCard"]:::components
            RenameModal["RenameModal"]:::components
        end
        subgraph "Battle Components"
            BattleArena["BattleArena"]:::components
            PokemonSelector["PokemonSelector"]:::components
            BattleResult["BattleResult"]:::components
        end
        subgraph "Statistics Components"
            StatisticsGrid["StatisticsGrid"]:::components
            StatisticsCharts["StatisticsCharts"]:::components
            BattleChart["BattleChart"]:::components
            StatCard["StatCard"]:::components
        end
        subgraph "Common Components"
            SearchBar["SearchBar"]:::components
        end
    end

    CatchPage -->|"renders"| MainLayout
    BattlePage -->|"renders"| MainLayout
    StatisticsPage -->|"renders"| MainLayout

    %% Pages to Feature Components
    CatchPage -->|"uses"| PokemonGrid
    CatchPage -->|"uses"| PokemonDetail
    CatchPage -->|"uses"| CatchAnimation
    CatchPage -->|"uses"| WildPokemonArea

    BattlePage -->|"uses"| BattleArena
    BattlePage -->|"uses"| PokemonSelector
    BattlePage -->|"uses"| BattleResult

    StatisticsPage -->|"uses"| StatisticsGrid
    StatisticsPage -->|"uses"| StatisticsCharts

    %% Components to Logic Layer
    subgraph "Logic Layer"
        direction TB
        subgraph "Hooks"
            useEncounter["useEncounter Hook"]:::logic
            useCatchPokemon["useCatchPokemon Hook"]:::logic
            useStatisticsData["useStatisticsData Hook"]:::logic
            useMediaQuery["useMediaQuery Hook"]:::logic
        end
        subgraph "Utility Services"
            BattleLogic["battle.ts"]:::logic
            DateUtil["date.ts"]:::logic
            Inventory["inventory.ts"]:::logic
            LocalStorageWrapper["localStorage.ts"]:::logic
        end
    end

    PokemonGrid -->|"getPokemonList()"| useEncounter
    CatchAnimation -->|"onCatchClick()"| useCatchPokemon
    StatisticsCharts -->|"fetchStats()"| useStatisticsData
    MainLayout -->|"responsive checks"| useMediaQuery

    useEncounter --> BattleLogic
    useCatchPokemon --> Inventory
    useCatchPokemon --> LocalStorageWrapper
    useStatisticsData --> LocalStorageWrapper
    useStatisticsData --> DateUtil
    BattleArena -->|"simulateBattle()"| BattleLogic

    %% Data & Storage Layer
    subgraph "Data & Storage"
        direction TB
        StaticPokemon["pokemon.ts"]:::data
        LegendaryPokemon["legendaryPokemon.ts"]:::data
        LocalStorage["localStorage"]:::data
    end

    BattleLogic --> StaticPokemon
    useEncounter --> StaticPokemon
    useEncounter --> LegendaryPokemon
    LocalStorageWrapper --> LocalStorage

    %% User Interaction Flow
    PokemonCard -->|"onSelect()"| useCatchPokemon
    useCatchPokemon -->|"saveParty()"| LocalStorage
    LocalStorage -->|"loadParty()"| useCatchPokemon
    useCatchPokemon -->|"update UI"| PokemonCard

    %% Click Events
    click IndexHTML "https://github.com/lawvia/pokeboi-v2/blob/master/index.html"
    click Main "https://github.com/lawvia/pokeboi-v2/blob/master/src/main.tsx"
    click App "https://github.com/lawvia/pokeboi-v2/blob/master/src/App.tsx"
    click CatchPage "https://github.com/lawvia/pokeboi-v2/blob/master/src/pages/CatchPage.tsx"
    click BattlePage "https://github.com/lawvia/pokeboi-v2/blob/master/src/pages/BattlePage.tsx"
    click StatisticsPage "https://github.com/lawvia/pokeboi-v2/blob/master/src/pages/StatisticsPage.tsx"
    click MainLayout "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/layout/MainLayout.tsx"
    click Sidebar "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/layout/Sidebar.tsx"
    click NavLink "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/layout/NavLink.tsx"
    click PokemonGrid "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/pokemon/PokemonGrid.tsx"
    click PokemonDetail "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/pokemon/PokemonDetail.tsx"
    click PokemonCard "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/pokemon/PokemonCard.tsx"
    click PokemonStats "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/pokemon/PokemonStats.tsx"
    click PokemonTypeTag "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/pokemon/PokemonTypeTag.tsx"
    click CatchAnimation "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/catch/CatchAnimation.tsx"
    click WildPokemonArea "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/catch/WildPokemonArea.tsx"
    click PartyPokemonCard "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/catch/PartyPokemonCard.tsx"
    click RenameModal "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/catch/RenameModal.tsx"
    click BattleArena "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/battle/BattleArena.tsx"
    click PokemonSelector "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/battle/PokemonSelector.tsx"
    click BattleResult "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/battle/BattleResult.tsx"
    click StatisticsGrid "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/statistics/StatisticsGrid.tsx"
    click StatisticsCharts "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/statistics/StatisticsCharts.tsx"
    click BattleChart "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/statistics/BattleChart.tsx"
    click StatCard "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/statistics/StatCard.tsx"
    click SearchBar "https://github.com/lawvia/pokeboi-v2/blob/master/src/components/common/SearchBar.tsx"
    click useEncounter "https://github.com/lawvia/pokeboi-v2/blob/master/src/hooks/useEncounter.ts"
    click useCatchPokemon "https://github.com/lawvia/pokeboi-v2/blob/master/src/hooks/useCatchPokemon.ts"
    click useStatisticsData "https://github.com/lawvia/pokeboi-v2/blob/master/src/hooks/useStatisticsData.ts"
    click useMediaQuery "https://github.com/lawvia/pokeboi-v2/blob/master/src/hooks/useMediaQuery.ts"
    click BattleLogic "https://github.com/lawvia/pokeboi-v2/blob/master/src/utils/battle.ts"
    click DateUtil "https://github.com/lawvia/pokeboi-v2/blob/master/src/utils/date.ts"
    click Inventory "https://github.com/lawvia/pokeboi-v2/blob/master/src/utils/inventory.ts"
    click LocalStorageWrapper "https://github.com/lawvia/pokeboi-v2/blob/master/src/utils/localStorage.ts"
    click StaticPokemon "https://github.com/lawvia/pokeboi-v2/blob/master/src/data/pokemon.ts"
    click LegendaryPokemon "https://github.com/lawvia/pokeboi-v2/blob/master/src/data/legendaryPokemon.ts"

    %% Styles
    classDef pages fill:#D0E8FF,stroke:#004E96
    classDef components fill:#E3F9E5,stroke:#2D6A4F
    classDef logic fill:#FFF3BF,stroke:#D39E00
    classDef data fill:#FFF4D6,stroke:#FFB703
    classDef external fill:#E8E8E8,stroke:#888888,stroke-dasharray: 5 5
```
