# erik-eei/mtg-deck-project architecture

> Architecture diagram of the GitHub repository erik-eei/mtg-deck-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/erik-eei/mtg-deck-project
- Repository: https://github.com/erik-eei/mtg-deck-project

## Overview

##### Main Components Overview

a. Frontend Architecture (React-based SPA):
- Present a clear component hierarchy with the following main sections:
- Pages Layer (top-level routes)
- Components Layer (reusable UI components)
- Utils Layer (services and handlers)
- Hooks Layer (custom React hooks)
- Assets Layer (static resources)

b. External Integration:
- Scryfall API connection for card data
- Local Storage integration for deck persistence

**[Pages Layer]**
- ↓
**[Components Layer]**
- ↓
**[Hooks & Utils Layer]**
- ↓
**[External Services]**

##### Key Relationships to Highlight

a. Data Flow:
- How card data flows from Scryfall API through the application
- Deck data persistence flow to/from local storage
- Demonstrate component communication patterns

b. Feature Modules:
- Deck Building Module
- DeckBuilder components
- Card selection and management
- Deck validation and storage

- Card Discovery Module
- Search functionality
- Card display and filtering
- Card detail viewing

- Settings Module
- Theme management
- Import/Export functionality
- User preferences

##### Specific Implementation Details

Technical aspects:

a. Custom Hooks Integration:
- useSearchCards → Scryfall API interaction
- useBackgroundBlur → UI effects
- useGetRandomCard → Card randomization
- useImagePreloader → Asset management

b. Utility Services:
- buildHandler
- cacheHandler
- deckHandler
- themeHandler
- usernameHandler

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef page fill:#3498db,color:white
    classDef component fill:#2ecc71,color:white
    classDef util fill:#f1c40f,color:black
    classDef hook fill:#9b59b6,color:white
    classDef external fill:#e74c3c,color:white
    classDef storage fill:#95a5a6,color:white
    
    %% Pages Layer
    subgraph Pages
        Home["Home Page"]:::page
        DeckBuilder["Deck Builder Page"]:::page
        Discover["Discover Page"]:::page
        Settings["Settings Page"]:::page
    end

    %% Components Layer
    subgraph DeckBuildingModule
        CardSelector["Card Selector"]:::component
        StatusBoard["Status Board"]:::component
        ManaCostGraph["Mana Cost Graph"]:::component
    end

    subgraph CardDiscoveryModule
        SearchComp["Search Component"]:::component
        CardDetail["Card Detail Modal"]:::component
        CardComp["Card Component"]:::component
    end

    subgraph SettingsModule
        ThemePicker["Theme Picker"]:::component
        ImportExport["Import/Export"]:::component
        UsernameChanger["Username Changer"]:::component
    end

    subgraph LayoutComponents
        Navbar["Navbar"]:::component
        Footer["Footer"]:::component
    end

    %% Hooks Layer
    subgraph CustomHooks
        useSearch["useSearchCards"]:::hook
        useBlur["useBackgroundBlur"]:::hook
        useRandom["useGetRandomCard"]:::hook
        usePreload["useImagePreloader"]:::hook
    end

    %% Utils Layer
    subgraph UtilityServices
        DeckHandler["Deck Handler"]:::util
        ThemeHandler["Theme Handler"]:::util
        CacheHandler["Cache Handler"]:::util
        UserHandler["Username Handler"]:::util
    end

    %% External Services
    ScryfallAPI["Scryfall API"]:::external
    LocalStorage["Local Storage"]:::storage
    Assets["Assets Layer"]:::storage

    %% Relationships
    Home --> Navbar
    DeckBuilder --> Navbar
    Discover --> Navbar
    Settings --> Navbar

    DeckBuilder --> DeckBuildingModule
    Discover --> CardDiscoveryModule
    Settings --> SettingsModule

    CardDiscoveryModule --> useSearch
    useSearch --> ScryfallAPI
    useSearch --> CacheHandler

    DeckBuildingModule --> DeckHandler
    DeckHandler --> LocalStorage

    SettingsModule --> ThemeHandler
    SettingsModule --> UserHandler
    ThemeHandler --> LocalStorage
    UserHandler --> LocalStorage

    Assets --> usePreload
    usePreload --> CardComp
    usePreload --> CardDetail

    %% Click Events
    click Home "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Pages/Home/Home.jsx"
    click DeckBuilder "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Pages/DeckBuilder/DeckBuilder.jsx"
    click Discover "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Pages/Discover/Discover.jsx"
    click Settings "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Pages/Settings/Settings.jsx"
    click CardSelector "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/DeckBuilder/DeckBuilderCardSelector/"
    click StatusBoard "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/DeckBuilder/DeckBuilderStatusBoard/"
    click ManaCostGraph "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/DeckBuilder/ManaCostGraph/"
    click SearchComp "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/Discover/DiscoverSearchComponent/"
    click CardDetail "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/Discover/CardDetailModal/"
    click CardComp "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/Discover/DiscoverCardComponent/"
    click ThemePicker "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/Settings/ThemePickerComponent/"
    click ImportExport "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/Settings/ImportComponent/"
    click UsernameChanger "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/Settings/UsernameChangerComponent/"
    click useSearch "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Hooks/useSearchCards.jsx"
    click useBlur "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Hooks/useBackgroundBlur.jsx"
    click useRandom "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Hooks/useGetRandomCard.jsx"
    click usePreload "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Hooks/useImagePreloader.jsx"
    click DeckHandler "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Utils/deckHandler.js"
    click ThemeHandler "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Utils/themeHandler.js"
    click CacheHandler "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Utils/cacheHandler.js"
    click UserHandler "https://github.com/Erik-EEI/mtg-deck-project/blob/main/mtg-frontend-react/src/Utils/usernameHandler.js"
    click Assets "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Assets/"
    click Navbar "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/Layout/Navbar/"
    click Footer "https://github.com/Erik-EEI/mtg-deck-project/tree/main/mtg-frontend-react/src/Components/Layout/Footer/"
```
