How parth-420/goalchain works
Main Components
• Smart Contract Module:
• Located in the "contract" directory.
• Implemented using Anchor and Rust.
• Contains programs (e.g., the “stake” program) and tests (TypeScript-based tests).
• Key functions: stake_task and complete_task.
• Blockchain Network:
• Represents the Solana blockchain (Devnet/Mainnet) where the smart contract is deployed.
• Relationship to the smart contract by showing deployment tools (Anchor CLI, Solana CLI).
• Frontend Application:
• Found within the "ui" directory.
• Built using Next.js, leveraging the App Router, custom components, hooks, and a TailwindCSS configuration.
• Contains the UI elements (pages, layouts, components, and utility libraries) that interact with the blockchain.
• Integration/API Layer:
• Although still under process, there’s an intended integration where Next.js API routes will interact directly with the smart contract.
• This layer is crucial for triggering smart contract instructions (like stake_task and complete_task) from the frontend.
Relationships and Data Flow
• User Interaction:
• The end user interacts with the Next.js frontend UI (web browser).
• The UI captures user actions such as creating or completing a goal.
• API or Direct Wallet Integration:
• (When completed) the frontend will communicate with an API layer or directly use wallet interactions to sign transactions.
• This communication flows to trigger the smart contract functions.
• Blockchain Communication:
• Transactions are sent to the Solana network where the smart contract processes them.
• The response (e.g., funds returned on successful completion) is propagated back through the API layer to update the UI.
Important Architectural Patterns
• Separation of Concerns:
• Distinguish between the smart contract (backend on blockchain) and the UI (frontend web application).
• Decentralized Architecture:
• That part of the logic (goal staking and verification) resides on the blockchain, ensuring trustless operations.
• Future API Integration:
• Clearly denote that an API layer will mediate some interactions between the UI and the blockchain, an important design consideration for maintaining clear boundaries.