# j-chau/spellbook architecture

> Architecture diagram of the GitHub repository j-chau/spellbook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/j-chau/spellbook
- Repository: https://github.com/j-chau/spellbook

## Overview

##### Detailed Component Breakdown

A. Client Layer:
- Browser interface
- Local Storage component (as indicated by LocalStorage.ts utility)

B. Application Layer (React Components):

1. Pages (Top Level):
- SearchSpells Page
- MySpells Page

2. Core Components (Middle Level):
- Navigation
- SpellList
- SpellCard
- Filter Components

3. Utility Layer (Bottom Level):
- Hooks (useDebounce)
- Utils
- Types

C. External Services:
- Open5e API
- Local Storage Interface

##### Flow Representation

- User interactions → Components
- Component → Open5e API calls
- Data persistence → Local Storage
- State management flows

##### Component Relationships

Key relationships:
- SearchSpells page containing filters (ClassFilter, SchoolFilter, Search)
- SpellList containing SpellCard components
- AddButton/RemoveButton interaction with Local Storage
- Filter components' connection to the search functionality

##### Technical Details

Annotations for:
- TypeScript usage (indicated by .tsx files)
- CSS Modules implementation
- Testing setup (Jest)

- User Interface Layer
- Business Logic Layer
- Data Persistence Layer
- External Services Layer

Important Guidelines:

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Browser/User Interface"]
        LocalStorage["Local Storage"]:::storage
    end

    subgraph Application
        subgraph Pages
            SearchSpells["Search Spells Page"]
            MySpells["My Spells Page"]
        end

        subgraph Components
            Nav["Navigation"]
            SpellList["Spell List"]
            SpellCard["Spell Card"]
            Filter["Filter Base"]
            Tooltip["Tooltip"]
        end

        subgraph Filters
            Search["Search Input"]
            ClassFilter["Class Filter"]
            SchoolFilter["School Filter"]
        end

        subgraph Utils
            LocalStorageUtil["Local Storage Utility"]
            Types["Type Definitions"]
            Hooks["useDebounce Hook"]
        end
    end

    subgraph External
        Open5e["Open5e API"]:::external
    end

    %% Relationships
    Browser --> Nav
    Nav --> SearchSpells
    Nav --> MySpells
    
    SearchSpells --> Search
    SearchSpells --> ClassFilter
    SearchSpells --> SchoolFilter
    SearchSpells --> SpellList
    
    MySpells --> SpellList
    
    Filter --> ClassFilter
    Filter --> SchoolFilter
    
    SpellList --> SpellCard
    SpellCard --> Tooltip
    
    Search --> Hooks
    ClassFilter --> LocalStorageUtil
    SchoolFilter --> LocalStorageUtil
    
    SpellCard --> LocalStorageUtil
    LocalStorageUtil --> LocalStorage
    
    SearchSpells --> Open5e
    MySpells --> LocalStorage

    %% Styling
    classDef page fill:#a8dadc
    classDef component fill:#457b9d
    classDef filter fill:#e63946
    classDef util fill:#1d3557
    classDef storage fill:#fca311
    classDef external fill:#2a9d8f

    class SearchSpells,MySpells page
    class Nav,SpellList,SpellCard,Filter,Tooltip component
    class Search,ClassFilter,SchoolFilter filter
    class LocalStorageUtil,Types,Hooks util
    class LocalStorage storage
    class Open5e external

    %% Click Events
    click SearchSpells "https://github.com/j-chau/spellbook/blob/main/src/pages/SearchSpells/SearchSpells.tsx"
    click MySpells "https://github.com/j-chau/spellbook/blob/main/src/pages/MySpells/MySpells.tsx"
    click Nav "https://github.com/j-chau/spellbook/blob/main/src/components/Navigation/Navigation.tsx"
    click SpellList "https://github.com/j-chau/spellbook/blob/main/src/components/SpellList/SpellList.tsx"
    click SpellCard "https://github.com/j-chau/spellbook/blob/main/src/components/SpellCard/SpellCard.tsx"
    click ClassFilter "https://github.com/j-chau/spellbook/blob/main/src/pages/SearchSpells/components/ClassFilter/ClassFilter.tsx"
    click SchoolFilter "https://github.com/j-chau/spellbook/blob/main/src/pages/SearchSpells/components/SchoolFilter/SchoolFilter.tsx"
    click Search "https://github.com/j-chau/spellbook/blob/main/src/pages/SearchSpells/components/Search/Search.tsx"
    click Filter "https://github.com/j-chau/spellbook/blob/main/src/components/Filter/Filter.tsx"
    click Tooltip "https://github.com/j-chau/spellbook/blob/main/src/components/Tooltip/Tooltip.tsx"
    click LocalStorageUtil "https://github.com/j-chau/spellbook/blob/main/src/utils/LocalStorage.ts"
    click Hooks "https://github.com/j-chau/spellbook/blob/main/src/hooks/useDebounce.ts"
    click Types "https://github.com/j-chau/spellbook/blob/main/src/types.ts"
```
