How chiefwoods/splurge works
Main Components
• Frontend Application (Next.js App)
– Located in the “app” directory, this contains the Next.js pages (app/src/app), UI components (app/src/components and subdirectories), hooks, and other UI-related utilities.
– It handles routing (pages, dynamic routes for shoppers, stores, orders, etc.), state management, and user interactions.
– Uses libraries such as React, SWR for data fetching, and wallet-adapter for Solana wallet integration.
• On-chain Program (Solana Program)
– Found under the “programs/splurge” directory, it is written using Rust and Anchor.
– Contains various instructions (e.g., create_item, create_order, withdraw_earnings, etc.), state definitions, and utility functions.
– This is the backend “smart contract” that processes on-chain business logic.
• Blockchain and Ecosystem Layer
– The actual Solana blockchain is where on-chain transactions occur.
– External libraries and services (e.g., @solana/web3.js, @solana/spl-token, and external APIs like Helius) enable communication and transactions on-chain.
• Testing and Deployment Components
– “tests” directory holds functional tests (using Bun as the test runner) to simulate and verify actions performed by both the frontend and on-chain program.
– Configuration and deployment scripts (Anchor.toml, Cargo.toml, and migration scripts) help build and deploy the Solana program, while package.json and bun.lockb coordinate dependencies for the app.
Relationships & Data Flow
• User interactions on the frontend trigger API or direct blockchain calls using wallet adapters and Solana libraries.
• Data flows from the frontend’s UI components (including form dialogs and order management) to the blockchain via Solana web3 calls.
• The on-chain program listens for various instructions (e.g., create/store actions) and manipulates on-chain state accordingly.
• Tests simulate these interactions end-to-end by sending transactions and verifying state changes.
Architectural Patterns
• Separation of Concerns: Clear split between the user-facing Next.js frontend and the on-chain Solana backend.
• Modular Design: Both frontend and on-chain program are organized modularly (e.g., “app/src/components” for UI and “programs/splurge/src/instructions” for separate instructions).
• Use of Domain-Specific Frameworks: Anchor in the Rust program abstracts much of the on-chain logic into an easy-to-follow structure.
Technologies, Frameworks, & Libraries
• Frontend: Next.js, React, TypeScript, tailwind, and UI libraries (shadcn/ui).
• Blockchain & On-chain: Rust, Anchor, anchor-spl, and related crates.
• Communication: @solana/web3.js, wallet-adapter, and Solana-specific libraries.
• Testing: Bun is used as the test runner.