# hmiller20/pet-app-next architecture

> Architecture diagram of the GitHub repository hmiller20/pet-app-next, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hmiller20/pet-app-next
- Repository: https://github.com/hmiller20/pet-app-next

## Overview

##### Main Components

Frontend Layer:
- Next.js Application (Client-Side)
- Pages/Routes Structure
- Login
- Menu
- Choose Pet
- Name Pet
- Game
- Settings
- Components Layer
- Game Components
- Animation Components
- Background Components
- Contexts
- Auth Context
- Game Context

Backend Integration:
- Firebase Integration (as indicated by src/lib/firebase.ts)
- Authentication System
- Data Persistence

Asset Management:
- Pet Animations System
- Different pet types (sheep)
- Various states (happy, neutral, sad, sick)
- Age variations (baby, adult)

##### User Authentication Flow
- User → Login Page → Firebase Auth → App Access
##### Game State Flow
- Game Context → Pet State → Animation System
##### Asset Loading Flow
- Pet Selection → Animation Loading → Rendering
##### Data Persistence Flow
- Game State → Firebase → Storage

##### Important Architectural Elements to Emphasize

- Next.js App Router Structure
- Context-based State Management
- Component Hierarchy
- Asset Organization System
- Firebase Integration Points

##### Technical Details

- Next.js 13+ App Router
- React Context API usage
- Firebase Authentication
- Custom hooks (useSound)
- Animation system structure

Create clear sections for:
##### User Interface Layer
- Pages
- Components
- Animations
##### Application Logic Layer
- Contexts
- Hooks
- Utils
##### External Services Layer
- Firebase
- Asset Storage

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        UI["User Interface"]
        
        subgraph "Pages"
            Login["Login Page"]:::page
            Menu["Menu Page"]:::page
            ChoosePet["Choose Pet Page"]:::page
            NamePet["Name Pet Page"]:::page
            Game["Game Page"]:::page
            Settings["Settings Page"]:::page
        end
        
        subgraph "Components"
            GameComp["Game Components"]:::component
            InfoModal["Info Modal"]:::component
            
            subgraph "Animation Components"
                PetAnim["Pet Animation"]:::component
                BgAnim["Background Animation"]:::component
                AnimShapes["Animated Shapes"]:::component
                WaveBg["Wave Background"]:::component
            end
        end
    end
    
    subgraph "Application Logic"
        AuthCtx[("Auth Context")]:::context
        GameCtx[("Game Context")]:::context
        SoundHook["Sound System"]:::util
        PetUtils["Pet Utilities"]:::util
    end
    
    subgraph "External Services"
        Firebase[(Firebase)]:::external
        
        subgraph "Asset Storage"
            PetAssets["Pet Animation Assets"]:::asset
            SoundAssets["Sound Assets"]:::asset
        end
    end
    
    %% Relationships
    UI --> Login & Menu & ChoosePet & NamePet & Game & Settings
    
    Login --> AuthCtx
    AuthCtx --> Firebase
    
    Game --> GameComp
    GameComp --> InfoModal
    GameComp --> PetAnim
    GameComp --> BgAnim
    
    GameCtx --> PetUtils
    PetUtils --> Firebase
    
    PetAnim --> PetAssets
    BgAnim --> AnimShapes & WaveBg
    
    GameComp --> SoundHook
    SoundHook --> SoundAssets
    
    %% Click Events
    click Login "https://github.com/hmiller20/pet-app-next/blob/main/src/app/login/page.tsx"
    click Menu "https://github.com/hmiller20/pet-app-next/blob/main/src/app/menu/page.tsx"
    click ChoosePet "https://github.com/hmiller20/pet-app-next/blob/main/src/app/choose-pet/page.tsx"
    click NamePet "https://github.com/hmiller20/pet-app-next/blob/main/src/app/name-pet/page.tsx"
    click Game "https://github.com/hmiller20/pet-app-next/blob/main/src/app/game/page.tsx"
    click Settings "https://github.com/hmiller20/pet-app-next/blob/main/src/app/settings/page.tsx"
    click GameComp "https://github.com/hmiller20/pet-app-next/blob/main/src/components/GameComponents.tsx"
    click InfoModal "https://github.com/hmiller20/pet-app-next/blob/main/src/components/InfoModal.tsx"
    click PetAnim "https://github.com/hmiller20/pet-app-next/blob/main/src/components/animations/PetAnimation.tsx"
    click BgAnim "https://github.com/hmiller20/pet-app-next/blob/main/src/components/backgrounds/AnimatedBackground.tsx"
    click AnimShapes "https://github.com/hmiller20/pet-app-next/blob/main/src/components/backgrounds/AnimatedShapes.tsx"
    click WaveBg "https://github.com/hmiller20/pet-app-next/blob/main/src/components/backgrounds/WaveBackground.tsx"
    click AuthCtx "https://github.com/hmiller20/pet-app-next/blob/main/src/contexts/AuthContext.tsx"
    click GameCtx "https://github.com/hmiller20/pet-app-next/blob/main/src/contexts/GameContext.tsx"
    click Firebase "https://github.com/hmiller20/pet-app-next/blob/main/src/lib/firebase.ts"
    click PetUtils "https://github.com/hmiller20/pet-app-next/blob/main/src/lib/petUtils.ts"
    click SoundHook "https://github.com/hmiller20/pet-app-next/blob/main/src/hooks/useSound.ts"
    click PetAssets "https://github.com/hmiller20/pet-app-next/tree/main/src/assets/animations/pets/sheep"
    
    %% Styles
    classDef page fill:#2196F3,stroke:#1565C0,color:white
    classDef component fill:#4CAF50,stroke:#2E7D32,color:white
    classDef context fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef external fill:#FF9800,stroke:#EF6C00,color:white
    classDef util fill:#795548,stroke:#4E342E,color:white
    classDef asset fill:#FFC107,stroke:#FFA000,color:white
    
    %% Legend
    subgraph Legend
        L1["Page"]:::page
        L2["Component"]:::component
        L3[("Context")]:::context
        L4["Utility"]:::util
        L5[(External Service)]:::external
        L6["Asset"]:::asset
    end
```
