Skip to content

precog-iiith/Elections_24

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Election Analysis Website

Welcome to the Election Analysis Website project! This guide will help you set up and run the website locally on your machine.

Getting Started

Prerequisites

  • Python 3.8 or higher

Development Mode

Installation

Using Git:

git clone https://github.com/random-goose/elections_2024

Without Git:

  • Navigate to the GitHub repository's Downloads section.
  • Click on "Download ZIP."
  • Locate the ZIP file on your system and unzip it.

Python and Flask

Ensure Python is installed on your system, then install the dependencies:

python --version            # Should return Python >= 3.8
pip install -r requirements.txt

If Python is not installed, visit the Python download page and follow the instructions.

Node.js and npm

With sudo access:

  • Download Node.js: Visit the Node.js download page and download the LTS version for your OS.

  • Install Node.js: Follow the appropriate installation instructions:

    • Windows/macOS:

      • Run the installer and follow the prompts.

      • Verify installation:

        node -v
        npm -v
    • Linux (Ubuntu-based):

      sudo apt update
      sudo apt install nodejs npm
      node -v
      npm -v

Running

Prerequisites

  • We recommend using an IDE like VSCode: Download VSCode
  • Each section (Frontend, Backend, Framing, Political Ads) runs in its own terminal.
  • In VSCode, open a terminal using Ctrl + ` or the bottom panel toggle.
  • Use the + button in the terminal panel to open multiple terminals as needed.

Express.js Backend

Install required packages:

sudo npm install -g express nodemon

Start the Express.js server:

cd backend
npm install
nodemon app.js

Setting the Express.js API URL

Before running the Next.js server, set the NEXT_PUBLIC_EXPRESS_API_URL environment variable in a .env file at the root of your Next.js project:

NEXT_PUBLIC_EXPRESS_API_URL=http://localhost:3500  # Default port

Next.js Frontend

Navigate to the frontend directory, install dependencies, and start the server:

cd election
npm install
npm run dev

If it runs successfully, you should see output similar to:

> next dev

   ▲ Next.js 15.2.1-canary.0
   - Local:        http://localhost:3000
   - Network:      http://192.168.1.20:3000
   - Environments: .env

 ✓ Starting...

You can access the dashboard UI at http://localhost:3000. But make sure to start the below servers as well.

Starting Servers

Ensure all servers are running:

  • Express.js Backend

    cd backend
    nodemon app.js
  • Framing Flask Backend

    cd Flask
    python api.py

Political Ads API Setup

Two separate Flask servers handle political ads data. Though the API uses GET requests (generally less secure than POST), this is suitable here since it only filters publicly available data.

  • Facebook / Meta Ads

    cd Facebook-API
    python api.py  # Runs on port 5100
  • Google Ads

    cd Google-API
    python api.py  # Runs on port 5050

Ad data is stored in each folder under:

  • meta_ad_data.csv
  • google_ad_data.csv

Production Mode

Installation

Ensure all development dependencies are installed.

Building Next.js for Production

cd election
npm run build

Then, start all servers as described in the Development Mode section.

Appendices

Some features are not directly accessible via the dashboard. Use the following resources for extended functionality:

  • Quora Scraped Data: Link
  • Sharechat Scraped Data: Link
  • Sharechat Full Graph: Link
  • Community Detection Codes: Link
  • Framing Model: Link
  • Toxic Memes Model: Link
  • Gender predictor from Indian usernames: Link
  • News Headline Dump: Link
  • Scraped Reddit Data: Link

Troubleshooting

If you face any issues, please raise an issue in the repository.

Common Errors

If npm run dev returns:

> election@0.1.0 dev
> next dev
========================================================================
Welcome to nmh version 1.8
See the release notes in /usr/share/doc/nmh/NEWS
...
next: usage: next [+folder] [switches] [switches for showproc]

Try the following:

npx next dev
npm run dev

This usually happens only during the first startup.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages