How daltonic/votee works
Project type and purpose
• Type: Full-stack decentralized application (dApp).
• Purpose: Allow users to create polls, register candidates, and vote on the Solana blockchain via a React/Next.js frontend and an on-chain Anchor/Rust program.
File structure
• Top-level directories
• src/app – Next.js 13 “app” directory contains pages (page.tsx), layouts, global CSS, and React components.
• anchor – Anchor Solana program, migrations, IDL and type-binding generation, tests for the on-chain logic.
• public, screenshots – static assets.
• Key patterns
• Frontend follows a component-based React + Redux Toolkit structure, with services (services/blockchain.service.tsx) handling RPC calls.
• Blockchain uses Anchor: programs in anchor/programs/votee/src, migrations in anchor/migrations, and IDL/types in anchor/target.
• Config & build files
• next.config.mjs, tsconfig.json, Tailwind config, GitHub workflows for CI.
• .env for RPC URL and wallet configuration.
Extract additional insights from the README
• Architecture: Clear split between frontend (Next.js, React, Redux) and on-chain program (Anchor + Rust).
• Tech stack:
• Frontend: Next.js, React, Redux, TypeScript, Tailwind CSS.
• Blockchain: Solana Web3.js, @coral-xyz/anchor, Solana Wallet Adapter.
• Wallet: Phantom (via Wallet Adapter).
• Workflow:
1. Developer runs solana-test-validator.
2. Deploy Anchor program (anchor/migrations/deploy.ts).
3. Frontend uses IDL (anchor/target/idl/votee.json) & TypeScript bindings (anchor/target/types/votee.ts) to interact.
Main components and their relationships
a. User & Wallet
• User’s browser with Phantom wallet extension.
• Solana Wallet Adapter handles connection and signature requests.
b. Frontend (Next.js)
• React UI components (pages, modals)
• Redux store tracks global state (connected wallet, polls, candidates).
• blockchain.service.tsx sends transactions and reads chain state via RPC.
• Consumes Anchor IDL & types for type-safe on-chain calls.
c. Solana Test Validator / Cluster
• Local RPC node (NEXT_PUBLIC_RPC_URL=http://127.0.0.1:8899).
• Provides JSON-RPC and transaction execution.
d. On-chain Anchor Program
• Rust code: instructions for initialize, create_poll, register_candidate, vote.
• State accounts: Poll, Candidate, Counter, Voter, Registration.
• Anchor framework handles account serialization, security checks.
e. DevOps / CI
• GitHub Workflows for testing both frontend and Anchor program.
Architectural patterns & principles
• Separation of Concerns: UI vs. blockchain logic.
• Component-based UI: Reusable React components (Header, CandidateList).
• State Management: Redux Toolkit + React Query for caching blockchain reads.
• Smart-contract interactions using Anchor IDL and TypeScript bindings.
• Local development loop: Anchor migrations → program deployment → frontend testing.
Final checklist
[ ] Frontend stack (Next.js, React, Redux, Tailwind)
[ ] Wallet adapter & Phantom wallet
[ ] blockchain.service.tsx + IDL/types integration
[ ] Local Solana RPC/Test Validator
[ ] Anchor program with instructions & state accounts
[ ] Migrations/deploy pipeline