Skip to content

Okuromatsu/vote-condorcet

Repository files navigation

Condorcet Vote πŸ—³οΈ

A fair and transparent voting system using the Condorcet method - no registration required, just rank and vote!

Online public version here : (vote-condorcet.com)

✨ Features

  • Fair Voting - Condorcet method finds the candidate who beats all others in head-to-head matchups
  • Ranked Choice - Voters rank candidates by preference (1st, 2nd, 3rd, etc.)
  • Automatic Results - System calculates winner using pairwise comparisons
  • Easy Sharing - Unique URLs and QR codes for poll distribution
  • Duplicate Prevention - Cookie-based fingerprinting prevents vote manipulation
  • No Account Required - Simple, accessible, anonymous voting
  • Multi-language - Support for French (FR), Spanish (ES), and English (EN)

πŸš€ Quick Start

Prerequisites

  • Python 3.9+
  • Git

Setup (5 minutes)

# Clone repository
git clone https://github.com/yourname/condorcet-vote.git
cd condorcet-vote

# Create virtual environment
python -m venv .venv
source ./venv/bin/activate  # On Windows: .venv\Scripts\Activate.ps1

# Install dependencies
pip install -r requirements.txt

# Setup database
python manage.py migrate

# Create admin user (optional)
python manage.py createsuperuser

# Run server
python manage.py runserver

Visit: http://localhost:8000/

πŸ“– How It Works

  1. Create Poll - Enter title, candidates, optional description
  2. Share Link - Get unique URL to share with voters
  3. Vote - Voters rank all candidates by preference
  4. Results - System calculates Condorcet winner automatically

The Condorcet Method

  • Compares each candidate against every other candidate head-to-head
  • Winner is candidate who beats all others in one-on-one matchups
  • If tie exists, Schulze tiebreaker method is used

Example:

Voters rank: Python > JavaScript > Java
            JavaScript > Java > Python
            Java > Python > JavaScript

Matchups:
- Python vs JavaScript: 2 wins β†’ Python wins
- Python vs Java: 2 wins β†’ Python wins
- JavaScript vs Java: 1 win, 1 loss β†’ Tie

Result: Python is Condorcet winner (beats all others)

πŸ—οΈ Project Structure

condorcet-vote/
β”œβ”€β”€ voting/                 # Main app
β”‚   β”œβ”€β”€ models.py          # Database models
β”‚   β”œβ”€β”€ views.py           # Business logic
β”‚   β”œβ”€β”€ forms.py           # Form validation
β”‚   β”œβ”€β”€ utils.py           # Voting algorithm
β”‚   β”œβ”€β”€ templates/         # HTML templates
β”‚   └── static/            # CSS/JavaScript
β”œβ”€β”€ condorcet_project/     # Django settings
β”œβ”€β”€ locale/                # Translation files (FR, ES)
β”œβ”€β”€ manage.py              # Django CLI
β”œβ”€β”€ requirements.txt       # Dependencies
└── README.md             # This file

πŸ”§ Configuration

Development (Default)

python manage.py runserver
# DEBUG=True, SQLite database, no security restrictions

Production

  1. Set environment variables (or .env file):

    • SECRET_KEY - Django secret (generate new one)
    • DEBUG - Set to False
    • ALLOWED_HOSTS - Your domain(s)
  2. Run migrations:

python manage.py migrate
python manage.py collectstatic --noinput
  1. Use Gunicorn:
gunicorn condorcet_project.wsgi:application --bind 0.0.0.0:8000

πŸ§ͺ Testing

# Run all tests
python manage.py test

# Run specific app
python manage.py test voting

🌐 Translations

Currently supported:

  • πŸ‡¬πŸ‡§ English (EN) - Default
  • πŸ‡«πŸ‡· FranΓ§ais (FR) - Complete
  • πŸ‡ͺπŸ‡Έ EspaΓ±ol (ES) - Complete

Add New Translation

python manage.py makemessages -l [lang_code]
# Edit locale/[lang_code]/LC_MESSAGES/django.po
python manage.py compilemessages

πŸ“¦ Dependencies

See requirements.txt for complete list. Main packages:

  • Django 4.2.7 - Web framework
  • Bootstrap 5 - Frontend styling
  • PostgreSQL - Production database (optional, defaults to SQLite)
  • Gunicorn - Production server

πŸ“ License

CC BY-NC-SA 4.0

About

A Condorcet voting system website in python

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors