which Svelte Themes

Which

A tiny voting/polling web app. Svelte/Go/PostgreSQL

Which?

Live: which.jwlarocque.com

A simple voting/polling web app, with support for instant runoff as well as approval and plurality voting. Svelte frontend, Go backend, PostgreSQL database.

Current code quality: gradually improving

Installation Instructions

  1. Install git, npm, go, and postgresql
  2. Get server dependencies: go get github.com/jackc/pgx github.com/jmoiron/sqlx golang.org/x/oauth2 cloud.google.com/go/compute/metadata
  3. Clone this respository: git clone https://github.com/jwlarocque/which.git
  4. Change to which directory: cd which
  5. Build the frontend: npm run build
  6. Create a PostgreSQL DB from schema.sql (you might want to change the owner username)
  7. Edit start.sh.sample with the appropriate paths and variables and rename it start.sh.
  8. If necessary, allow execution: chmod u+x start.sh
  9. Build the server executable: go build -o which_server server/main.go
  10. If not running it with sudo, give which_server permission to bind reserved ports: sudo setcap 'cap_net_bind_service=+ep' which_server

Run as daemon:

  1. Edit which_server.service.sample with the appropriate paths and rename it which_server.service
  2. Move the systemd service file: sudo cp which_server.service /etc/systemd/system
  3. Start the service (sudo) systemctl start which_server.service

Or just run (sudo) ./start.sh

TODO

In Progress

  • Consider redirecting to question upon creation
  • Sankey diagrams for ranked choice/runoff results (currently just shows winner)
  • Link copy dropdown

Planned

  • Question subtitles/additional information
  • List of questions voted on by user
  • Additional cleanup and documentation

Potential

  • Config file (instead of treating start.sh as config via env vars)
  • HTTPS
  • Jenkins CI

References

Golang package docs
MDN

Auth

Skarlso, Google sign-in Part 1
Skarlso, Part 2
Alex Pliutau, stdlib OAuth2
Jon Calhoun, Securing cookies in Go

Svelte

Svelte docs Svelte tour

SQL

PostegreSQL docs
jmoiron/sqlx
VividCortex, DB-driven Go

Top categories

Loading Svelte Themes