# ayfri/atom-clicker architecture

> Architecture diagram of the GitHub repository ayfri/atom-clicker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayfri/atom-clicker
- Repository: https://github.com/ayfri/atom-clicker

## Overview

Atom Clicker is a SvelteKit incremental game. The player interacts with the game page to click atoms, buy production buildings and upgrades, unlock skills, collect power-ups, and progress through Photon, Radiation, and prestige realms. GameManager owns mutable progression and persistence; specialized components present each domain. Optional simulation benchmarks exercise the same state manager. Authenticated routes provide leaderboard, Quark rewards, cosmetics, statistics, and error reporting through Supabase. Some client composition is inferred from the tree and README because page/component implementations were not sampled.

Main entry points: [`src/lib/helpers/GameManager.svelte.ts`](https://github.com/ayfri/atom-clicker/blob/main/src/lib/helpers/GameManager.svelte.ts) (Game Manager), [`src/lib/server/supabase.server.ts`](https://github.com/ayfri/atom-clicker/blob/main/src/lib/server/supabase.server.ts) (Supabase Service), [`src/routes/api/leaderboard/+server.ts`](https://github.com/ayfri/atom-clicker/blob/main/src/routes/api/leaderboard/%2Bserver.ts) (Leaderboard API), [`src/routes/api/quarks`](https://github.com/ayfri/atom-clicker/tree/main/src/routes/api/quarks) (Quark APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Game Client"]
  node_game_page["Game Page<br/>[+page.svelte]"]
  node_game_state["Game Manager"]
  node_canvas["Atom Canvas<br/>[Canvas.svelte]"]
end

subgraph group_g2["Progression Systems"]
  node_buildings["Buildings<br/>[Buildings.svelte]"]
  node_upgrades["Upgrades<br/>[Upgrades.svelte]"]
  node_skills["Skill Tree<br/>[SkillTree.svelte]"]
  node_prestige["Prestige Realms"]
  node_photon["Photon Realm<br/>[PhotonRealm.svelte]"]
  node_radiation["Radiation Realm"]
  node_powerups["Power Ups"]
  node_quarks["Quarks Quests<br/>[Quarks.svelte]"]
  node_simulation["Simulation Engine<br/>[engine.ts]"]
end

subgraph group_g3["Persistence Layer"]
  node_saves["Save Manager<br/>[saves.ts]"]
  node_offline["Offline Progress<br/>[offlineProgress.ts]"]
  node_local_storage[("Browser Storage")]
end

subgraph group_g4["Online Services"]
  node_leaderboard_ui["Leaderboard UI<br/>[Leaderboard.svelte]"]
  node_leaderboard_api["Leaderboard API<br/>[+server.ts]"]
  node_quark_api["Quark APIs"]
  node_auth_api["Auth Status API<br/>[+server.ts]"]
  node_stats_api["Stats API<br/>[+server.ts]"]
  node_error_api["Error API<br/>[+server.ts]"]
  node_obfuscation["Data Verification"]
  node_supabase_service["Supabase Service<br/>[supabase.server.ts]"]
end

node_player(("Player"))
node_supabase[("Supabase")]
node_auth_provider["Auth Provider"]

node_player -->|"plays"| node_game_page
node_game_page -->|"updates"| node_game_state
node_game_state -->|"renders state"| node_canvas
node_game_state -->|"feeds production"| node_buildings
node_buildings -->|"buys buildings"| node_game_state
node_upgrades -->|"buys upgrades"| node_game_state
node_skills -->|"buys skills"| node_game_state
node_prestige -->|"resets progress"| node_game_state
node_photon -->|"collects photons"| node_game_state
node_radiation -->|"controls reactor"| node_game_state
node_powerups -->|"collects boosts"| node_game_state
node_quarks -->|"tracks rewards"| node_game_state
node_simulation -->|"ticks state"| node_game_state
node_game_state -->|"serializes state"| node_saves
node_game_state -->|"applies progress"| node_offline
node_saves -->|"reads writes"| node_local_storage
node_leaderboard_ui -.->|"loads scores"| node_leaderboard_api
node_leaderboard_api -->|"verifies payload"| node_obfuscation
node_leaderboard_api -->|"reads writes profiles"| node_supabase_service
node_quark_api -->|"verifies payload"| node_obfuscation
node_quark_api -->|"claims entitlements"| node_supabase_service
node_auth_api -->|"checks session"| node_supabase_service
node_stats_api -->|"counts profiles"| node_supabase_service
node_error_api -->|"logs errors"| node_supabase_service
node_supabase_service -->|"queries database"| node_supabase
node_auth_provider -.->|"provides session"| node_auth_api

click node_game_page "https://github.com/ayfri/atom-clicker/blob/main/src/routes/%2Bpage.svelte"
click node_game_state "https://github.com/ayfri/atom-clicker/blob/main/src/lib/helpers/GameManager.svelte.ts"
click node_canvas "https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/game/Canvas.svelte"
click node_buildings "https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/game/Buildings.svelte"
click node_upgrades "https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/game/Upgrades.svelte"
click node_skills "https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/modals/SkillTree.svelte"
click node_prestige "https://github.com/ayfri/atom-clicker/tree/main/src/lib/components/prestige"
click node_photon "https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/prestige/PhotonRealm.svelte"
click node_radiation "https://github.com/ayfri/atom-clicker/tree/main/src/lib/components/radiation"
click node_powerups "https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/hud/ActivePowerUps.svelte"
click node_quarks "https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/modals/Quarks.svelte"
click node_simulation "https://github.com/ayfri/atom-clicker/blob/main/src/lib/simulation/engine.ts"
click node_saves "https://github.com/ayfri/atom-clicker/blob/main/src/lib/helpers/saves.ts"
click node_offline "https://github.com/ayfri/atom-clicker/blob/main/src/lib/helpers/offlineProgress.ts"
click node_local_storage "https://github.com/ayfri/atom-clicker/blob/main/src/lib/utils/safeLocalStorage.ts"
click node_leaderboard_ui "https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/modals/Leaderboard.svelte"
click node_leaderboard_api "https://github.com/ayfri/atom-clicker/blob/main/src/routes/api/leaderboard/%2Bserver.ts"
click node_quark_api "https://github.com/ayfri/atom-clicker/tree/main/src/routes/api/quarks"
click node_auth_api "https://github.com/ayfri/atom-clicker/blob/main/src/routes/api/auth/status/%2Bserver.ts"
click node_stats_api "https://github.com/ayfri/atom-clicker/blob/main/src/routes/api/stats/%2Bserver.ts"
click node_error_api "https://github.com/ayfri/atom-clicker/blob/main/src/routes/api/errors/%2Bserver.ts"
click node_obfuscation "https://github.com/ayfri/atom-clicker/blob/main/src/lib/server/obfuscation.server.ts"
click node_supabase_service "https://github.com/ayfri/atom-clicker/blob/main/src/lib/server/supabase.server.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_game_page,node_game_state,node_canvas toneBlue
class node_buildings,node_upgrades,node_skills,node_prestige,node_photon,node_radiation,node_powerups,node_quarks,node_simulation,node_supabase toneAmber
class node_saves,node_offline,node_local_storage toneMint
class node_leaderboard_ui,node_leaderboard_api,node_quark_api,node_auth_api,node_stats_api,node_error_api,node_obfuscation,node_supabase_service toneRose
class node_player,node_auth_provider toneIndigo
```

## Components

### Game Client

- [Game Page](https://github.com/ayfri/atom-clicker/blob/main/src/routes/%2Bpage.svelte): `src/routes/+page.svelte`
- [Game Manager](https://github.com/ayfri/atom-clicker/blob/main/src/lib/helpers/GameManager.svelte.ts): `src/lib/helpers/GameManager.svelte.ts`
- [Atom Canvas](https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/game/Canvas.svelte): `src/lib/components/game/Canvas.svelte`

### Progression Systems

- [Buildings](https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/game/Buildings.svelte): `src/lib/components/game/Buildings.svelte`
- [Upgrades](https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/game/Upgrades.svelte): `src/lib/components/game/Upgrades.svelte`
- [Skill Tree](https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/modals/SkillTree.svelte): `src/lib/components/modals/SkillTree.svelte`
- [Prestige Realms](https://github.com/ayfri/atom-clicker/tree/main/src/lib/components/prestige): `src/lib/components/prestige`
- [Photon Realm](https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/prestige/PhotonRealm.svelte): `src/lib/components/prestige/PhotonRealm.svelte`
- [Radiation Realm](https://github.com/ayfri/atom-clicker/tree/main/src/lib/components/radiation): `src/lib/components/radiation`
- [Power Ups](https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/hud/ActivePowerUps.svelte): `src/lib/components/hud/ActivePowerUps.svelte`
- [Quarks Quests](https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/modals/Quarks.svelte): `src/lib/components/modals/Quarks.svelte`
- [Simulation Engine](https://github.com/ayfri/atom-clicker/blob/main/src/lib/simulation/engine.ts): `src/lib/simulation/engine.ts`

### Persistence Layer

- [Save Manager](https://github.com/ayfri/atom-clicker/blob/main/src/lib/helpers/saves.ts): `src/lib/helpers/saves.ts`
- [Offline Progress](https://github.com/ayfri/atom-clicker/blob/main/src/lib/helpers/offlineProgress.ts): `src/lib/helpers/offlineProgress.ts`
- [Browser Storage](https://github.com/ayfri/atom-clicker/blob/main/src/lib/utils/safeLocalStorage.ts): `src/lib/utils/safeLocalStorage.ts`

### Online Services

- [Leaderboard UI](https://github.com/ayfri/atom-clicker/blob/main/src/lib/components/modals/Leaderboard.svelte): `src/lib/components/modals/Leaderboard.svelte`
- [Leaderboard API](https://github.com/ayfri/atom-clicker/blob/main/src/routes/api/leaderboard/%2Bserver.ts): `src/routes/api/leaderboard/+server.ts`
- [Quark APIs](https://github.com/ayfri/atom-clicker/tree/main/src/routes/api/quarks): `src/routes/api/quarks`
- [Auth Status API](https://github.com/ayfri/atom-clicker/blob/main/src/routes/api/auth/status/%2Bserver.ts): `src/routes/api/auth/status/+server.ts`
- [Stats API](https://github.com/ayfri/atom-clicker/blob/main/src/routes/api/stats/%2Bserver.ts): `src/routes/api/stats/+server.ts`
- [Error API](https://github.com/ayfri/atom-clicker/blob/main/src/routes/api/errors/%2Bserver.ts): `src/routes/api/errors/+server.ts`
- [Data Verification](https://github.com/ayfri/atom-clicker/blob/main/src/lib/server/obfuscation.server.ts): `src/lib/server/obfuscation.server.ts`
- [Supabase Service](https://github.com/ayfri/atom-clicker/blob/main/src/lib/server/supabase.server.ts): `src/lib/server/supabase.server.ts`

### Other components

- **Player**
- **Supabase**
- **Auth Provider**

## Connections

- Player → Game Page: plays
- Game Page → Game Manager: updates
- Game Manager → Atom Canvas: renders state
- Game Manager → Buildings: feeds production
- Buildings → Game Manager: buys buildings
- Upgrades → Game Manager: buys upgrades
- Skill Tree → Game Manager: buys skills
- Prestige Realms → Game Manager: resets progress
- Photon Realm → Game Manager: collects photons
- Radiation Realm → Game Manager: controls reactor
- Power Ups → Game Manager: collects boosts
- Quarks Quests → Game Manager: tracks rewards
- Simulation Engine → Game Manager: ticks state
- Game Manager → Save Manager: serializes state
- Game Manager → Offline Progress: applies progress
- Save Manager → Browser Storage: reads writes
- Leaderboard UI → Leaderboard API: loads scores
- Leaderboard API → Data Verification: verifies payload
- Leaderboard API → Supabase Service: reads writes profiles
- Quark APIs → Data Verification: verifies payload
- Quark APIs → Supabase Service: claims entitlements
- Auth Status API → Supabase Service: checks session
- Stats API → Supabase Service: counts profiles
- Error API → Supabase Service: logs errors
- Supabase Service → Supabase: queries database
- Auth Provider → Auth Status API: provides session
