How usainbluntmx/atlas works
1. Repo shape: two main runtimes
- This is a Solana dApp with a hard split between:
- On-chain program in programs/atlas (Rust + Anchor)
- Client/game app in frontend (Next.js + TypeScript + Phaser)
- There is no custom backend or database; persistent state lives on Solana.
2. On-chain core: the atlas Anchor program
- programs/atlas/src/lib.rs is the protocol boundary.
- It exposes the world logic described in the README: initialize the shared world, initialize the leaderboard, mint a character NFT for a wallet, and collect resources.
- This program is the source of truth for:
- global world state
- per-wallet character state
- leaderboard updates
- resource availability / depletion
3. State model: PDA-backed accounts
- The architecture centers on deterministic PDAs:
- WorldState seeded by ["world"]
- Character seeded by ["character", owner]
- Leaderboard seeded by ["leaderboard"]
- These account boundaries are important because the frontend reads and writes them directly via Anchor; there is no intermediary API layer.
4. Frontend shell: Next.js as orchestration layer
- frontend/app/page.tsx is the main client entry point and likely coordinates wallet state, game state, and on-chain actions.
- frontend/app/layout.tsx and frontend/app/globals.css provide the app shell and global styling.
- frontend/components/WalletProvider.tsx wraps Solana wallet connectivity, which is the root dependency for all chain interactions.
5. Game rendering: Phaser embedded inside React
- frontend/components/GameCanvas.tsx mounts the Phaser game inside the Next.js UI.
- The actual game runtime is in frontend/game/main.ts, with scenes under frontend/game/scenes/.
- BootScene.ts is the startup/bootstrap layer, and WorldScene.ts is the active play world.
- frontend/game/objects/Player.ts defines the player entity and movement/animation behavior.
6. UI overlay: game HUD and transaction feedback
- frontend/components/HUD.tsx provides the in-game interface: score, progress, and likely world status.
- frontend/components/TxToast.tsx surfaces transaction hashes/links so user actions remain verifiable on Solscan.
- frontend/components/Landing.tsx is the non-game presentation layer for onboarding and protocol explanation.
7. Chain interaction layer
- frontend/lib/anchor.ts is the client-side Anchor integration layer: program ID, IDL access, and PDA helpers.
- frontend/lib/constants.ts centralizes protocol and app configuration.
- frontend/lib/arweave.ts handles NFT metadata/storage integration, which matters because character minting depends on off-chain asset metadata even though ownership/state are on Solana.
8. Primary data flow: wallet → game action → transaction → updated state
- User connects a wallet through the provider.
- The UI/game emits actions such as mint character or collect resource.
- The frontend constructs an Anchor transaction and sends it to Solana Devnet.
- The program mutates PDA accounts.
- The frontend re-reads account state and updates the HUD/game world; tx hashes are surfaced to the player.
9. Gameplay-state coupling
- The Phaser world is not just cosmetic; it reflects shared on-chain state.
- Resource collection affects persistent world availability, not just local score.
- The leaderboard is also on-chain, so competition is globally shared across sessions and devices.
10. Deployment and network assumptions
- The protocol is configured for Solana Devnet, not mainnet.
- migrations/deploy.ts is the Anchor deployment path for the program.
- The README’s program ID and Solscan links indicate the deployed on-chain artifacts are part of the architecture, not just local dev scaffolding.
11. Testing and verification
- tests/atlas.ts is the program test suite, likely validating instruction behavior and PDA/account transitions.
- The repo also includes docs/architecture.png, reinforcing that the intended architecture is a small set of deterministic on-chain accounts with a thin interactive client.
12. Diagram boundary summary
- Draw three major boxes:
- Solana/Anchor program for authoritative state and rules
- Next.js client shell for wallet, app state, and UI composition
- Phaser game runtime embedded in the client for rendering and input
- Then show two external integrations:
- Wallet adapter / Phantom-compatible wallets
- Arweave for NFT metadata
- The key architectural principle is that the game is persistent and shared because the world state is stored on-chain, while the frontend is a stateless presenter and transaction initiator.
Main entry points: lib.rs atlas program · page.tsx App page · WorldScene.ts World scene · anchor.ts Anchor client
Components 26
Solana program
Anchor-based source of truth for world state and gameplay rules.
- atlas program · Protocol boundary and on-chain instruction entrypoint.
programs/atlas/src/lib.rs - World state · Shared global world state seeded by world.
programs/atlas/src/lib.rs - Character state · Per-wallet character account seeded by character and owner.
programs/atlas/src/lib.rs - Leaderboard · Global ranking account seeded by leaderboard.
programs/atlas/src/lib.rs - World logic · Initializes world and handles resource collection and depletion.
programs/atlas/src/lib.rs - Mint character · Creates a character NFT tied to a wallet and metadata.
programs/atlas/src/lib.rs - Score updates · Updates the on-chain leaderboard from gameplay actions.
programs/atlas/src/lib.rs
Frontend client
Next.js shell embedding the Phaser game and wallet interactions.
- App page · Main client entry that coordinates wallet, game, and chain actions.
frontend/app/page.tsx - App shell · Root UI layout for the client application.
frontend/app/layout.tsx - Wallet provider · Wraps Solana wallet connectivity for the client UI.
frontend/components/WalletProvider.tsx - Game canvas · Mounts the Phaser runtime inside the React interface.
frontend/components/GameCanvas.tsx - HUD · Displays score, progress, and world status.
frontend/components/HUD.tsx - Landing · Non-game presentation layer for onboarding and explanation.
frontend/components/Landing.tsx - Tx toast · Surfaces transaction hashes and verification links.
frontend/components/TxToast.tsx - Anchor client · Program ID, IDL access, and PDA helper layer.
frontend/lib/anchor.ts - Constants · Centralized protocol and application configuration.
frontend/lib/constants.ts - Arweave client · Handles NFT metadata and off-chain asset storage integration.
frontend/lib/arweave.ts - Game runtime · Bootstraps the embedded Phaser game.
frontend/game/main.ts - Boot scene · Startup and bootstrap scene for the game.
frontend/game/scenes/BootScene.ts - World scene · Active gameplay scene that reflects on-chain world state.
frontend/game/scenes/WorldScene.ts - Player · Player movement and animation behavior.
frontend/game/objects/Player.ts
Build and tests
Deployment and verification tooling around the main runtimes.
- Deploy script · Program deployment path for the on-chain contract.
migrations/deploy.ts - Program tests · Validates instructions and account transitions.
tests/atlas.ts
External services
Wallets, Solana network, and off-chain metadata storage.
- Wallets · Phantom-compatible wallets used for signing transactions.
- Solana Devnet · Target network for program state and transactions.
- Arweave · External metadata storage used for character NFT assets.
Connections 28
- atlas program → World state: owns · Defines and mutates the shared world PDA.
- atlas program → Character state: owns · Defines and mutates per-wallet character accounts.
- atlas program → Leaderboard: owns · Defines and mutates the global leaderboard PDA.
- atlas program → World logic: exposes · Exports world initialization and resource collection logic.
- atlas program → Mint character: exposes · Exports the character minting instruction.
- atlas program → Score updates: exposes · Exports leaderboard update behavior.
- App page → Wallet provider: uses · Relies on wallet connection for all chain actions.
- App page → Game canvas: hosts · Composes the embedded game runtime.
- App page → HUD: renders · Surfaces gameplay and chain status.
- App page → Landing: shows · Provides onboarding before or outside gameplay.
- App page → Tx toast: surfaces · Shows transaction feedback to the player.
- Game canvas → Game runtime: boots · Creates the Phaser runtime inside the React host.
- Game runtime → Boot scene: starts · Initial scene bootstrap.
- Boot scene → World scene: hands off · Transitions into the active play scene.
- World scene → Player: spawns · Uses the player entity for movement and animation.
- World scene → Anchor client: reads/writes · Reads on-chain state and sends gameplay transactions.
- Anchor client → atlas program: calls · Builds transactions against the Anchor program.
- Anchor client → Constants: configures · Uses shared IDs, network, and app settings.
- Anchor client → Arweave client: fetches · Resolves metadata needed for character minting.
- Wallet provider → Wallets: connects · Integrates with external signing wallets.
- Anchor client → Solana Devnet: submits · Sends transactions and account reads to Solana Devnet.
- Arweave client → Arweave: stores · Uploads or resolves NFT metadata assets.
- Deploy script → atlas program: deploys · Deploys the on-chain program.
- Program tests → atlas program: verifies · Exercises instructions and PDA transitions.
- World scene → World state: syncs · Reflects persistent world availability in gameplay.
- World scene → Character state: syncs · Loads per-wallet progress and character status.
- World scene → Leaderboard: syncs · Displays global competition state.
- App page → Anchor client: orchestrates · Coordinates UI actions with chain requests.