# afrah-saleh/fin-s-adventure architecture

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

- Interactive diagram: https://gitdiagram.com/afrah-saleh/fin-s-adventure
- Repository: https://github.com/afrah-saleh/fin-s-adventure

## Overview

##### Main Components Identification

A. Presentation Layer
- Main Game Interface (ContentView)
- Onboarding Experience (OnboardingView)
- UI Elements (ViewElements folder components)

B. Game Logic Layer
- Game Scene Controller
- Enemy Handling System
- Player Management
- Game State Management

C. Asset Management Layer
- Create components for:
- Visual Assets (Images/Sprites)
- Audio Assets (Sound Effects/Music)

##### Technology Stack Representation
Dedicated sections showing the main technologies:
- SpriteKit (Game Engine)
- SwiftUI (UI Framework)
- AVFoundation (Audio System)
- GameplayKit (Game Logic)

**┌─────────────────────────────────────────┐**
- Presentation               │
- ┌─────────────┐ ┌──────────────────┐  │
- SwiftUI   │ │    SpriteKit     │  │
- Views    │ │   Game Scene     │  │
- ┘ └──────────────────┘  │
- ┤
- Game Logic Layer             │
- ┌─────────────┐ ┌──────────────────┐  │
- Player    │ │      Enemy       │  │
- Management │ │    Handling      │  │
- ┘ └──────────────────┘  │
- ┤
- Asset Management              │
- ┌─────────────┐ ┌──────────────────┐  │
- Visual    │ │      Audio       │  │
- Assets    │ │     System       │  │
- ┘ └──────────────────┘  │
- ┘

##### Key Relationships to Highlight
- How GameScene.swift coordinates with EnemyHandling.swift and setupPlayer.swift
- Connection between SoundManager and the Resources folder
- Demonstrate how ViewElements interact with the main views
- Relationship between game logic and UI updates

##### Documentation Elements
Add:
- A clear title: "Fin's Adventure - System Architecture"
- Version information
- Brief descriptions of major components
- Notes about the WWDC award-winning features

##### Data Flow Indicators
Show:
- Player input handling
- Collision detection paths
- Score/health update mechanisms
- Audio trigger points
- Scene transition flows

Remember to maintain a balance between detail and clarity, focusing on the game's educational and environmental awareness aspects while clearly showing the technical implementation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Title
    title["Fin's Adventure - System Architecture"]
    
    subgraph PL["Presentation Layer"]
        direction TB
        UI["SwiftUI Views"]
        GS["Game Scene Interface"]
        
        subgraph Views["View Components"]
            direction TB
            CV["Content View"]:::ui
            OV["Onboarding View"]:::ui
            VE["View Elements"]:::ui
            HB["Health Bar"]:::ui
            TM["Timer"]:::ui
            BG["Background View"]:::ui
        end
    end
    
    subgraph GL["Game Logic Layer"]
        direction TB
        GSC["Game Scene Controller"]:::logic
        EH["Enemy Handling"]:::logic
        PM["Player Management"]:::logic
        GSM["Game State Manager"]:::logic
        SS["Scene Setup"]:::logic
    end
    
    subgraph AL["Asset Management Layer"]
        direction TB
        VA["Visual Assets"]:::asset
        AA["Audio Assets"]:::asset
        SM["Sound Manager"]:::asset
    end
    
    %% Framework Components
    SK[("SpriteKit")]:::framework
    SUI[("SwiftUI")]:::framework
    AVF[("AVFoundation")]:::framework
    GPK[("GameplayKit")]:::framework
    
    %% Relationships
    UI --> Views
    Views --> GSC
    GSC --> EH
    GSC --> PM
    GSC --> GSM
    GSC --> SS
    GSC --> SM
    SM --> AA
    GSC --> VA
    
    %% Framework Dependencies
    SK -.-> GSC
    SUI -.-> UI
    AVF -.-> SM
    GPK -.-> GSC
    
    %% Click Events
    click CV "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/views/ContentView.swift"
    click OV "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/views/OnboardingView.swift"
    click VE "https://github.com/Afrah-saleh/Fin-s-Adventure/tree/main/Fin's Adventure/views/ViewElements/"
    click GSC "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/ViewModel/GameScene.swift"
    click EH "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/ViewModel/EnemyHandling.swift"
    click PM "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/ViewModel/setupPlayer.swift"
    click GSM "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/ViewModel/GameOver.swift"
    click VA "https://github.com/Afrah-saleh/Fin-s-Adventure/tree/main/Fin's Adventure/Assets.xcassets/"
    click AA "https://github.com/Afrah-saleh/Fin-s-Adventure/tree/main/Fin's Adventure/Resources/"
    click SM "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/ViewModel/SoundManager.swift"
    click SS "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/ViewModel/setupScene.swift"
    click HB "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/views/ViewElements/HealthBarView.swift"
    click TM "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/views/ViewElements/Timer.swift"
    click BG "https://github.com/Afrah-saleh/Fin-s-Adventure/blob/main/Fin's Adventure/views/ViewElements/BackgroundViewModel.swift"
    
    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef logic fill:#2ecc71,stroke:#27ae60,color:white
    classDef asset fill:#e67e22,stroke:#d35400,color:white
    classDef framework fill:#9b59b6,stroke:#8e44ad,color:white
    
    %% Legend
    subgraph Legend
        direction TB
        L1["UI Components"]:::ui
        L2["Game Logic"]:::logic
        L3["Asset Management"]:::asset
        L4["Frameworks"]:::framework
    end
```
