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.
- 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).
- Prerequisites: Node.js 18+ recommended.
- Install:
npm install - Run:
npm start - Open: http://localhost:3000
npm start: Compile TypeScript todist/then runnode dist/index.js.npm test: Placeholder (no tests configured yet).- Dev tip:
npx tsc --watchfor incremental builds; in another terminal runnode 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.
src/— TypeScript sourceindex.ts— Express server, routes, session/game logicpolicy-service.ts— Load/randomize/redact policies
views/— EJS pages (pages/) and partials (partials/)public/— Static assets (css/,js/)test3/policies.json— Policy data sourcedist/— Compiled JS output (generated)
- Port: currently fixed to
3000insrc/index.ts. - Session secret: currently hardcoded for demo. For production, update the server to read
SESSION_SECRETfrom env. - Policies: edit
test3/policies.json. Each party maps to an array of{ headline, description }; party name is derived from the object key.
- 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.
- Not configured. Suggested: Vitest or Jest with ts-node/ts-jest. Target ≥80% coverage for services (e.g.,
policy-service.ts).
See AGENTS.md for repository guidelines.
MIT — see LICENSE.