How ayan-choradia/positive_slope works
Project Type and Purpose
• Full-stack Ethereum DApp for tracking medicine authenticity.
• Frontend: Single-page application built with Vite.
• Blockchain Layer: Smart contracts deployed via Truffle on Ethereum.
• No traditional backend server; the blockchain itself is the data layer.
Main Components
a. Frontend (UI)
• Vite dev server / build artifact.
• HTML/CSS/JS pages (index.html, details.html, timeline.html).
• JavaScript modules (auth.js, details.js, timeline.js, main.js).
• Web3/Ethers.js integration for blockchain communication.
b. Smart Contracts
• contracts/*.sol (e.g., ProductVerification.sol, Product_Exist.sol, etc.)
• Build artifacts (build/contracts/*.json) containing ABI + deployed addresses.
c. Deployment & Development Tools
• Truffle framework: migrations (migrations/*.js), truffle-config.js.
• Tests (test/metacoin.js).
• Node/NPM (package.json, node_modules).
d. Ethereum Network
• Local test network (Ganache) or public testnet/mainnet.
e. Wallet Provider
• MetaMask or any Web3 provider for user authentication & transaction signing.
Relationships & Data Flow
1. Developer runs truffle migrate → Truffle migrations deploy smart contracts to Ethereum.
2. Frontend (in user’s browser) loads built UI and connects to a Web3 provider.
3. User actions on UI (e.g., “Submit Medicine Data”) → Web3/Ethers.js → Smart Contract function call → Transaction sent to Ethereum network.
4. Ethereum processes transaction, updates contract state. Events emitted.
5. Frontend listens to contract events or reads contract state via Web3 calls → updates UI (timeline, details).
6. Build artifacts (ABI + addresses) enable the frontend to instantiate contract wrappers.
Architectural Patterns & Design Principles
• Separation of Concerns: UI layer vs. blockchain (data & business logic) layer.
• Immutable Data Store: Smart contracts as the single source of truth.
• Event-driven updates: Contracts emit events to signal new data.
• Modular contract design: multiple contracts (ProductVerification, Product_Exist, etc.) for clarity.
• CI/CD hooks: Truffle tests ensure contract correctness before deployment.
Technologies & Frameworks
• Solidity & OpenZeppelin (standard libraries if used).
• Truffle (migrations, testing).
• Ganache or Infura (Ethereum node provider).
• Web3.js or Ethers.js for frontend/blockchain interface.
• Vite for frontend bundling.
• HTML5/CSS3/Vanilla JS.
Final Checklist
• All main components present (Frontend, Smart Contracts, Ethereum Network, Dev Tools).
• Labels for ABIs, migrations, tests.
• Notes on event subscriptions and on-chain state reads.