Skip to content
jeffmercuryPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

The Tracker

A public, national (US) site that tracks the issues most impacting the country as living figures, not posts. Each tracker shows a current number, whether it is moving, how fresh the data is, and community-submitted actions people can take. The promise: you can see whether the number moved, and whether the public's effort had anything to do with it.

Spec: see the product & technical spec this was built from. Build order was followed as written: adapters were run live before any UI was built (docs/source_reality.md).

Layout

backend/   FastAPI + SQLAlchemy + Alembic. Adapters, nightly job, ranking, auth, admin.
frontend/  React + Vite + TypeScript. Feed, tracker cards, action modals, forms, admin.
docs/      source_reality.md: what each upstream feed actually returns and how stale it is.

Run it

cp .env.example .env                       # fill in keys you have; none are required for dev

cd backend
uv sync --extra dev
uv run alembic upgrade head
ADMIN_EMAIL=you@example.com ADMIN_PASSWORD='pick one' uv run python -m app.cli seed
uv run uvicorn app.main:app --reload       # http://localhost:8000  (docs at /docs)

cd ../frontend
npm install
npm run dev                                # http://localhost:5173, proxies /api -> :8000

seed creates the starting sources and trackers, fetches each source once, backfills the publisher's own back-series so trends and sparklines are real, and publishes only the trackers that got a number. Sources whose key is missing (Census, FBI) or that are manual-entry (Mapping Police Violence) stay approved and unpublished: no source, no number, no card.

The nightly job

cd backend && uv run python -m app.cli nightly

For each source: fetch, compare with the last recorded figure, append to figure_history only if it changed, update the source's freshness fields (last_checked_at, last_changed_at, last_fetch_status, staleness_reason), then recompute ranking. Run it from cron, or set SCHEDULER_ENABLED=1 to run it in-process at NIGHTLY_HOUR_UTC. figure_history rows can never be updated or deleted (enforced in the ORM).

Other commands: probe-source <adapter> '<json config>', backfill <source_id>, create-admin <email> <password>, list-adapters, init-db.

Data honesty, in code

  • Cards show the publisher's release date and the period the figure covers, never our fetch date. staleness_reason explains why a figure hasn't moved, including overdue releases.
  • A failed fetch keeps the last good figure and shows "Couldn't reach {source} on {date}".
  • Adapters never compute a number the source didn't publish. Census uses published rates, not count ratios. Manual sources say they were entered by hand.
  • Publishing requires a source, an editorial reason, a direction of harm, and a fetched figure.

Adding a source

  1. Write an adapter in backend/app/adapters/ subclassing SourceAdapter, register it, and run it live with probe-source. Record what it returns in docs/source_reality.md.
  2. In the admin UI (Source health), add the source with its adapter config, fetch it, and backfill if the publisher offers a back-series.
  3. Attach it to the tracker in the issue queue, set the editorial reason and direction of harm, publish.

If a source has no API, use the manual adapter: an admin enters the value, period, release date, and provenance, and the card says so.

Ranking

score = w_harm·harm_norm + w_trend·trend_term + w_fresh·freshness_norm + w_signal·signal_norm over published trackers. Weights live in backend/ranking.toml (env RANKING_W_* overrides). Worsening figures rank up, improving ones drift down. The admin ranking audit shows every component of every score.

Tests

cd backend && uv run pytest              # offline: fixtures, trend matrix, nightly, privacy, admin gate
cd backend && uv run pytest -m live      # hits real APIs; skips cleanly without keys or quota
cd frontend && npm test && npm run build

Attribution & privacy

Submitters choose: publish my name, publish as a named nominee, or anonymous (default: unattributed). Public endpoints and public API responses never carry account data; admin views do. Users change attribution any time from their submissions page.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages