How ayushmankoley/flipzy works
Project Type & Purpose
• Flipzy is a decentralized, full-stack coin-flip gambling dApp on the Aptos blockchain.
• Frontend: React + TypeScript + Vite UI that interacts with wallets and the blockchain.
• Backend: On-chain Move smart contract handling game logic, randomness, payouts.
Top-Level Components
A. Frontend Client
• React app (Vite + TS) under /frontend
• UI Components: game screens, headers, banners, message board, coin animation
• Wallet Integration: WalletProvider.tsx, aptos-wallet-adapter
• Utility Modules:
– aptosClient.ts and surfClient.ts for RPC/transaction calls
– ABIs: coin_abi.ts, message_board_abi.ts
– View-functions: e.g. flipCoin.ts, getGameState.ts
B. Smart Contract Layer
• Move modules under /contract/sources/coinflip.move
• Test suite: /contract/tests/test_end_to_end.move
• Scripts for compile/publish/test/upgrade under /scripts/move
C. Blockchain Infrastructure
• Aptos Network (Testnet/Mainnet)
• Aptos CLI for deployment
• GraphQL/RPC API endpoint
D. Deployment & CI/CD
• Netlify for frontend (netlify.toml, _redirects)
• npm scripts: build, dev, move:compile/test/publish/upgrade
E. Static Assets & Config
• Tailwind + Shadcn UI styling (tailwind.config.js)
• Env config (.env, VITE_ variables)
Relationships & Data Flows
1. User loads React app (Netlify CDN) → UI renders pages/components.
2. User connects wallet (via WalletProvider) → session established.
3. To display existing state, app calls view-functions against Aptos RPC or GraphQL.
4. On “Flip Coin” action:
• UI builds a transaction using client lib (aptosClient/surfClient) + ABI.
• Transaction is sent to user’s wallet → signed → broadcast to Aptos network.
5. Aptos validators process flip_coin() (or degen/whale) in Move contract → emit events.
6. Frontend listens or polls for events/state changes → updates RecentPlays feed + user balance.
Architectural Patterns & Principles
• Separation of concerns: UI layer vs. blockchain logic.
• Modular React components + utility hooks for reuse (ui/, components/, view-functions/).
• Scripted contract lifecycle: compile → test → deploy → upgrade.
• Env-driven configuration for testnet vs. mainnet.
• Event-driven updates via blockchain events or GraphQL subscriptions.
Final Checklist
[ ] Main components labeled
[ ] Key tech (React, Move, Netlify, Tailwind, Aptos CLI) called out
[ ] Notes on compile/test/deploy pipeline