# ephemerallycaden/hacksheffield-26 architecture

> Architecture diagram of the GitHub repository ephemerallycaden/hacksheffield-26, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ephemerallycaden/hacksheffield-26
- Repository: https://github.com/ephemerallycaden/hacksheffield-26

## Overview

Off the Grid is a mobile pixel-art AR exploration game backed by a Next.js server. Players explore real streets on a hex map, spot objects with an on-device detector, and submit finds that the server resolves into collectible Locals, tiers, rewards, and progression. The app also supports offline find queuing, collections and profiles, leaderboards, and district cosmetic shops. The README documents the major product branches; sampled source confirms app routing, find handling, player authentication, database setup, and profile/shop behavior. Some mobile-to-server links are documented rather than shown in sampled client code.

Main entry points: [`src/server/finds.ts`](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/finds.ts) (Find Resolution), [`src/app/api/finds/route.ts`](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/app/api/finds/route.ts) (Find API Route), [`src/server/db/index.ts`](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/db/index.ts) (Game Database), [`mobile/src/screens/ArScreen.tsx`](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/mobile/src/screens/ArScreen.tsx) (AR Detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile Game"]
  node_app["App Shell<br/>[App.tsx]"]
  node_map["Hex Exploration"]
  node_ar["AR Detection<br/>[ArScreen.tsx]"]
  node_offline["Offline Find Queue"]
end

subgraph group_finds["Finds and Progression"]
  node_contracts["Shared Game Contracts"]
  node_findapi["Find API Route<br/>[route.ts]"]
  node_findlogic["Find Resolution<br/>[finds.ts]"]
  node_catalogue["Local Catalogue<br/>[catalogue.ts]"]
  node_hexinfo["Hex Rarity and Place<br/>[hexes.ts]"]
  node_loot["Loot and Progression<br/>[loot.ts]"]
end

subgraph group_social["Player and Social"]
  node_collection["Collection and Profile"]
  node_profile["Profile Service<br/>[profile.ts]"]
  node_leaderboard["Leaderboard<br/>[leaderboard.ts]"]
end

subgraph group_commerce["Cosmetic Shops"]
  node_shopui["District Shop<br/>[ShopScreen.tsx]"]
  node_shopservice["Shop and Equipping<br/>[shop.ts]"]
end

subgraph group_platform["Server Platform"]
  node_playerauth["Device Authentication<br/>[player.ts]"]
  node_database[("Game Database<br/>[index.ts]")]
  node_mapapi["Map API Route<br/>[route.ts]"]
end

node_player(("Explorer"))

node_player -->|"plays"| node_app
node_app -->|"routes to"| node_map
node_app -->|"routes to"| node_ar
node_player -->|"explores"| node_map
node_map -->|"requests hints"| node_mapapi
node_player -->|"spots and interacts"| node_ar
node_ar -->|"queues offline finds"| node_offline
node_offline -->|"submits when online"| node_findapi
node_ar -->|"submits snapshot"| node_findapi
node_findapi -->|"authenticates"| node_playerauth
node_findapi -->|"opens"| node_database
node_findapi -->|"loads"| node_catalogue
node_findapi -->|"dispatches"| node_findlogic
node_findlogic -->|"resolves Local"| node_catalogue
node_findlogic -->|"gets hex info"| node_hexinfo
node_findlogic -->|"rolls rewards"| node_loot
node_findlogic -->|"records finds"| node_database
node_findlogic -->|"validates find data"| node_contracts
node_player -->|"views collection"| node_collection
node_collection -->|"loads profile"| node_profile
node_profile -->|"reads player history"| node_database
node_player -->|"views rankings"| node_leaderboard
node_leaderboard -->|"reads rankings"| node_database
node_player -->|"browses cosmetics"| node_shopui
node_shopui -->|"requests shop"| node_shopservice
node_shopservice -->|"reads and writes"| node_database
node_shopservice -->|"authenticates"| node_playerauth

click node_app "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/mobile/src/App.tsx"
click node_map "https://github.com/ephemerallycaden/hacksheffield-26/tree/main/mobile/src/map"
click node_ar "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/mobile/src/screens/ArScreen.tsx"
click node_offline "https://github.com/ephemerallycaden/hacksheffield-26/tree/main/mobile/src/queue"
click node_contracts "https://github.com/ephemerallycaden/hacksheffield-26/tree/main/contracts"
click node_findapi "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/app/api/finds/route.ts"
click node_findlogic "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/finds.ts"
click node_catalogue "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/catalogue.ts"
click node_hexinfo "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/hexes.ts"
click node_loot "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/loot.ts"
click node_collection "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/mobile/src/screens/CollectionScreen.tsx"
click node_profile "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/profile.ts"
click node_leaderboard "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/leaderboard.ts"
click node_shopui "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/mobile/src/screens/ShopScreen.tsx"
click node_shopservice "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/shop.ts"
click node_playerauth "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/player.ts"
click node_database "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/db/index.ts"
click node_mapapi "https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/app/api/map/route.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_app,node_map,node_ar,node_offline toneBlue
class node_contracts,node_findapi,node_findlogic,node_catalogue,node_hexinfo,node_loot toneAmber
class node_collection,node_profile,node_leaderboard toneMint
class node_shopui,node_shopservice toneRose
class node_playerauth,node_database,node_mapapi,node_player toneIndigo
```

## Components

### Mobile Game

- [App Shell](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/mobile/src/App.tsx): `mobile/src/App.tsx`
- [Hex Exploration](https://github.com/ephemerallycaden/hacksheffield-26/tree/main/mobile/src/map): `mobile/src/map`
- [AR Detection](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/mobile/src/screens/ArScreen.tsx): `mobile/src/screens/ArScreen.tsx`
- [Offline Find Queue](https://github.com/ephemerallycaden/hacksheffield-26/tree/main/mobile/src/queue): `mobile/src/queue`

### Finds and Progression

- [Shared Game Contracts](https://github.com/ephemerallycaden/hacksheffield-26/tree/main/contracts): `contracts`
- [Find API Route](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/app/api/finds/route.ts): `src/app/api/finds/route.ts`
- [Find Resolution](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/finds.ts): `src/server/finds.ts`
- [Local Catalogue](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/catalogue.ts): `src/server/catalogue.ts`
- [Hex Rarity and Place](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/hexes.ts): `src/server/hexes.ts`
- [Loot and Progression](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/loot.ts): `src/server/loot.ts`

### Player and Social

- [Collection and Profile](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/mobile/src/screens/CollectionScreen.tsx): `mobile/src/screens/CollectionScreen.tsx`
- [Profile Service](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/profile.ts): `src/server/profile.ts`
- [Leaderboard](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/leaderboard.ts): `src/server/leaderboard.ts`

### Cosmetic Shops

- [District Shop](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/mobile/src/screens/ShopScreen.tsx): `mobile/src/screens/ShopScreen.tsx`
- [Shop and Equipping](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/shop.ts): `src/server/shop.ts`

### Server Platform

- [Device Authentication](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/player.ts): `src/server/player.ts`
- [Game Database](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/server/db/index.ts): `src/server/db/index.ts`
- [Map API Route](https://github.com/ephemerallycaden/hacksheffield-26/blob/main/src/app/api/map/route.ts): `src/app/api/map/route.ts`

### Other components

- **Explorer**

## Connections

- Explorer → App Shell: plays (evidence: `README.md`)
- App Shell → Hex Exploration: routes to (evidence: `mobile/src/App.tsx`)
- App Shell → AR Detection: routes to (evidence: `mobile/src/App.tsx`)
- Explorer → Hex Exploration: explores (evidence: `README.md`)
- Hex Exploration → Map API Route: requests hints (evidence: `README.md`)
- Explorer → AR Detection: spots and interacts (evidence: `README.md`)
- AR Detection → Offline Find Queue: queues offline finds (evidence: `README.md`)
- Offline Find Queue → Find API Route: submits when online (evidence: `README.md`)
- AR Detection → Find API Route: submits snapshot (evidence: `README.md`)
- Find API Route → Device Authentication: authenticates (evidence: `src/app/api/finds/route.ts`)
- Find API Route → Game Database: opens (evidence: `src/app/api/finds/route.ts`)
- Find API Route → Local Catalogue: loads (evidence: `src/app/api/finds/route.ts`)
- Find API Route → Find Resolution: dispatches (evidence: `src/app/api/finds/route.ts`)
- Find Resolution → Local Catalogue: resolves Local (evidence: `src/server/finds.ts`)
- Find Resolution → Hex Rarity and Place: gets hex info (evidence: `src/server/finds.ts`)
- Find Resolution → Loot and Progression: rolls rewards (evidence: `src/server/finds.ts`)
- Find Resolution → Game Database: records finds (evidence: `src/server/finds.ts`)
- Find Resolution → Shared Game Contracts: validates find data (evidence: `src/server/finds.ts`)
- Explorer → Collection and Profile: views collection (evidence: `README.md`)
- Collection and Profile → Profile Service: loads profile (evidence: `README.md`)
- Profile Service → Game Database: reads player history (evidence: `src/server/profile.ts`)
- Explorer → Leaderboard: views rankings (evidence: `README.md`)
- Leaderboard → Game Database: reads rankings (evidence: `src/server/leaderboard.ts`)
- Explorer → District Shop: browses cosmetics (evidence: `README.md`)
- District Shop → Shop and Equipping: requests shop (evidence: `README.md`)
- Shop and Equipping → Game Database: reads and writes (evidence: `src/server/shop.ts`)
- Shop and Equipping → Device Authentication: authenticates (evidence: `src/server/shop.ts`)
