# 1. Start Ganache (persistent blockchain)
./start-ganache.sh
# 2. Deploy contracts
npx truffle migrate --network development
# 3. Start backend (in new terminal)
cd backend && node index.js
# 4. Start frontend (in new terminal)
cd frontend && npm start
# 5. Open http://localhost:5173
# 6. Connect MetaMask with Account 1 (admin)
# 7. Register voters and add candidatesThe blockchain state is PERSISTENT! You don't need to redeploy or re-register.
# Just start the services:
./start-ganache.sh # Terminal 1
node backend/index.js # Terminal 2
cd frontend && npm start # Terminal 3
# Your registrations and candidates are still there! ✓Only delete ganache_db/ when:
- Smart contract code changed
- You want to test from scratch
- Database is corrupted
# Stop Ganache (Ctrl+C)
rm -rf ganache_db/
./start-ganache.sh
npx truffle migrate --reset --network development# This deletes all your voter registrations!
npx truffle migrate --reset# Just restart Ganache if it crashed
./start-ganache.sh
# Frontend/backend can restart anytime without losing data- Cause: You ran
truffle migrate --resetwhich deployed a new contract - Fix: Don't use
--resetflag during normal development
- Cause: Database was deleted or contracts redeployed
- Fix: Re-register voters on the new contract
- Cause: Circuit breaker from too many errors
- Fix: MetaMask → Settings → Advanced → Clear activity tab data
- Ganache Database:
./ganache_db/(DO NOT DELETE during dev) - Chain ID: 1337 (fixed)
- Network ID: 1337 (fixed)
- Admin Account: Account 0 (first account shown in Ganache output)
- Voter Accounts: Accounts 1-9 (use any for testing voters)
- Leave Ganache running - Don't stop it unless necessary
- Don't use --reset - Only for fresh starts
- Check database exists -
ls ganache_db/should show files - One-time registration - Register voters once, they persist
- Backend/Frontend - Can restart these anytime, data is on blockchain