# bechiixd/keydrop-cases-simulator architecture

> Architecture diagram of the GitHub repository bechiixd/keydrop-cases-simulator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bechiixd/keydrop-cases-simulator
- Repository: https://github.com/bechiixd/keydrop-cases-simulator

## Overview

Keydrop Simulator is a local, single-user CS2 case-opening strategy tool: users browse imported case data, run batch or realistic openings, and inspect outcomes they can verify through a shared provably-fair chain. It also supports battle simulations, inventory and upgrade flows, plus fake-balance/history management. The graph follows documented routes and indexed imports; several UI implementations were not sampled, so their internal wiring is omitted where it cannot be established.

Main entry points: [`app/api/scrape/route.ts`](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/app/api/scrape/route.ts) (Scrape API), [`lib/caseEngine.ts`](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/caseEngine.ts) (Opening and batch engine), [`lib/scraper/cache.ts`](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/scraper/cache.ts) (Case cache), [`components/SimPageClient.tsx`](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/SimPageClient.tsx) (Simulation mode selector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_catalog["Case catalog"]
  node_case_ui["Case browser and detail"]
  node_case_pages["Case detail page<br/>[page.tsx]"]
  node_case_admin["Case management and paste"]
  node_scrape_api["Scrape API<br/>[route.ts]"]
  node_scrape_fetch["Keydrop fetch<br/>[keydrop.ts]"]
  node_normalizer["Case normalization<br/>[normalize.ts]"]
  node_case_cache[("Case cache<br/>[cache.ts]")]
  node_image_mirror["Image mirror<br/>[mirror.ts]"]
end

subgraph group_simulations["Simulations"]
  node_sim_page["Simulation mode selector<br/>[SimPageClient.tsx]"]
  node_batch_ui["Batch simulator<br/>[SimClient.tsx]"]
  node_realistic_ui["Realistic opening<br/>[OpenRealistic.tsx]"]
  node_battle_ui["Battle simulator<br/>[BattleClient.tsx]"]
  node_battle_engine["Battle calculation<br/>[battleEngine.ts]"]
end

subgraph group_fairness["Fairness and engines"]
  node_case_engine["Opening and batch engine<br/>[caseEngine.ts]"]
  node_provably_fair["Fair ticket and picks<br/>[provablyFair.ts]"]
  node_sha["SHA-256 and HMAC<br/>[sha256.ts]"]
  node_verify_api["Drop verification API<br/>[route.ts]"]
  node_verifier_ui["Drop verifier<br/>[SimVerifier.tsx]"]
end

subgraph group_economy["Local economy"]
  node_balance_ui["Balance and history<br/>[BalanceClient.tsx]"]
  node_inventory_ui["Inventory<br/>[page.tsx]"]
  node_upgrader_ui["Inventory upgrader<br/>[UpgraderClient.tsx]"]
  node_upgrader_engine["Upgrade calculation<br/>[upgrader.ts]"]
  node_inventory_store[("Inventory storage<br/>[inventory.ts]")]
  node_local_storage[("Browser localStorage<br/>[storage.ts]")]
end

node_user(("User"))
node_keydrop["Keydrop"]

node_user -->|"browses"| node_case_ui
node_user -->|"simulates"| node_sim_page
node_user -->|"runs battles"| node_battle_ui
node_user -->|"manages balance"| node_balance_ui
node_keydrop -->|"supplies case data"| node_scrape_fetch
node_scrape_api -.->|"fetches"| node_scrape_fetch
node_scrape_api -->|"normalizes input"| node_normalizer
node_scrape_fetch -->|"uses"| node_normalizer
node_scrape_api -->|"reads and writes"| node_case_cache
node_scrape_api -->|"runs mirror"| node_image_mirror
node_case_ui -->|"loads cases"| node_case_cache
node_case_pages -->|"loads case"| node_case_cache
node_case_admin -.->|"manages cases"| node_scrape_api
node_sim_page -->|"selects mode"| node_batch_ui
node_sim_page -->|"selects mode"| node_realistic_ui
node_sim_page -->|"loads cases"| node_case_cache
node_batch_ui -->|"runs batches"| node_case_engine
node_realistic_ui -.->|"opens case"| node_case_engine
node_battle_ui -->|"runs battle"| node_battle_engine
node_battle_engine -->|"runs batches"| node_case_engine
node_case_engine -->|"computes ticket and picks"| node_provably_fair
node_provably_fair -->|"hashes and signs"| node_sha
node_batch_ui -->|"renders verifier"| node_verifier_ui
node_verifier_ui -.->|"requests verification"| node_verify_api
node_verify_api -->|"loads case data"| node_case_cache
node_verify_api -->|"recomputes drop"| node_case_engine
node_verify_api -->|"verifies ticket"| node_provably_fair
node_balance_ui -->|"reads and writes"| node_local_storage
node_inventory_ui -->|"manages items"| node_inventory_store
node_upgrader_ui -->|"uses inventory"| node_inventory_store
node_upgrader_ui -->|"calculates upgrades"| node_upgrader_engine
node_inventory_store -->|"persists items"| node_local_storage
node_batch_ui -->|"stores balance and history"| node_local_storage
node_battle_ui -->|"records outcomes"| node_inventory_store

click node_case_ui "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/HomeCasesClient.tsx"
click node_case_pages "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/app/cases/%5Bslug%5D/page.tsx"
click node_case_admin "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/ManageCasesClient.tsx"
click node_scrape_api "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/app/api/scrape/route.ts"
click node_scrape_fetch "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/scraper/keydrop.ts"
click node_normalizer "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/scraper/normalize.ts"
click node_case_cache "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/scraper/cache.ts"
click node_image_mirror "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/mirror.ts"
click node_sim_page "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/SimPageClient.tsx"
click node_batch_ui "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/SimClient.tsx"
click node_realistic_ui "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/OpenRealistic.tsx"
click node_battle_ui "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/BattleClient.tsx"
click node_battle_engine "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/battleEngine.ts"
click node_case_engine "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/caseEngine.ts"
click node_provably_fair "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/provablyFair.ts"
click node_sha "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/sha256.ts"
click node_verify_api "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/app/api/provably-fair/route.ts"
click node_verifier_ui "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/SimVerifier.tsx"
click node_balance_ui "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/BalanceClient.tsx"
click node_inventory_ui "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/app/inventory/page.tsx"
click node_upgrader_ui "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/UpgraderClient.tsx"
click node_upgrader_engine "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/upgrader.ts"
click node_inventory_store "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/inventory.ts"
click node_local_storage "https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/storage.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_case_ui,node_case_pages,node_case_admin,node_scrape_api,node_scrape_fetch,node_normalizer,node_case_cache,node_image_mirror,node_user toneBlue
class node_sim_page,node_batch_ui,node_realistic_ui,node_battle_ui,node_battle_engine toneAmber
class node_case_engine,node_provably_fair,node_sha,node_verify_api,node_verifier_ui toneMint
class node_balance_ui,node_inventory_ui,node_upgrader_ui,node_upgrader_engine,node_inventory_store,node_local_storage toneRose
class node_keydrop toneIndigo
```

## Components

### Case catalog

- [Case browser and detail](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/HomeCasesClient.tsx): `components/HomeCasesClient.tsx`
- [Case detail page](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/app/cases/%5Bslug%5D/page.tsx): `app/cases/[slug]/page.tsx`
- [Case management and paste](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/ManageCasesClient.tsx): `components/ManageCasesClient.tsx`
- [Scrape API](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/app/api/scrape/route.ts): `app/api/scrape/route.ts`
- [Keydrop fetch](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/scraper/keydrop.ts): `lib/scraper/keydrop.ts`
- [Case normalization](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/scraper/normalize.ts): `lib/scraper/normalize.ts`
- [Case cache](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/scraper/cache.ts): `lib/scraper/cache.ts`
- [Image mirror](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/mirror.ts): `lib/mirror.ts`

### Simulations

- [Simulation mode selector](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/SimPageClient.tsx): `components/SimPageClient.tsx`
- [Batch simulator](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/SimClient.tsx): `components/SimClient.tsx`
- [Realistic opening](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/OpenRealistic.tsx): `components/OpenRealistic.tsx`
- [Battle simulator](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/BattleClient.tsx): `components/BattleClient.tsx`
- [Battle calculation](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/battleEngine.ts): `lib/battleEngine.ts`

### Fairness and engines

- [Opening and batch engine](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/caseEngine.ts): `lib/caseEngine.ts`
- [Fair ticket and picks](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/provablyFair.ts): `lib/provablyFair.ts`
- [SHA-256 and HMAC](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/sha256.ts): `lib/sha256.ts`
- [Drop verification API](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/app/api/provably-fair/route.ts): `app/api/provably-fair/route.ts`
- [Drop verifier](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/SimVerifier.tsx): `components/SimVerifier.tsx`

### Local economy

- [Balance and history](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/BalanceClient.tsx): `components/BalanceClient.tsx`
- [Inventory](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/app/inventory/page.tsx): `app/inventory/page.tsx`
- [Inventory upgrader](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/components/UpgraderClient.tsx): `components/UpgraderClient.tsx`
- [Upgrade calculation](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/upgrader.ts): `lib/upgrader.ts`
- [Inventory storage](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/inventory.ts): `lib/inventory.ts`
- [Browser localStorage](https://github.com/bechiixd/keydrop-cases-simulator/blob/main/lib/storage.ts): `lib/storage.ts`

### Other components

- **User**
- **Keydrop**

## Connections

- User → Case browser and detail: browses
- User → Simulation mode selector: simulates
- User → Battle simulator: runs battles
- User → Balance and history: manages balance
- Keydrop → Keydrop fetch: supplies case data
- Scrape API → Keydrop fetch: fetches
- Scrape API → Case normalization: normalizes input (evidence: `app/api/scrape/route.ts`)
- Keydrop fetch → Case normalization: uses (evidence: `lib/scraper/keydrop.ts`)
- Scrape API → Case cache: reads and writes (evidence: `app/api/scrape/route.ts`)
- Scrape API → Image mirror: runs mirror (evidence: `app/api/scrape/route.ts`)
- Case browser and detail → Case cache: loads cases (evidence: `app/page.tsx`)
- Case detail page → Case cache: loads case (evidence: `app/cases/[slug]/page.tsx`)
- Case management and paste → Scrape API: manages cases
- Simulation mode selector → Batch simulator: selects mode (evidence: `components/SimPageClient.tsx`)
- Simulation mode selector → Realistic opening: selects mode (evidence: `components/SimPageClient.tsx`)
- Simulation mode selector → Case cache: loads cases (evidence: `app/sim/page.tsx`)
- Batch simulator → Opening and batch engine: runs batches (evidence: `components/SimClient.tsx`)
- Realistic opening → Opening and batch engine: opens case
- Battle simulator → Battle calculation: runs battle (evidence: `components/BattleClient.tsx`)
- Battle calculation → Opening and batch engine: runs batches (evidence: `lib/battleEngine.ts`)
- Opening and batch engine → Fair ticket and picks: computes ticket and picks (evidence: `lib/caseEngine.ts`)
- Fair ticket and picks → SHA-256 and HMAC: hashes and signs (evidence: `lib/provablyFair.ts`)
- Batch simulator → Drop verifier: renders verifier (evidence: `components/SimClient.tsx`)
- Drop verifier → Drop verification API: requests verification
- Drop verification API → Case cache: loads case data (evidence: `app/api/provably-fair/route.ts`)
- Drop verification API → Opening and batch engine: recomputes drop (evidence: `app/api/provably-fair/route.ts`)
- Drop verification API → Fair ticket and picks: verifies ticket (evidence: `app/api/provably-fair/route.ts`)
- Balance and history → Browser localStorage: reads and writes (evidence: `components/BalanceClient.tsx`)
- Inventory → Inventory storage: manages items (evidence: `app/inventory/page.tsx`)
- Inventory upgrader → Inventory storage: uses inventory (evidence: `components/UpgraderClient.tsx`)
- Inventory upgrader → Upgrade calculation: calculates upgrades (evidence: `components/UpgraderClient.tsx`)
- Inventory storage → Browser localStorage: persists items (evidence: `lib/inventory.ts`)
- Batch simulator → Browser localStorage: stores balance and history (evidence: `components/SimClient.tsx`)
- Battle simulator → Inventory storage: records outcomes (evidence: `components/BattleClient.tsx`)
