This crate is a Web App example that uses Svelte as the frontend with Rust Rocket as the backend API to do ranked choice voting.
Each user ranks the candidates according to their preference, and an election is run after each vote is cast.
The implementation is not secure. There is no registration mechanism. Users simply identity with a self-chosen username, so any user can change any other's ballot simply by giving their username.
NodeJs - Install
Rust - Install
Rust Nightly for the project folder
cd ranked-voting
rustup override set nightly
npm install
...create a SQLite database, install SQLx CLI crate, and run the SQL migrations
sqlite3 votes.db
cargo install sqlx-cli
sqlx migrate run
...then start Rocket server and Rollup in two different terminals
Terminal 1: (To run the rust server)
cargo run
Terminal 2: (To build and hot reload svelte components)
npm run dev
Navigate to localhost:8000. You should see your app running.
All svelte component live in client
directory. Save any changes live-reloading.
All Rocket code lives in src
directory. To rebuild Rust code use cargo run after saving your changes.
All static files are served from public
directory. Including the JS code compiled by Svelte Compiler.
To create an optimized version of the app:
npm run build
cargo build --release