How sidharth0909/disaster-relief-fund works
Project type and purpose
• This is a full-stack decentralized application (DApp) for blockchain-based crowdfunding.
• Purpose: allow users to view campaigns, connect via MetaMask, donate ETH, and allow admins to create/manage campaigns and withdraw funds.
File structure
• Top level:
• blockchain/ – Truffle project with contracts, migrations, build artifacts, Ganache data directory
• public/ & src/ – React single-page-app (SPA) structure
• src/abis/ – compiled contract ABIs for Web3 integration
• src/components/ – React UI components (DisasterFund)
• src/App.js, index.js – app initialization, Web3/provider setup
• Config/build scripts:
• truffle-config.js – network & compiler settings
• package.json – React dependencies and Truffle commands
• ganache-cli invocation stores chain data in blockchain/ganache-data/
README insights
• Technology stack: Solidity, Truffle, Ganache, React.js, Web3.js, MetaMask, Chart.js
• Execution flow: Ganache → Truffle migrate → React start → user/admin operations via UI → Web3.js → Smart Contract
• Smart contract functions define the core business logic
Main components & their interactions
a. Frontend (React SPA)
• Components: ConnectWallet, CampaignList, DonateButton, AdminDashboard (Chart.js analytics)
• Asset: public/index.html, CSS files, Web3 provider setup in App.js
b. Web3 Layer
• Web3.js library + MetaMask (injected provider)
• src/abis/DisasterReliefFund.json provides contract ABI & network addresses
c. Smart Contract (Solidity)
• DisasterReliefFund.sol deployed via Truffle migrations
• Business logic: createCampaign, donate, withdrawFunds, getCampaigns
d. Blockchain Node
• Ganache (local Ethereum network) persists chain data under blockchain/ganache-data
• Truffle migrations drive deployment to this node
e. External Integrations (optional)
• Infura/Goerli (for testnet deployment) via HDWalletProvider in truffle-config.js
• MetaMask as user’s wallet interface
Interactions:
1. User clicks “Connect Wallet” → MetaMask injects provider → React stores account
2. User/Admin calls action (donate, createCampaign, withdraw) → UI calls Web3.js methods on contract → Transaction → Ganache processes and persists on blockchain
3. UI polls or subscribes to events or calls getCampaigns() to refresh state → Chart.js visualizes progress
Architectural patterns & design principles
• Layered architecture: UI layer (React) → Service layer (Web3.js) → Smart contract layer → Data layer (blockchain state)
• Separation of concerns:
• Contract logic isolated in Solidity
• UI and business workflows in React components
• Build/deploy steps in Truffle migrations
• Modularization: React components in src/components, ABIs in src/abis, migrations in blockchain/migrations
• External “MetaMask Wallet”
• (Optional) External “Infura / Testnet” for production/testnet deployment
• Frontend in blue, Blockchain & contracts in green, External services in yellow
d. Labels:
• Call out key technologies: React.js, Web3.js, Truffle, Ganache, Solidity, Chart.js
• Data stores (chain state) vs. off-chain UI state