Skip to content

A small web app that presents redacted political policies and infers a user’s leaning based on their responses. Built with TypeScript, Express, EJS, and Chart.js.

License

Notifications You must be signed in to change notification settings

VibeCoder01/political-compass

Repository files navigation

Blind Policy Quiz (Node/TypeScript + Express)

A small web app that presents redacted political policies and infers a user’s leaning based on their responses. Built with TypeScript, Express, EJS, and Chart.js.

Features

  • Redacted policy prompts; anonymized party labels during play.
  • 5-point Likert scoring: Strongly Disagree (−2) … Strongly Agree (+2); Neutral (0).
  • Unique questions per run (no repeats until pool is exhausted).
  • Ends on strong lead (≥10 votes and top > second + 1) or after 30 questions.
  • In‑game “swingometer” radar chart (toggle persists); full‑screen chart with real party names on results.
  • Topic-balanced sampling so sessions cover multiple areas (e.g., Health, Economy, Housing).

Quick Start

  • Prerequisites: Node.js 18+ recommended.
  • Install: npm install
  • Run: npm start
  • Open: http://localhost:3000

Scripts

  • npm start: Compile TypeScript to dist/ then run node dist/index.js.
  • npm test: Placeholder (no tests configured yet).
  • Dev tip: npx tsc --watch for incremental builds; in another terminal run node dist/index.js.
  • Policy tools: npm run validate:policies, npm run generate:policy-sources, npm run apply:policy-sources, node scripts/tag-policies.js.
  • Redaction check (after build): node scripts/test-redaction.js.

Project Structure

  • src/ — TypeScript source
    • index.ts — Express server, routes, session/game logic
    • policy-service.ts — Load/randomize/redact policies
  • views/ — EJS pages (pages/) and partials (partials/)
  • public/ — Static assets (css/, js/)
  • test3/policies.json — Policy data source
  • dist/ — Compiled JS output (generated)

Configuration & Data

  • Port: currently fixed to 3000 in src/index.ts.
  • Session secret: currently hardcoded for demo. For production, update the server to read SESSION_SECRET from env.
  • Policies: edit test3/policies.json. Each party maps to an array of { headline, description }; party name is derived from the object key.

Development Notes

  • Chart.js is loaded via CDN in views/partials/header.ejs.
  • Client logic lives in public/js/main.js (vote handling, chart updates, toggle persistence).
  • TypeScript config in tsconfig.json (strict mode, outDir: dist).
  • Methodology and assumptions in METHODOLOGY.md.

Testing

  • Not configured. Suggested: Vitest or Jest with ts-node/ts-jest. Target ≥80% coverage for services (e.g., policy-service.ts).

Contributing

See AGENTS.md for repository guidelines.

License

MIT — see LICENSE.

About

A small web app that presents redacted political policies and infers a user’s leaning based on their responses. Built with TypeScript, Express, EJS, and Chart.js.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published