Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
shobrook committed Nov 12, 2024
1 parent 87c8f0d commit 8a813a3
Show file tree
Hide file tree
Showing 42 changed files with 9,242 additions and 0 deletions.
130 changes: 130 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Who Will Win?

Single-page NextJS app featuring real-time forecasting, betting odds, polls, and news for any given election. It's currently set up for the 2024 presidential election, but could be repurposed for tracking any election.

## Running locally

> This assumes you have a Postgres database up and running. When you first spin up the database, make sure to run `npx prisma db push` to initialize the tables.
First, install the dependencies:

```bash
npm install
```

Then, create a `.env` file in the root directory of this codebase with the following variables:

```bash
API_URL="http://localhost:3000/api"
DATABASE_URI="" # Postgres URI goes here
SECRET_KEY="jOFASFL3foj3oi4p32O3%$" # Used to authenticate requests from the cron job
NEWSDATA_API_KEY="" # Get one here: https://newsdata.io/free-news-api
METACULUS_API_KEY=""
```

Then run the development server:

```bash
npm run dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the site.

To actually populate the site with data, you need to run a cron job that periodically hits the [http://localhost:3000/api/refresh](http://localhost:3000/api/refresh) endpoint. This will fetch the latest data from Metaculus, Polymarket, PredictIt, 538 (polls), and news, and add it to the database. Make sure to include the `SECRET_KEY` (from the `.env` file above) in the authorization header of the request.

## Acknowledgements

Built by [Jonathan Shobrook](https://github.com/shobrook) and originally used to power [willtrumpwin.com](https://willtrumpwin.com) (now associated with Kalshi).
Loading

0 comments on commit 8a813a3

Please sign in to comment.