You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 14646e5
Browse filesBrowse the repository at this point in the historyBrowse files
docs(claude.md): remove 70 duplicated lines my last docs commit introduced
3690fa0 spliced the new signal-quality section in with
s[:start] + new + s[end:], where end came from s.index("### Frontend"). That
matched "### Frontend (local)" up in Commands - EARLIER in the file than
start - so the slice duplicated everything between them. The file carried two
copies of Frontend (local), Migrations, Tests, Architecture, Data flow,
Learning layer, Projects, the catalog section and Signal quality, with the
second copy stale: "~92 tests" and the old "Thin volume (inherent)" text that
the commit was meant to replace.
Verified by diffing against CLAUDE.md at 3484e3b (the commit before): the only
differences now are the intended ones - the test count and the rewritten
signal section. 210 lines -> 140.
Lesson for splice edits: index() takes the FIRST match. Anchor on text that is
unique, and assert the end anchor comes after the start.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
-70Lines changed: 0 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,76 +109,6 @@ The GitHub half of the score always worked; the **developer-conversation half**
109
109
110
110
To grow the signal further: Hacker News is the weakest source (Algolia search by tool keyword would target it), or widen keywords in `catalog.py` — and move the epoch when you do.
111
111
112
-
### Frontend (local)
113
-
```bash
114
-
cd frontend
115
-
npm install
116
-
npm run dev # Next dev server on :3000 (Turbopack)
117
-
npm run build # production build
118
-
npm run lint # eslint
119
-
```
120
-
121
-
### Migrations
122
-
Alembic is configured (`backend/alembic.ini`, versions in `backend/alembic/versions/`), but the app **also auto-creates tables** on startup via `Base.metadata.create_all` and seeds them. Because `create_all` never adds a column to a table that already exists, `app/db/migrate.py:ensure_columns` runs on startup and additively `ALTER TABLE ADD COLUMN`s any missing model fields (nullable/defaulted only — it never drops/retypes). Adding a plain nullable column to a model needs no Alembic step; anything structural still does. For schema changes:
`tests/conftest.py` points `DATABASE_URL` at a **throwaway SQLite file** (never `backend/test.db`), blanks every API key, and sets `RUN_SCRAPER_INLINE=0` + `WARM_RESOURCE_CACHE=0`, all before `app` is imported — so the suite needs no database, secrets or network and gives the same answer in CI as locally. Backend CI (`.github/workflows/backend.yml`) runs it on every push/PR. Coverage today: the project video gate + cache key (`test_projects.py`, with the real titles that reached production as regressions), data freshness (`test_health.py`), the scheduler's success stamping (`test_scheduler.py`), the score's contract (`test_scoring.py`), and the booted app (`test_api.py`). Pure logic belongs in a service module where it can be tested without a request — `projects.video_cache_slug` was moved out of the endpoint for exactly that reason.
1.**`app/services/scheduler.py`** — `run_scraper_loop()` runs every 30 min (started as an asyncio task at app startup). `perform_full_scrape()` is an 8-step pipeline: sync tool registry → fetch community sources → sentiment → GitHub repo stats → score → persist snapshots → update tools → recompute. Live progress is exposed via `GET /api/v1/status`. `perform_full_scrape` never raises (the loop must survive) but **returns True only when the final commit landed**; `record_cycle_result` stamps `last_scraped_time` on success alone and otherwise increments `consecutive_failures`. Both the loop and `POST /admin/scrape` go through `run_one_cycle()` — the admin trigger used to call the pipeline directly, so a manual fix never cleared the alert. It used to stamp unconditionally, so a crashed pipeline was reported as a fresh scrape and the site said "Live".
146
-
2.**`app/services/scraper.py`** — async fetchers: `fetch_github_repo_stats` (targeted per-repo, ETag caching + adaptive rate limiting), `fetch_hackernews`, `fetch_devto`, `fetch_reddit` (RSS, no auth), `fetch_tech_news` (RSS). `batch_sentiment_analysis` uses Groq (`llama-3.1-8b-instant`) — a no-op/skip when `GROQ_API_KEY` is empty.
147
-
3.**`app/services/scoring.py`** — `calculate_all_tool_scores` scores each tool on an **absolute 0–100 scale** from its own signals only: floor-anchored log stars (60%) and forks (15%) plus community mentions saturating at 25 (25%). A tool's score does not move when an unrelated tool moves — `test_scoring.py` pins this. (This file used to say percentile ranks; `_percentile_rank` is unused.) Also classifies growth stage, trend, learning priority, and generates recommendation text.
148
-
4.**`app/api/endpoints/mvp.py`** — the single router, mounted at `settings.API_V1_STR` (`/api/v1`). All endpoints live here: `/tools`, `/tools/{slug}`, `/tools/{slug}/history`, `/tools/{slug}/resources` (learning videos + platforms, see below), `/tools/compare`, `/tools/by-domain`, `/domains`, `/domains/{slug}/learning-path`, `/roadmaps`, `/roadmaps/{slug}` (steps hydrated with per-step tools + each tool's top video), `/progress/{summary,/{slug},toggle}` (learning progress, auth-gated), `/notifications/{subscribe,status,unsubscribe}` (daily-nudge opt-in), `/overview`, `/status`, `/health` (always 200; `status` is ok/degraded/error with a `data` freshness report), `/health/data` (**503 when data is stale >2h, the scraper has failed 2+ cycles running, or nothing was ever scraped — point an uptime monitor here**; logic in `app/services/health.py:assess_freshness`), `/ready`, `/admin/scrape` + `/admin/send-daily-digests` (gated by `ADMIN_API_KEY`).
149
-
5.**`app/models/all_models.py`** — tables: `Domain`, `Tool` (now also carries `homepage`/`latest_version`/`latest_release_at` for the resource docs-link + stale-tutorial warning), `ToolSnapshot` (time series, incl. `stars`), `ToolRoadmap`, `UserProgress` (completed roadmap steps per user), `ToolResource` (cached learning videos/platforms), `NotificationPref` (daily-nudge opt-in). Roadmaps are keyed by **domain slug**. New model fields are reconciled onto existing DBs at startup by `app/db/migrate.py:ensure_columns` (additive `ALTER TABLE ADD COLUMN` only — `create_all` never adds columns to an existing table).
150
-
151
-
### Learning layer (the retention + growth product)
152
-
-**Resources — `app/services/resources.py`** (`GET /tools/{slug}/resources`). Best videos/playlists + platform links per tool. **Nothing is model-generated:** video links come from the YouTube Data API (ranked by `rank_resource`: reach/engagement/freshness/depth) when `YOUTUBE_API_KEY` is set, else from a hand-curated `CURATED_VIDEOS` list where **every id is verified live via YouTube oEmbed** (`verify_youtube`) before it ships — a bad/unrelated id fails closed. `videos_source` = `youtube_api` | `curated` | `search`. `warm_resource_cache` pre-warms on startup; results cached in `ToolResource` (24h TTL). Curated platform links are always-valid search/listing deep-links (DevDocs, freeCodeCamp, NPTEL/SWAYAM…). Release data (for the "predates current version" warning) comes from `scraper.fetch_github_latest_release`.
153
-
-**Progress — `/progress/*`.**`UserProgress` rows exist only for COMPLETED steps; `build_progress_summary` computes streak + active roadmaps + today's focus. **Auth: `app/core/auth.py` verifies the Clerk session JWT** (issuer/JWKS derived from the public `CLERK_PUBLISHABLE_KEY`, no secret) and uses its `sub`; a client-supplied `user_id` is ignored when Clerk is configured, and falls back only in keyless dev.
154
-
-**Daily nudge — `app/services/notifications.py`.** Opt-in only (`NotificationPref`). `run_daily_digests` builds each user's "next lesson" digest (reusing the progress summary) and sends via Resend, or logs a no-op when `RESEND_API_KEY` is empty. Triggered by an external daily cron hitting `POST /admin/send-daily-digests` (`X-Admin-Key`).
155
-
156
-
### Projects — learning turned into evidence
157
-
**`app/services/projects.py` is the ONE place projects are defined**, the same rule `catalog.py` follows for tools. Each brief carries `slug`, `tool_slug`, `tier` (beginner/intermediate/advanced), `summary`, `brief`, `requirements[]`, `skills[]`, `est_hours` and a `walkthrough` (`video_id` + `keywords`, `docs[]`, `steps[]`). `_validate()` runs at import and raises on an unknown `tool_slug`, a bad tier or a duplicate slug, so a typo fails at boot rather than rendering an orphan card. **No table** — these are static hand-authored content like `catalog.TOOLS`, not cached remote data like `ToolResource`, so there is nothing to migrate; walkthrough verification results (negatives included) live in `app/core/cache.py` via the `get_cached`/`set_cached` helpers.
158
-
159
-
**The honesty line, and it is the whole design.** A brief is a SPECIFICATION and is authored by hand. A walkthrough link is a CLAIM and is verified: every `video_id` goes through `resources.verify_youtube` (oEmbed — no key, no quota) at serve time and **fails closed**, leaving the docs and written steps rather than a dead link. `verify_youtube` also rejects a live id whose real title misses the keywords, which is what catches a typo resolving to some unrelated real video. `walkthrough.video_verified` reports this to the UI, mirroring `videos_live`.
160
-
161
-
Endpoints: `/projects` (`tool`, `domain`, `tier` filters), `/projects/{slug}` (verified walkthrough), `/tools/{slug}/projects` (404s on an unknown tool, so a URL typo stays distinguishable from a tool with no brief yet). `/roadmaps/{slug}` hydrates a `projects` array onto each step. Frontend: `/projects`, `/projects/[slug]`, `components/ProjectCard.tsx` (exports `TIER_BADGE`, reused by the roadmap so tiers and step levels share one palette), `components/ToolProjects.tsx` on the tool profile. **Coverage is deliberately partial** — 13 briefs across react/nextjs/fastapi/docker/pytorch/rust; everything else gets a visible empty state, never a generated filler.
162
-
163
-
### One unified tool catalog (single source of truth)
164
-
**`app/services/catalog.py` is the ONE place tools are defined.** Its `TOOLS` list carries all three concerns per tool: display (name, slug, icon, category, description), learning (level, is_entry_point, seq, parent_slug), and scraping (github_repo, keywords). To add/edit/remove a tracked tool, edit this file and nothing else.
165
-
166
-
-`seed.py` imports it as `SEED_TOOLS` (seeds the DB from it).
167
-
-`scoring.py` derives `TOOL_REGISTRY` (repo + keywords + category) and the mention-matching regex patterns from it.
168
-
-`scheduler.py` Step 0 **never creates tool rows** — it only warns if a catalog tool is missing. Creating rows there was the old bug.
169
-
-`seed.reconcile_catalog(db)` runs on every startup (after `run_seed`) and **deletes any `tools` row whose slug isn't in the catalog** — this purges legacy placeholder/duplicate rows so the live DB always matches the catalog.
170
-
171
-
`category`**must** match a `Domain` name in `SEED_DOMAINS` (domain pages / learning paths resolve by it). This replaced a prior dual-catalog bug where `SEED_TOOLS` and a separate hardcoded `TOOL_REGISTRY` disagreed on slugs/repos and spawned ~23 null-category placeholder rows (e.g. "Python #1"). History: `memory/stackradar-data-integrity.md`.
172
-
173
-
All 31 tools now carry real GitHub stars + percentile scores (a live authenticated scrape ran 2026-07-13). The catalog membership is the curated 31; widen it later by adding entries to `catalog.py` (+ a matching `Domain` if the category is new).
174
-
175
-
### Signal quality — the "mentions" pipeline
176
-
The GitHub half of the score always worked; the **developer-conversation half** used to read `0` for every tool. Two root causes were fixed (2026-07-13):
177
-
1.**Rounding sink (fixed).** Mentions were sentiment-weighted floats (neutral `0.5`) then `round()`-ed → `round(0.5) = 0`, so isolated mentions vanished. `scheduler.py` Step 3 now uses `scoring.count_mentions` → **raw integer counts** (one per matching item), no rounding.
178
-
2.**Under-used text (fixed).** Matching now runs over `title + tag_list/tags + subreddit + description` via `scoring._item_text`. Dev.to's `description` was previously ignored and is where most matches now come from.
179
-
3.**Thin volume (inherent).** One ~170-item snapshot across 4 sources; HN items are title-only, so a single cycle yields only a handful of mentions (~5). They **accumulate across cycles** in `ToolSnapshot.mention_count` (scheduler ~line 346). `tool.hn_count`/`devto_count`/etc. hold the latest cycle's raw counts. `count_weighted_mentions` + `SENTIMENT_WEIGHTS` remain in `scoring.py` for future sentiment work but are no longer on the scrape path.
180
-
To grow the signal further: add more subreddits/RSS feeds, fetch HN story text (not just titles), or widen keywords in `catalog.py`.
181
-
182
112
### Frontend
183
113
-**App Router** (`frontend/src/app/`). Key routes: `/` (landing — **six editorial chapters on the `scrollcraft` engine, "chaptered editorial" grammar**; see below), `/explore`, `/trends`, `/compare`, `/tools/[slug]` (renders `LearningResources`), `/roadmap/[technology]` (interactive path — per-step "Watch on YouTube" + per-tool "Best course" videos, progress check-off), `/roadmaps`, `/watchlist`, plus the growth surfaces: `/plan/[slug]` (public shareable career-plan landing, per-goal OG preview), `/learn/[slug]` (SSR SEO guide "How to Learn X in 2026" with Course/FAQ JSON-LD), and `/api/og` (dynamic Open Graph card via `next/og`). `ShareButton` (native share + copy) drives the acquisition loop; goal→roadmap mapping lives in `src/data/goals.ts`. `sitemap.ts` lists all learn/roadmap/plan/tool pages. Set `NEXT_PUBLIC_SITE_URL` in production so OG/canonical/sitemap URLs are absolute.
184
114
-**`frontend/src/data/trends.ts` is the only place the frontend talks to the backend.** Every page imports typed `fetchX()` helpers from here (`fetchTools`, `fetchOverview`, `fetchToolDetail`, `fetchLearningPath`, `fetchCompareTools`, etc.). Fetches use Next.js ISR (`revalidate`). **Do not hardcode tool/score/roadmap data in components — it must come through this layer.**
0 commit comments