# ayfri/atom-clicker-svelte architecture

> Architecture diagram of the GitHub repository ayfri/atom-clicker-svelte, 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/ayfri/atom-clicker-svelte
- Repository: https://github.com/ayfri/atom-clicker-svelte

## Overview

##### High-Level Architecture Components

a) Frontend Application (Svelte-based)
- Client-side rendering
- Component hierarchy (Atomic Design Pattern)
- State management
- Game engine integration

##### Component Structure (Using Atomic Design)

Components hierarchically:
- Atoms (basic components)
- Molecules (composite components)
- Organisms (complex components)
- Pages/Routes

##### Core Systems

Create distinct sections for:
- Game Engine System
- State Management System
- Rendering System (PIXI.js integration)
- Save System
- Particle System

##### Specific Implementation Details

Key relationships:
**Game Engine (gameManager.ts)**
**↓**
**State Stores (gameStore.ts, protons.ts, etc.)**
**↓**
**UI Components (Atom.svelte, Buildings.svelte, etc.)**

##### Component Relationships

Interactions:
- Game loop → State updates → UI renders
- User interactions → State mutations → Game state updates
- Save system ↔ Game state persistence

##### Data Flow Patterns

Represent:
- Store subscriptions
- Component communication
- Game state updates
- Particle system interactions

Key Elements to Include:

##### Core Systems
- Game Manager
- Particle System
- Save System
- Canvas Renderer

##### State Stores
- Game Store
- Protons Store
- Canvas Store
- Window Store
- Toast Store

##### UI Component Hierarchy
- Atoms (Modal, StatItem, etc.)
- Molecules (Canvas, Counter, etc.)
- Organisms (Atom, Buildings, SkillTree, etc.)

##### Data Sources
- achievements.ts
- buildings.ts
- currencies.ts
- skillTree.ts
- upgrades.ts

Important Considerations:

##### Clear boundaries between
- Game logic
- UI components
- State management
- Data configuration

##### Reactive nature of
- Store updates
- Component rendering
- Game state changes

##### Interaction patterns
- User input handling
- Game loop updates
- State propagation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        UI_ATOMS["Atomic Components"]
        UI_MOLECULES["Molecular Components"]
        UI_ORGANISMS["Organism Components"]
        
        UI_ATOMS --> UI_MOLECULES
        UI_MOLECULES --> UI_ORGANISMS
    end

    subgraph "Store Layer"
        GAME_STORE["Game Store"]
        PROTONS_STORE["Protons Store"]
        CANVAS_STORE["Canvas Store"]
        TOAST_STORE["Toast Store"]
        WINDOW_STORE["Window Store"]
    end

    subgraph "Game Core"
        GAME_MANAGER["Game Manager"]
        PARTICLE_SYSTEM["Particle System"]
        SAVE_SYSTEM["Save System"]
    end

    subgraph "Game Data"
        ACHIEVEMENTS["Achievements"]
        BUILDINGS["Buildings"]
        CURRENCIES["Currencies"]
        POWERUPS["Power-ups"]
        SKILLTREE["Skill Tree"]
        UPGRADES["Upgrades"]
    end

    UI_ORGANISMS --> GAME_STORE
    UI_ORGANISMS --> CANVAS_STORE
    UI_ORGANISMS --> TOAST_STORE
    
    GAME_STORE --> GAME_MANAGER
    PROTONS_STORE --> GAME_MANAGER
    CANVAS_STORE --> PARTICLE_SYSTEM
    
    GAME_MANAGER --> SAVE_SYSTEM
    SAVE_SYSTEM --> GAME_DATA
    
    GAME_MANAGER --> ACHIEVEMENTS
    GAME_MANAGER --> BUILDINGS
    GAME_MANAGER --> CURRENCIES
    GAME_MANAGER --> POWERUPS
    GAME_MANAGER --> SKILLTREE
    GAME_MANAGER --> UPGRADES

    %% Component Mappings
    click UI_ATOMS "https://github.com/Ayfri/Atom-Clicker-Svelte/tree/main/src/lib/components/atoms/"
    click UI_MOLECULES "https://github.com/Ayfri/Atom-Clicker-Svelte/tree/main/src/lib/components/molecules/"
    click UI_ORGANISMS "https://github.com/Ayfri/Atom-Clicker-Svelte/tree/main/src/lib/components/organisms/"
    click GAME_STORE "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/stores/gameStore.ts"
    click PROTONS_STORE "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/stores/protons.ts"
    click CANVAS_STORE "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/stores/canvas.ts"
    click TOAST_STORE "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/stores/toasts.ts"
    click WINDOW_STORE "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/stores/window.ts"
    click GAME_MANAGER "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/helpers/gameManager.ts"
    click PARTICLE_SYSTEM "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/helpers/particles.ts"
    click SAVE_SYSTEM "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/helpers/saves.ts"
    click ACHIEVEMENTS "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/data/achievements.ts"
    click BUILDINGS "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/data/buildings.ts"
    click CURRENCIES "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/data/currencies.ts"
    click POWERUPS "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/data/powerUp.ts"
    click SKILLTREE "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/data/skillTree.ts"
    click UPGRADES "https://github.com/Ayfri/Atom-Clicker-Svelte/blob/main/src/lib/data/upgrades.ts"

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef store fill:#2ecc71,stroke:#27ae60,color:white
    classDef core fill:#f1c40f,stroke:#f39c12,color:black
    classDef data fill:#9b59b6,stroke:#8e44ad,color:white

    class UI_ATOMS,UI_MOLECULES,UI_ORGANISMS frontend
    class GAME_STORE,PROTONS_STORE,CANVAS_STORE,TOAST_STORE,WINDOW_STORE store
    class GAME_MANAGER,PARTICLE_SYSTEM,SAVE_SYSTEM core
    class ACHIEVEMENTS,BUILDINGS,CURRENCIES,POWERUPS,SKILLTREE,UPGRADES data
```
