How jainsamyak15/pepper works
Project type and purpose
• This is a full-stack decentralized application (dApp) built with Next.js (App Router) as the frontend, React components, Tailwind CSS, and a set of Solidity smart contracts under contracts/.
• Purpose: A peer-to-peer sports prediction market (“Pepper”) where official team managers create markets and fans place back/lay bets using team-specific Fan Tokens on the Chiliz blockchain.
File structure
• Top-level:
• contracts/ – Solidity contracts defining market logic, roles, fees, matching engine.
• scripts/deploy.js – Deployment script for the smart contract.
• src/app/ – Next.js pages (App Router) for public pages (/markets, /teams, /create-market, /admin/dashboard, etc.).
• src/components/ – Reusable UI components (market cards, order book, forms, wallet connector).
• src/hooks/ – Custom React hooks (useWallet, useMarkets, useTeams) for state and contract interactions.
• src/utils/contract.ts – Ethers/Web3 interface to the deployed contract.
• Config files: Next.js (next.config.mjs), Tailwind (tailwind.config.ts), ESLint/TypeScript settings.
Key insights from the README
• Roles: Admin, Team Manager, Users
• Core flows: wallet connection → browse/create markets → place/cancel orders → match engine → resolve markets → redeem winnings.
• On-chain order matching, fee collection, and role-based access control.
Main components
a. Frontend (Next.js + React)
• Pages (src/app/*)
• UI Components (src/components/*)
• Hooks (src/hooks/*)
b. Blockchain Layer
• Smart Contract (contracts/Pepper.sol) with modules: RBAC, market factory, order matching, resolution, fee logic.
• Deployment (scripts/deploy.js) to the Chiliz EVM.
c. Wallet Provider
• MetaMask or any Web3 wallet (interfaced via useWallet)
d. External Services (optional/future)
• Sports data API (for real-time feeds)
• Governance/voting contracts
Relationships and data flows
• Frontend → Web3 Provider (injected by MetaMask)
• Web3 Provider → Ethers.js → Smart Contract on Chiliz blockchain (JSON-RPC)
• Smart Contract → on-chain state (markets, orders, roles, token balances)
• Optional: off-chain APIs → Frontend (for sports data, analytics)
Architectural patterns & design principles
• File-based routing (Next.js App Router) – separate pages by directory.
• Component hierarchy – <Header>, <Footer>, <MarketCard>, <OrderBook>, <PlaceOrderForm>.
• Hook abstraction – encapsulate contract reads/writes in useMarkets and useWallet.
• Separation of concerns – UI vs. data layer (Ethers abstractions in src/utils/contract.ts).
• On-chain business logic – state machine for market lifecycle; no central server liability.
Technologies & frameworks
• Next.js (React, App Router, SSR/SSG)
• Tailwind CSS for styling
• Ethers.js for blockchain interactions
• Solidity for smart contracts
• Node.js scripts for contract deployment
Essential elements
• Component boundaries (Frontend vs. Blockchain)
• Deployment pipeline: scripts/deploy.js → Chiliz test/mainnet