Skip to content

feat(prompts): add Competition column with a 5-bar difficulty meter - #82

Merged
gkhngyk merged 1 commit into
mainfrom
feat/prompts-competition-column
May 22, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feat/prompts-competition-column

Conversation

@gkhngyk

@gkhngyk gkhngyk commented May 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Competition column to the All Prompts tab (/dashboard/prompts?tab=all) with an Ahrefs/SEMrush-style 5-bar difficulty meter. The competition data already comes back on every DataForSEO search-volume call — this wires it end-to-end (DataForSEO → DB → UI) with no extra API spend.

Closes #44

Changes

  • Migration 00004_prompt_competition.sql — adds competition_index (int) + competition (LOW/MEDIUM/HIGH) to prompt_volumes. Additive, IF NOT EXISTS, no RLS change.
  • DataForSEO client — getSearchVolumes now returns { volume, competitionIndex, competition } per keyword. Callers updated: volumes.js and test-volumes.js.
  • Aggregation — fetchAndSaveVolumes computes a volume-weighted average competition index per prompt and derives the LOW/MEDIUM/HIGH label. google_volumes stays a { keyword: number } map for the existing UI.
  • Types — prompt_volumes Row/Insert/Update in supabase.ts; PromptVolume in types/index.ts.
  • Component — CompetitionBars: 5 equal-height bars, green → dark red by level, — when null.
  • UI — Competition column in AllPromptsTab with a header tooltip clarifying it's a Google Ads proxy for topic difficulty.

Honest framing

This is Google Ads paid-bid competition — a proxy for general topic difficulty, not true AEO difficulty (being cited by AI engines). The header tooltip says so. An AEO-native metric can replace it later.

Verification

  • typecheck + format:check pass; no new lint errors.
  • Migration applies cleanly (additive, idempotent).
  • Smoke-tested end-to-end: after a fresh re-analyze the bars render at the correct level/colour per prompt; prompts without a fetched volume row show — (correct null state).

Migration note

The migration is additive and idempotent. Apply via Supabase Studio SQL Editor or supabase db push — safe to run before or after merge (IF NOT EXISTS makes a re-run a no-op).

Out of scope (per the issue)

Per-keyword competition breakdown, AEO-native composite difficulty, other pages, sort/filter by competition, MCP/REST exposure — all noted as follow-ups.

Wires DataForSEO competition data end-to-end (API -> DB -> UI) for the
All Prompts tab, reusing the existing search-volume call (no extra spend):

- migration 00004 adds competition_index + competition to prompt_volumes
- getSearchVolumes now returns { volume, competitionIndex, competition }
  per keyword; callers updated (volumes.js, test-volumes.js)
- fetchAndSaveVolumes aggregates a volume-weighted average per prompt and
  stores both the index and a LOW/MEDIUM/HIGH label
- CompetitionBars renders an Ahrefs-style 5-bar meter (green -> dark red),
  '-' when unknown
- All Prompts tab gains a Competition column with a header tooltip noting
  it's a Google Ads proxy for topic difficulty

Closes #44
@gkhngyk
gkhngyk merged commit ad66e99 into main May 22, 2026
3 checks passed
@gkhngyk gkhngyk mentioned this pull request May 26, 2026

This branch was successfully deployed

1 active deployment
Preview — 114bab84 Deployed May 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(prompts): add Competition column to the All Prompts tab (with a 5-bar difficulty meter)

1 participant