How dappuniversity/decentratwitter works
Main Components
• Smart Contract Layer:
• “contracts” directory containing Solidity code.
• Role of smart contracts in managing the decentralized aspects (e.g., tweet data, user interactions).
• Blockchain Development and Deployment:
• Hardhat development environment (hardhat.config.js, local blockchain node).
• Deploy script in the “scripts” directory that migrates contracts.
• Local blockchain (simulated network when using npx hardhat node, with chainID 31337).
• Frontend Application:
• “public” folder for static HTML (index.html, manifest.json) and the “src” folder for React components (App.js, Home.js, Profile.js).
• Use of React Router for navigation between pages.
• Blockchain Interaction:
• Ethers.js component that bridges the frontend to the smart contracts via blockchain calls.
• Testing Environment:
• Briefly mention the “test” folder where the smart contract tests are organized.
• External Dependencies:
• IPFS for metadata storage, as per the README, which may be considered an external service storing off-chain data.
Relationships & Data Flow
• User actions in the frontend triggering events that interact with Ethers.js.
• Ethers.js sending transactions or queries to the smart contract layer on the blockchain.
• Smart contract responses/transaction confirmations flowing back through Ethers.js to the frontend.
• Off-chain data flow to/from IPFS (e.g., metadata storage related to tweets).
• That the Hardhat node simulates the blockchain environment, letting developers deploy and test contracts locally.
Architectural Patterns & Design Principles
• A clear separation of concerns:
• Frontend (UI, routing, state management) versus blockchain (contracts, tests, deployments).
• That the project follows a multi-tier architecture:
• Presentation Layer (React frontend)
• Blockchain/Smart Contract Layer (Solidity contracts executed on a private Hardhat network)
• Integration Layer (Ethers.js that acts as a bridge)
• Mention that testing is handled independently for smart contract logic through Hardhat’s testing framework.
Technical Stack and Tools
• Specific technologies alongside each component:
• Solidity (Smart Contracts)
• Hardhat (Development blockchain, deploy script, config)
• React (Frontend framework, hosted in the src/public folders)
• Ethers.js (Blockchain interaction library)
• IPFS (Off-chain storage for metadata)
• React Router (Navigation within the frontend)
• NodeJS and npm (Project dependency management and script execution)
Final Recommendations
• Detail each component to capture both the development (Hardhat node, deploy script, test suite) and runtime (React app, wallet connection via Metamask) aspects.
• Tailor the explanation of component interactions to both development and user usage scenarios – from contract deployment, testing, to frontend interactions.
Happy diagramming!