Skip to content

CampaignLab/ReformExposedNearMe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reform UK Exposed Tweets by Area

Static single-page site listing tweets from the @ReformExposed Twitter account, filterable by area and keyword. Tweet data is pulled at runtime from a PostgreSQL database via a small HTTP API.

Local development

The site is backed by a Postgres database. A small Node server (server.js) serves the static files and the /api/tweets endpoint that reads from the database.

Prerequisites

  • Node.js
  • A reachable PostgreSQL database with the tweets table loaded (see "Loading the data" below)

Setup

cd reformexposed-site
npm install              # installs the `pg` driver
cp .env.example .env     # then edit DATABASE_URL to point at your Postgres
npm start                # starts server.js on http://localhost:8088

Then open http://localhost:8088.

server.js automatically reads .env from the project root. Alternatively export DATABASE_URL in your shell.

Loading the data

The tweet data lives in Updated_For_REXPO.csv (columns: URL, Area, all_persons, Tweet). To (re)load it into Postgres:

createdb reformexposed
psql reformexposed -c "
  CREATE TABLE tweets (
    id SERIAL PRIMARY KEY,
    url TEXT,
    area TEXT,
    all_persons TEXT,
    tweet TEXT
  );"
psql reformexposed -c "\copy tweets(url, area, all_persons, tweet) FROM 'Updated_For_REXPO.csv' WITH (FORMAT csv, HEADER true)"

Deploy to Vercel

npm i -g vercel
cd reformexposed-site
vercel        # preview deploy
vercel --prod # production deploy

The /api/tweets.js serverless function serves the JSON API on Vercel. Set the DATABASE_URL environment variable in the Vercel project settings (do not commit .env).

vercel.json sets clean URLs and basic caching/security headers.

Files

  • index.html — the app (markup, styles, data loading + filtering logic)
  • api/tweets.js — Vercel serverless function returning tweet JSON from Postgres
  • server.js — local dev server (static files + /api/tweets) backed by Postgres
  • package.json / package-lock.json — Node dependencies (pg)
  • assets/hero.jpeg — vendored hero image (originally hotlinked from samkriss.com)
  • vercel.json — deployment config
  • Updated_For_REXPO.csv — source data used to populate the database

Data source

Tweets are read from the tweets table in Postgres. The API (/api/tweets) returns rows with area, tweet, and url fields; the frontend filters them by area and keyword.

About

This repo is for the vercel based dynamically updating version of the website

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors