# ankushkun/pixels.earth architecture

> Architecture diagram of the GitHub repository ankushkun/pixels.earth, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ankushkun/pixels.earth
- Repository: https://github.com/ankushkun/pixels.earth

## Overview

Magicplace is a decentralized, Earth-mapped pixel canvas. Players explore the map, select pixels or import pixel art, and place pixels through the canvas UI and Magicplace program client; session keys support signing, while the on-chain program and MagicBlock ephemeral rollups provide the documented pixel and shard experience. Supporting branches cover map search and geocoding, shard overlays and onboarding, and a server-side chain indexer with analytics APIs. The excerpts show the main UI composition and several client, session, and indexer relationships; unsampled internals are represented cautiously.

Main entry points: [`app/src/components/pixel-canvas.tsx`](https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/pixel-canvas.tsx) (Pixel Canvas), [`app/src/hooks/use-magicplace-program.ts`](https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-magicplace-program.ts) (Program Client), [`app/src/App.tsx`](https://github.com/ankushkun/pixels.earth/blob/main/app/src/App.tsx) (App Composition), [`app/src/components/image-upload-dialog.tsx`](https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/image-upload-dialog.tsx) (Image Import)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_canvas["Canvas Experience"]
  node_app["App Composition<br/>[App.tsx]"]
  node_pixel_canvas["Pixel Canvas<br/>[pixel-canvas.tsx]"]
  node_shard_overlay["Shard Overlay"]
  node_tour["Guided Tour<br/>[tour.tsx]"]
  node_tour_state["Tour State<br/>[use-tour.ts]"]
  node_image_import["Image Import"]
  node_pixel_conversion["Pixel Conversion"]
  node_palette["Color Palette<br/>[colors.ts]"]
end

subgraph group_geo["Map and Location"]
  node_location_search["Location Search"]
  node_map_state["Map State<br/>[use-map.ts]"]
  node_projection["Map Projection<br/>[projection.ts]"]
  node_reverse_geocode["Reverse Geocoding<br/>[reverse-geocode.ts]"]
  node_geocode_core["Geocoding Core<br/>[geocode-core.ts]"]
end

subgraph group_chain["Wallet and Chain"]
  node_wallet_ui["Wallet Connect<br/>[wallet-connect.tsx]"]
  node_session_balance["Session Balance"]
  node_session_key["Session Keys"]
  node_program_client["Program Client"]
  node_program_events["Program Events"]
  node_program_idl["Program Interface<br/>[magicplace.ts]"]
  node_onchain_program["Magicplace Program<br/>[lib.rs]"]
end

subgraph group_server["Indexing and Analytics"]
  node_api_server["Web API Server<br/>[index.ts]"]
  node_indexer["Chain Indexer<br/>[indexer.ts]"]
  node_database[("Analytics Database<br/>[db.ts]")]
end

node_player(("Player"))
node_solana{{"Solana / MagicBlock"}}

node_player -->|"opens"| node_app
node_app -->|"renders"| node_pixel_canvas
node_app -->|"provides session"| node_session_balance
node_app -->|"renders"| node_tour
node_pixel_canvas -->|"renders"| node_shard_overlay
node_pixel_canvas -->|"opens"| node_image_import
node_image_import -->|"converts image"| node_pixel_conversion
node_image_import -->|"uses program"| node_program_client
node_pixel_canvas -->|"uses colors"| node_palette
node_tour -->|"uses state"| node_tour_state
node_pixel_canvas -->|"uses map"| node_map_state
node_pixel_canvas -->|"converts coordinates"| node_projection
node_pixel_canvas -->|"looks up places"| node_reverse_geocode
node_reverse_geocode -->|"uses core"| node_geocode_core
node_location_search -->|"converts coordinates"| node_projection
node_player -->|"searches places"| node_location_search
node_pixel_canvas -->|"places pixels"| node_program_client
node_pixel_canvas -->|"offers wallet access"| node_wallet_ui
node_session_balance -->|"uses session key"| node_session_key
node_program_client -->|"signs with"| node_session_key
node_program_client -->|"uses interface"| node_program_idl
node_program_client -->|"reads and submits"| node_solana
node_program_client -.->|"invokes program"| node_onchain_program
node_pixel_canvas -->|"subscribes to events"| node_program_events
node_api_server -->|"starts indexer"| node_indexer
node_api_server -->|"queries analytics"| node_database
node_indexer -->|"writes indexed events"| node_database
node_indexer -->|"fetches chain data"| node_solana
node_player -.->|"requests analytics"| node_api_server

click node_app "https://github.com/ankushkun/pixels.earth/blob/main/app/src/App.tsx"
click node_pixel_canvas "https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/pixel-canvas.tsx"
click node_shard_overlay "https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/shard-grid-overlay.tsx"
click node_tour "https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/tour.tsx"
click node_tour_state "https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-tour.ts"
click node_image_import "https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/image-upload-dialog.tsx"
click node_pixel_conversion "https://github.com/ankushkun/pixels.earth/blob/main/app/src/lib/image-to-pixel-art.ts"
click node_palette "https://github.com/ankushkun/pixels.earth/blob/main/app/src/lib/colors.ts"
click node_location_search "https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/location-search.tsx"
click node_map_state "https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-map.ts"
click node_projection "https://github.com/ankushkun/pixels.earth/blob/main/app/src/lib/projection.ts"
click node_reverse_geocode "https://github.com/ankushkun/pixels.earth/blob/main/app/src/lib/reverse-geocode.ts"
click node_geocode_core "https://github.com/ankushkun/pixels.earth/blob/main/app/src/lib/geocode-core.ts"
click node_wallet_ui "https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/wallet-connect.tsx"
click node_session_balance "https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/session-balance-provider.tsx"
click node_session_key "https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-session-key.tsx"
click node_program_client "https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-magicplace-program.ts"
click node_program_events "https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-magicplace-events.ts"
click node_program_idl "https://github.com/ankushkun/pixels.earth/blob/main/app/src/idl/magicplace.ts"
click node_onchain_program "https://github.com/ankushkun/pixels.earth/blob/main/programs/magicplace/src/lib.rs"
click node_api_server "https://github.com/ankushkun/pixels.earth/blob/main/app/src/index.ts"
click node_indexer "https://github.com/ankushkun/pixels.earth/blob/main/app/src/server/indexer.ts"
click node_database "https://github.com/ankushkun/pixels.earth/blob/main/app/src/server/db.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_pixel_canvas,node_shard_overlay,node_tour,node_tour_state,node_image_import,node_pixel_conversion,node_palette toneBlue
class node_location_search,node_map_state,node_projection,node_reverse_geocode,node_geocode_core toneAmber
class node_wallet_ui,node_session_balance,node_session_key,node_program_client,node_program_events,node_program_idl,node_onchain_program toneMint
class node_api_server,node_indexer,node_database toneRose
class node_player,node_solana toneIndigo
```

## Components

### Canvas Experience

- [App Composition](https://github.com/ankushkun/pixels.earth/blob/main/app/src/App.tsx): `app/src/App.tsx`
- [Pixel Canvas](https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/pixel-canvas.tsx): `app/src/components/pixel-canvas.tsx`
- [Shard Overlay](https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/shard-grid-overlay.tsx): `app/src/components/shard-grid-overlay.tsx`
- [Guided Tour](https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/tour.tsx): `app/src/components/tour.tsx`
- [Tour State](https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-tour.ts): `app/src/hooks/use-tour.ts`
- [Image Import](https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/image-upload-dialog.tsx): `app/src/components/image-upload-dialog.tsx`
- [Pixel Conversion](https://github.com/ankushkun/pixels.earth/blob/main/app/src/lib/image-to-pixel-art.ts): `app/src/lib/image-to-pixel-art.ts`
- [Color Palette](https://github.com/ankushkun/pixels.earth/blob/main/app/src/lib/colors.ts): `app/src/lib/colors.ts`

### Map and Location

- [Location Search](https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/location-search.tsx): `app/src/components/location-search.tsx`
- [Map State](https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-map.ts): `app/src/hooks/use-map.ts`
- [Map Projection](https://github.com/ankushkun/pixels.earth/blob/main/app/src/lib/projection.ts): `app/src/lib/projection.ts`
- [Reverse Geocoding](https://github.com/ankushkun/pixels.earth/blob/main/app/src/lib/reverse-geocode.ts): `app/src/lib/reverse-geocode.ts`
- [Geocoding Core](https://github.com/ankushkun/pixels.earth/blob/main/app/src/lib/geocode-core.ts): `app/src/lib/geocode-core.ts`

### Wallet and Chain

- [Wallet Connect](https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/wallet-connect.tsx): `app/src/components/wallet-connect.tsx`
- [Session Balance](https://github.com/ankushkun/pixels.earth/blob/main/app/src/components/session-balance-provider.tsx): `app/src/components/session-balance-provider.tsx`
- [Session Keys](https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-session-key.tsx): `app/src/hooks/use-session-key.tsx`
- [Program Client](https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-magicplace-program.ts): `app/src/hooks/use-magicplace-program.ts`
- [Program Events](https://github.com/ankushkun/pixels.earth/blob/main/app/src/hooks/use-magicplace-events.ts): `app/src/hooks/use-magicplace-events.ts`
- [Program Interface](https://github.com/ankushkun/pixels.earth/blob/main/app/src/idl/magicplace.ts): `app/src/idl/magicplace.ts`
- [Magicplace Program](https://github.com/ankushkun/pixels.earth/blob/main/programs/magicplace/src/lib.rs): `programs/magicplace/src/lib.rs`

### Indexing and Analytics

- [Web API Server](https://github.com/ankushkun/pixels.earth/blob/main/app/src/index.ts): `app/src/index.ts`
- [Chain Indexer](https://github.com/ankushkun/pixels.earth/blob/main/app/src/server/indexer.ts): `app/src/server/indexer.ts`
- [Analytics Database](https://github.com/ankushkun/pixels.earth/blob/main/app/src/server/db.ts): `app/src/server/db.ts`

### Other components

- **Player**
- **Solana / MagicBlock**

## Connections

- Player → App Composition: opens (evidence: `app/src/App.tsx`)
- App Composition → Pixel Canvas: renders (evidence: `app/src/App.tsx`)
- App Composition → Session Balance: provides session (evidence: `app/src/App.tsx`)
- App Composition → Guided Tour: renders (evidence: `app/src/App.tsx`)
- Pixel Canvas → Shard Overlay: renders (evidence: `app/src/components/pixel-canvas.tsx`)
- Pixel Canvas → Image Import: opens (evidence: `app/src/components/pixel-canvas.tsx`)
- Image Import → Pixel Conversion: converts image (evidence: `app/src/components/image-upload-dialog.tsx`)
- Image Import → Program Client: uses program (evidence: `app/src/components/image-upload-dialog.tsx`)
- Pixel Canvas → Color Palette: uses colors (evidence: `app/src/components/pixel-canvas.tsx`)
- Guided Tour → Tour State: uses state (evidence: `app/src/components/tour.tsx`)
- Pixel Canvas → Map State: uses map (evidence: `app/src/components/pixel-canvas.tsx`)
- Pixel Canvas → Map Projection: converts coordinates (evidence: `app/src/components/pixel-canvas.tsx`)
- Pixel Canvas → Reverse Geocoding: looks up places (evidence: `app/src/components/pixel-canvas.tsx`)
- Reverse Geocoding → Geocoding Core: uses core (evidence: `app/src/lib/reverse-geocode.ts`)
- Location Search → Map Projection: converts coordinates (evidence: `app/src/components/location-search.tsx`)
- Player → Location Search: searches places (evidence: `app/src/components/location-search.tsx`)
- Pixel Canvas → Program Client: places pixels (evidence: `app/src/components/pixel-canvas.tsx`)
- Pixel Canvas → Wallet Connect: offers wallet access (evidence: `app/src/components/pixel-canvas.tsx`)
- Session Balance → Session Keys: uses session key (evidence: `app/src/components/session-balance-provider.tsx`)
- Program Client → Session Keys: signs with (evidence: `app/src/hooks/use-magicplace-program.ts`)
- Program Client → Program Interface: uses interface (evidence: `app/src/hooks/use-magicplace-program.ts`)
- Program Client → Solana / MagicBlock: reads and submits (evidence: `app/src/hooks/use-magicplace-program.ts`)
- Program Client → Magicplace Program: invokes program
- Pixel Canvas → Program Events: subscribes to events (evidence: `app/src/components/pixel-canvas.tsx`)
- Web API Server → Chain Indexer: starts indexer (evidence: `app/src/index.ts`)
- Web API Server → Analytics Database: queries analytics (evidence: `app/src/index.ts`)
- Chain Indexer → Analytics Database: writes indexed events (evidence: `app/src/server/indexer.ts`)
- Chain Indexer → Solana / MagicBlock: fetches chain data (evidence: `app/src/server/indexer.ts`)
- Player → Web API Server: requests analytics
