Skip to content

otaviouss/quadratic-voting

 
 

Repository files navigation

Quadratic Voting (live)

Open-source QV tool

Architecture

This application is built atop

  1. Front-end: NextJS (React)
  2. Back-end: NodeJS + Express serverless functions
  3. 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:

  1. An events table keeps track of open voting events. Each event has a secret_key (uuid) to manage the event.
  2. A voters table keeps track of all voters and their preferences. Each voter has a id (uuid) that together with the event_uuid (uuid) represents their unique voting URL.

Important files:

  1. prisma/schema.sql contains the SQL schema for the application.
  2. pages/api/events/details.js contains the QV calculation logic.

Run locally

  1. Setup your PostgreSQL database
# Import schema
psql -f prisma/schema.sql
  1. Setup environment variables. Copy prisma/.env.sample to prisma/.env and replace DATABASE_URL with your PostgreSQL DB url.

  2. Run application

# Install dependencies
yarn

# Run application
yarn dev

Run in Docker container

# Build container
docker build . -t rxc_qv

# Run
docker run -d --env DATABASE_URL=postgresql://__USER__:__PASSWORD__@__HOST__/__DATABASE__ -p 2000:2000 rxc_qv

License

CC BY-NC 2.0

About

Quadratic Voting web application

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.7%
  • Dockerfile 1.3%