Welcome to the Election Analysis Website project! This guide will help you set up and run the website locally on your machine.
- Python 3.8 or higher
Using Git:
git clone https://github.com/random-goose/elections_2024Without Git:
- Navigate to the GitHub repository's Downloads section.
- Click on "Download ZIP."
- Locate the ZIP file on your system and unzip it.
Ensure Python is installed on your system, then install the dependencies:
python --version # Should return Python >= 3.8
pip install -r requirements.txtIf Python is not installed, visit the Python download page and follow the instructions.
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
-
- 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.
Install required packages:
sudo npm install -g express nodemonStart the Express.js server:
cd backend
npm install
nodemon app.jsBefore 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 portNavigate to the frontend directory, install dependencies, and start the server:
cd election
npm install
npm run devIf 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.
Ensure all servers are running:
-
Express.js Backend
cd backend nodemon app.js -
Framing Flask Backend
cd Flask python api.py
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.csvgoogle_ad_data.csv
Ensure all development dependencies are installed.
cd election
npm run buildThen, start all servers as described in the Development Mode section.
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
If you face any issues, please raise an issue in the repository.
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 devThis usually happens only during the first startup.