Quadratic Voting (live)
Quadratic Voting is the mathematically optimal way to vote in a democratic community, where votes express the degree of your preferences, not just direction. This calculator is an open-source voting application, with development supported by Gitcoin, and is a counterpart to the Quadratic Funding Calculator.
This application is built atop
- Front-end: NextJS (React)
- Back-end: NodeJS + Express serverless functions deployed on Vercel
- Database: PostgreSQL + the Prisma DB toolkit
At a fundamental level, the way in which voting links are generated and sessions are handled is kept simple:
- An
events
table keeps track of open voting events. Each event has asecret_key (uuid)
to manage the event. - A
voters
table keeps track of all voters and their preferences. Each voter has aid (uuid)
that together with theevent_uuid (uuid)
represents their unique voting URL.
Important files:
- prisma/schema.sql contains the SQL schema for the application.
- pages/api/events/details.js contains the QV calculation logic.
- Setup your PostgreSQL database
# Import schema
pg:psql -f prisma/schema.sql
-
Setup environment variables. Copy prisma/.env.sample to
prisma/.env
and replaceDATABASE_URL
with your PostgreSQL DB url. -
Run application
# Install dependencies
yarn
# Run application
yarn dev