Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SLElectionLive

SLElectionLive Dashboard License GitHub Issues

SLElectionLive is a Flask-based web application that provides real-time election results for Sri Lanka. It features an interactive dashboard with charts, a live news stream, and an SMS campaign interface. The application scrapes data from results.elections.gov.lk and uses Chart.js for visualizations, Bootstrap for styling, and a responsive design for accessibility across devices.

img1

Table of Contents

Live Demo

Explore the live application at https://sl-election-live.vercel.app/. View real-time election results, news updates, and manage SMS campaigns.

img2

Features

  • Live Election Results Dashboard: Displays vote shares, seats, and party details with an interactive doughnut chart.
  • Real-Time News Stream: Fullscreen news mode with voter turnout, social sharing, and automatic updates every 30 seconds.
  • SMS Campaign Interface: Manage and send SMS campaigns for election updates.
  • Dark Mode: Toggle between light and dark themes for better usability.
  • Responsive Design: Optimized for desktop, tablet, and mobile devices.
  • Data Scraping: Fetches live election data from results.elections.gov.lk using BeautifulSoup.
  • Fallback Data: Uses sample data when API or scraping fails, ensuring uninterrupted service.

Project Structure

SLElectionLive/
├── api/
│   ├── app.py               # Flask application with routes and scraping logic
│   ├── sample_data.py       # Generates sample election data for fallback
│   ├── templates/
│   │   ├── index.html       # Election results dashboard
│   │   ├── news.html        # Live news stream page
│   │   ├── sms_campaign.html # SMS campaign interface
├── packages.json            # Node.js configuration (optional for Vercel)
├── requirements.txt         # Python dependencies
├── test.py                  # Test script for development
├── vercel.json              # Vercel deployment configuration
├── README.md                # This file

Installation

Follow these steps to set up the project locally:

  1. Clone the Repository:

    git clone https://github.com/Ishanoshada/SLElectionLive.git
    cd SLElectionLive
  2. Create a Virtual Environment:

    python -m venv venv
  3. Activate the Virtual Environment:

    • On Windows:
      venv\Scripts\activate
    • On Linux/Mac:
      source venv/bin/activate
  4. Install Dependencies:

    pip install -r requirements.txt
  5. Set Up Environment Variables:

    • Create a .env file in the root directory:
      touch .env
    • Add necessary configurations (e.g., API keys, if used):
      FLASK_ENV=development
      SECRET_KEY=your_secret_key
      
  6. Run the Application:

    python api/app.py
    • The app will be available at http://localhost:5000.

Usage

  • Dashboard (/): View the latest election results with a chart and table of party details.
  • News Stream (/news): Access live updates with voter turnout, social sharing buttons, and navigation for recent results.
  • SMS Campaign (/sms_campaign): Manage SMS campaigns for election notifications.
  • Dark Mode: Click the moon/sun icon in the navbar to toggle themes.
  • Fullscreen Mode: On the news page, click the fullscreen button for an immersive view.

To test with sample data:

  • Modify app.py to force use_sample_data=True or simulate a failed API call.

Deployment

Local Deployment

  • Use gunicorn for production-like local testing:
    gunicorn -w 4 -b 0.0.0.0:8000 api.app:app

Vercel Deployment

The project includes vercel.json and packages.json, suggesting Vercel compatibility. To deploy:

  1. Install the Vercel CLI:
    npm install -g vercel
  2. Deploy from the project root:
    vercel
  3. Follow prompts to configure the project (ensure api/app.py is the entry point).
  4. Update vercel.json if needed to map routes correctly.

Other Platforms

  • Heroku: Push to a Heroku app with Procfile:
    web: gunicorn api.app:app
    
  • Render: Configure as a Python web service with requirements.txt.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch:
    git checkout -b feature/your-feature
  3. Commit changes:
    git commit -m "Add your feature"
  4. Push to the branch:
    git push origin feature/your-feature
  5. Open a pull request on https://github.com/Ishanoshada/SLElectionLive.

Please follow the Code of Conduct and include tests in test.py for new features.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Attribution

Views

About

A Flask web app for live Sri Lanka election results, featuring an interactive dashboard, news stream, and SMS campaign interface

Topics

Resources

Stars

Watchers

Forks

Used by

Contributors

Languages