# mosh-hamedani/game-hub architecture

> Architecture diagram of the GitHub repository mosh-hamedani/game-hub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mosh-hamedani/game-hub
- Repository: https://github.com/mosh-hamedani/game-hub

## Overview

##### Project type and purpose
- GameHub is a single-page application (SPA) built with React and TypeScript, bundled with Vite.
- It is a front-end video-game discovery tool that queries the external RAWG API to fetch game data by platform, genre, search term, etc.

##### File structure
Top-level files & directories:
- index.html, public/ – static entry point and assets
- src/ – application source code
- components/ – reusable UI pieces (NavBar, GameCard, selectors, skeletons)
- hooks/ – custom React hooks (useGames, useGenres, usePlatforms, useData)
- services/ – API client (api-client.ts), image URL builder
- data/ – static lookup data (genres.ts, platforms.ts)
- theme.ts, App.tsx, main.tsx, App.css, index.css
- vite.config.ts, tsconfig.json – build configuration

##### README for additional insights
- Confirms front-end focus, use of React, TypeScript, CSS, and connectivity to RAWG via an API key.
- No backend code; all data comes from RAWG’s REST API.

##### Detail
- Flow of the API key through api-client.ts to the RAWG endpoint.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser / Client
    subgraph "Browser / Client"
        IndexHTML["index.html"]:::client
        MainTSX["src/main.tsx"]:::client
    end

    %% Root React Application
    subgraph "Root React Application"
        AppTSX["src/App.tsx"]:::root
        AppCSS["src/App.css"]:::root
        IndexCSS["src/index.css"]:::root
    end

    %% UI Components
    subgraph "UI Components"
        NavBar["NavBar"]:::ui
        GameGrid["GameGrid"]:::ui
        GameCard["GameCard"]:::ui
        GameCardContainer["GameCardContainer"]:::ui
        GameCardSkeleton["GameCardSkeleton"]:::ui
        PlatformSelector["PlatformSelector"]:::ui
        SortSelector["SortSelector"]:::ui
        SearchInput["SearchInput"]:::ui
        GenreList["GenreList"]:::ui
        PlatformIconList["PlatformIconList"]:::ui
        CriticScore["CriticScore"]:::ui
        Emoji["Emoji"]:::ui
        GameHeading["GameHeading"]:::ui
        ColorModeSwitch["ColorModeSwitch"]:::ui
    end

    %% Custom Hooks
    subgraph "Custom Hooks"
        useData["useData.ts"]:::hooks
        useGames["useGames.ts"]:::hooks
        useGenres["useGenres.ts"]:::hooks
        usePlatforms["usePlatforms.ts"]:::hooks
    end

    %% Services Layer
    subgraph "Services Layer"
        APIClient["api-client.ts"]:::service
        ImageURL["image-url.ts"]:::service
    end

    %% Static Lookup Data
    subgraph "Static Data"
        GenresData["genres.ts"]:::data
        PlatformsData["platforms.ts"]:::data
    end

    %% Theme / Styling
    Theme["theme.ts"]:::config

    %% Build Toolchain & Configuration
    subgraph "Build & Config"
        ViteConfig["vite.config.ts"]:::build
        TSConfig["tsconfig.json"]:::build
        TSNodeConfig["tsconfig.node.json"]:::build
        PackageJSON["package.json"]:::build
        PackageLock["package-lock.json"]:::build
        ViteEnv["src/vite-env.d.ts"]:::build
    end

    %% Public Assets & Hosting
    subgraph "Assets & Hosting"
        PublicAssets["public/"]:::assets
        SrcAssets["src/assets/"]:::assets
    end

    %% External RAWG API
    RAWG["RAWG REST API"]:::external

    %% Connections
    IndexHTML -->|bootsraps| MainTSX
    MainTSX -->|renders| AppTSX
    AppTSX -->|uses| NavBar
    AppTSX -->|uses| GameGrid
    NavBar -->|renders| SearchInput
    GameGrid -->|renders| GameCardContainer
    GameCardContainer -->|uses| GameCard
    GameCard -->|renders| GameCardSkeleton
    GameGrid -->|filters| PlatformSelector
    GameGrid -->|sorts| SortSelector
    GameGrid -->|genres| GenreList
    GameCard -->|decorates| PlatformIconList
    GameCard -->|shows| CriticScore
    GameCard -->|shows| Emoji
    GameCard -->|title| GameHeading
    AppTSX -->|toggles| ColorModeSwitch

    NavBar -->|calls| useData
    GameGrid -->|calls| useGames
    GenreList -->|calls| useGenres
    PlatformSelector -->|calls| usePlatforms

    useData -->|requests| APIClient
    useGames -->|requests| APIClient
    useGenres -->|requests| APIClient
    usePlatforms -->|requests| APIClient

    APIClient -->|fetches| RAWG
    ImageURL -->|builds URLs for| GameCard

    useData -->|loads| GenresData
    useData -->|loads| PlatformsData

    AppTSX -->|imports| Theme

    Theme -->|applies| AppCSS
    Theme -->|applies| IndexCSS

    ViteConfig -->|builds| MainTSX
    TSConfig -->|types| MainTSX
    TSNodeConfig -->|types| ViteConfig
    PackageJSON -->|defines deps| ViteConfig
    PackageLock -->|locks deps| PackageJSON
    ViteEnv -->|provides| APIClient

    ViteConfig -->|serves| PublicAssets
    ViteConfig -->|serves| SrcAssets

    PublicAssets -->|static files| IndexHTML

    %% Click Events
    click IndexHTML "https://github.com/mosh-hamedani/game-hub/blob/main/index.html"
    click MainTSX "https://github.com/mosh-hamedani/game-hub/blob/main/src/main.tsx"
    click AppTSX "https://github.com/mosh-hamedani/game-hub/blob/main/src/App.tsx"
    click AppCSS "https://github.com/mosh-hamedani/game-hub/blob/main/src/App.css"
    click IndexCSS "https://github.com/mosh-hamedani/game-hub/blob/main/src/index.css"
    click NavBar "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/NavBar.tsx"
    click GameGrid "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/GameGrid.tsx"
    click GameCard "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/GameCard.tsx"
    click GameCardContainer "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/GameCardContainer.tsx"
    click GameCardSkeleton "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/GameCardSkeleton.tsx"
    click PlatformSelector "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/PlatformSelector.tsx"
    click SortSelector "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/SortSelector.tsx"
    click SearchInput "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/SearchInput.tsx"
    click GenreList "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/GenreList.tsx"
    click PlatformIconList "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/PlatformIconList.tsx"
    click CriticScore "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/CriticScore.tsx"
    click Emoji "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/Emoji.tsx"
    click GameHeading "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/GameHeading.tsx"
    click ColorModeSwitch "https://github.com/mosh-hamedani/game-hub/blob/main/src/components/ColorModeSwitch.tsx"
    click useData "https://github.com/mosh-hamedani/game-hub/blob/main/src/hooks/useData.ts"
    click useGames "https://github.com/mosh-hamedani/game-hub/blob/main/src/hooks/useGames.ts"
    click useGenres "https://github.com/mosh-hamedani/game-hub/blob/main/src/hooks/useGenres.ts"
    click usePlatforms "https://github.com/mosh-hamedani/game-hub/blob/main/src/hooks/usePlatforms.ts"
    click APIClient "https://github.com/mosh-hamedani/game-hub/blob/main/src/services/api-client.ts"
    click ImageURL "https://github.com/mosh-hamedani/game-hub/blob/main/src/services/image-url.ts"
    click GenresData "https://github.com/mosh-hamedani/game-hub/blob/main/src/data/genres.ts"
    click PlatformsData "https://github.com/mosh-hamedani/game-hub/blob/main/src/data/platforms.ts"
    click Theme "https://github.com/mosh-hamedani/game-hub/blob/main/src/theme.ts"
    click ViteConfig "https://github.com/mosh-hamedani/game-hub/blob/main/vite.config.ts"
    click TSConfig "https://github.com/mosh-hamedani/game-hub/blob/main/tsconfig.json"
    click TSNodeConfig "https://github.com/mosh-hamedani/game-hub/blob/main/tsconfig.node.json"
    click PackageJSON "https://github.com/mosh-hamedani/game-hub/blob/main/package.json"
    click PackageLock "https://github.com/mosh-hamedani/game-hub/blob/main/package-lock.json"
    click ViteEnv "https://github.com/mosh-hamedani/game-hub/blob/main/src/vite-env.d.ts"
    click PublicAssets "https://github.com/mosh-hamedani/game-hub/tree/main/public/"
    click SrcAssets "https://github.com/mosh-hamedani/game-hub/tree/main/src/assets/"

    %% Styles
    classDef client fill:#D0E7FF,stroke:#0366D6,color:#0366D6
    classDef root fill:#E8F5FF,stroke:#0366D6,color:#0366D6
    classDef ui fill:#CCE5FF,stroke:#004080,color:#004080
    classDef hooks fill:#DFFFE0,stroke:#3C763D,color:#3C763D
    classDef service fill:#FFF5CC,stroke:#8B6C00,color:#8B6C00
    classDef data fill:#E8FFE8,stroke:#2E8B57,color:#2E8B57
    classDef config fill:#F5E0FF,stroke:#6A0DAD,color:#6A0DAD
    classDef build fill:#F0F0F0,stroke:#606060,color:#606060
    classDef assets fill:#F8F0E3,stroke:#A0522D,color:#A0522D
    classDef external fill:#FFE5CC,stroke:#CC5200,color:#CC5200
```
