Repository navigation
Modernize project and evaluate profiles locally - #15
Conversation
The evaluator API replaced POST /evaluation/ with GET /evaluation/{user}
and renamed the response fields, so the app could not show any result.
Vite 3 and esbuild 0.15 also failed to install on Node 22.
- Upgrade to React 19, Vite 8, React Router 7, TypeScript 5, Chart.js 4
- Remove unused packages (axios, localforage, match-sorter, fontawesome)
- Move the result page to /evaluation/:username, which fetches its own data
- Share the dark mode state through one context
- Split the code into api, components, hooks, lib and pages folders
- Remove the badge button, because tgs.fly.dev no longer responds
- Rewrite the README in English and add a CI workflow and MIT license
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's GuideAPIDefine the evaluator API response mapping and the exported evaluation and error types that callers rely on.
Uses of the APIConnect the search flow and evaluation route to the evaluator client, including loading, error, and result states.
Define the new shareable evaluation route and retain redirects for the previous route paths.
ImplementationCentralize grade tiers and criterion labels used to translate evaluation data into a displayed result.
Provide shared dark-mode state and persist the selected theme across visits.
UIRender the grade chart, criterion results, navigation controls, status indicators, and theme toggle for the new evaluation experience.
Build the home, error, tea, and not-found screens around the updated routes and shared components.
ConfigurationModernize dependency versions and project scripts for the upgraded React, Vite, router, and TypeScript stack.
Configure the Node version, CI build, TypeScript projects, and Vite and CSS build tooling.
Set the document language, metadata, favicon, and global styling entry point for the refreshed app.
Add the project license and remove the obsolete architecture diagram asset.
DocumentationRewrite the README to explain the criteria, API, routes, setup, configuration, architecture, and deployment.
Other changesFiles not grouped.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 10 issues
Fixed security issues:
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/ci.yml" line_range="17" />
<code_context>
+ with:
+ node-version-file: .nvmrc
+ cache: npm
+ - run: npm ci
+ - run: npm run build
</code_context>
<issue_to_address>
**CI cannot install dependencies**
When the CI workflow runs, `npm ci` exits because the checkout has no committed lockfile; this PR deletes `package-lock.json` without adding a replacement, so CI never reaches the build step.
Commit a supported lockfile or change the workflow to install dependencies without `npm ci`.
</issue_to_address>
### Comment 2
<location path="package.json" line_range="13" />
<code_context>
"dev": "vite",
- "build": "tsc && vite build",
- "preview": "vite preview"
+ "build": "tsc -b && vite build",
+ "preview": "vite preview",
+ "typecheck": "tsc -b"
</code_context>
<issue_to_address>
**TypeScript build always fails**
When the build or typecheck script runs, `tsc -b` treats `tsconfig.app.json` and `tsconfig.node.json` as referenced projects, but neither enables `composite`; it exits with TS6306 before Vite runs, so the build and typecheck fail.
Enable `composite: true` in both referenced TypeScript configs, or change the scripts so they do not use project build mode.
</issue_to_address>
### Comment 3
<location path="package.json" line_range="9" />
<code_context>
+ "description": "Web app that grades a GitHub profile against 10 criteria.",
"type": "module",
+ "engines": {
+ "node": ">=20"
+ },
"scripts": {
</code_context>
<issue_to_address>
**Supported Node versions cannot run Vite**
When a contributor uses an early Node 20 release below Vite 8's minimum supported version, the `>=20` engine range and setup instructions allow Node releases that Vite 8 cannot run on, so contributors on those versions cannot start the dev server or build the app.
Raise the package engine range and setup instructions to Vite 8's minimum supported Node version.
Also at `README.md:41`, `package.json:10`.
</issue_to_address>
### Comment 4
<location path="src/api/evaluator.ts" line_range="2-3" />
<code_context>
+const API_URL =
+ import.meta.env.VITE_EVALUATOR_API_URL ??
+ "https://github-profile-evaluator.betrybe.dev";
+
+// GitHub usernames: alphanumeric or single hyphens, up to 39 characters.
</code_context>
<issue_to_address>
**Blank API setting breaks evaluations**
When `VITE_EVALUATOR_API_URL` is set to an empty string in a deployment environment, `API_URL` becomes an empty string, so `fetchEvaluation` requests `/evaluation/{username}` from the frontend origin instead of the evaluator API; the SPA fallback can return HTML, causing JSON parsing to fail and the result page to show an error.
Trim and validate the configured URL, treating an empty value as unset or failing clearly during startup/build.
</issue_to_address>
### Comment 5
<location path="src/api/evaluator.ts" line_range="65" />
<code_context>
+ if (!isValidUsername(username)) throw new UserNotFoundError(username);
+
+ const response = await fetch(
+ `${API_URL}/evaluation/${encodeURIComponent(username)}`,
+ { signal },
+ );
</code_context>
<issue_to_address>
**Trailing slash breaks API requests**
When `VITE_EVALUATOR_API_URL` is configured with a trailing slash, the configured URL produces `//evaluation/{username}`; the evaluator route does not match that path, so the request fails and users see the error page instead of a result.
Strip trailing slashes from the configured base URL before appending the evaluation path.
</issue_to_address>
### Comment 6
<location path="src/hooks/useTheme.tsx" line_range="33" />
<code_context>
+ useEffect(() => {
+ document.body.classList.toggle("bg-trybe", darkMode);
+ document.body.classList.toggle("bg-trybelight", !darkMode);
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(darkMode));
+ }, [darkMode]);
+
</code_context>
<issue_to_address>
**Theme changes fail when storage is blocked**
When the browser blocks local-storage writes or they fail, `localStorage.setItem` throws from the effect after the body classes change, leaving an uncaught runtime error and a theme preference that is not persisted; the app falls back to the default theme after reload.
Catch storage write failures so the selected theme continues to work for the session.
</issue_to_address>
### Comment 7
<location path="src/api/evaluator.ts" line_range="64-66" />
<code_context>
+): Promise<Evaluation> {
+ if (!isValidUsername(username)) throw new UserNotFoundError(username);
+
+ const response = await fetch(
+ `${API_URL}/evaluation/${encodeURIComponent(username)}`,
+ { signal },
+ );
+ if (!response.ok) {
</code_context>
<issue_to_address>
**Slow evaluations spin indefinitely**
When the evaluator API or network stalls without promptly failing, `fetch` has no deadline; if the evaluator API or network leaves the request pending, `EvaluationPage` remains in its loading state until the request eventually settles or the user leaves the page.
Apply a finite request timeout and transition timed-out requests to a recoverable error state.
</issue_to_address>
### Comment 8
<location path="src/pages/EvaluationPage.tsx" line_range="34-36" />
<code_context>
+ .then((evaluation) => setState({ status: "success", evaluation }))
+ .catch((error: unknown) => {
+ if (controller.signal.aborted) return;
+ setState({
+ status: error instanceof UserNotFoundError ? "not-found" : "error",
+ });
+ });
+
</code_context>
<issue_to_address>
**API failures lack diagnostics**
When the API request fails or its response cannot be parsed, the catch handler discards the error and stores only `status: "error"`; `ErrorPage` shows the same generic message for all failures, so API outages and response/parsing problems are not distinguishable to operators from this app.
Report the failure to available telemetry or at least log its status and cause while keeping the user-facing error generic.
</issue_to_address>
### Comment 9
<location path="src/components/SearchForm.tsx" line_range="33" />
<code_context>
+ >
+ <div className="relative items-center flex group">
+ <input
+ className="rounded-full w-[580px] h-20 bg-white text-2xl text-[#0B5A47] pl-9 peer outline-none"
+ required
+ name="github_user"
</code_context>
<issue_to_address>
**Submit button goes off-screen**
When the app is viewed on a narrow viewport, the input stays 580px wide and the submit button is positioned 463px from its left edge, so the form overflows and the button is partly or entirely off-screen; users cannot submit without horizontal scrolling.
Make the input width and submit-button positioning responsive to narrow viewports.
Also at `src/components/SearchForm.tsx:55`.
</issue_to_address>
### Comment 10
<location path="src/components/SearchForm.tsx" line_range="39" />
<code_context>
+ id="github_user"
+ type="text"
+ autoComplete="off"
+ maxLength={39}
+ onChange={() => setInvalid(false)}
+ />
</code_context>
<issue_to_address>
**Prefixed valid usernames are truncated**
When a user enters `@` followed by a 39-character GitHub username, `maxLength={39}` counts the leading `@` before `handleSubmit` removes it, so the browser truncates the username and the app evaluates a different account.
Allow for the optional `@` in the input length limit or remove it before applying the limit.
Also at `src/components/SearchForm.tsx:15`.
</issue_to_address>Sourcery assessment
Approval pending. 10 findings to address first.
Blocking findings: .github/workflows/ci.yml:17, package.json:13, package.json:9, src/api/evaluator.ts:3, src/api/evaluator.ts:65, and 5 more
| with: | ||
| node-version-file: .nvmrc | ||
| cache: npm | ||
| - run: npm ci |
There was a problem hiding this comment.
🔴 Critical · CI cannot install dependencies
When the CI workflow runs, npm ci exits because the checkout has no committed lockfile; this PR deletes package-lock.json without adding a replacement, so CI never reaches the build step.
Commit a supported lockfile or change the workflow to install dependencies without npm ci.
Prompt for AI agents
In `.github/workflows/ci.yml` at line 17:
**CI cannot install dependencies**
When the CI workflow runs, `npm ci` exits because the checkout has no committed lockfile; this PR deletes `package-lock.json` without adding a replacement, so CI never reaches the build step.
Commit a supported lockfile or change the workflow to install dependencies without `npm ci`.| "dev": "vite", | ||
| "build": "tsc && vite build", | ||
| "preview": "vite preview" | ||
| "build": "tsc -b && vite build", |
There was a problem hiding this comment.
🔴 Critical · TypeScript build always fails
When the build or typecheck script runs, tsc -b treats tsconfig.app.json and tsconfig.node.json as referenced projects, but neither enables composite; it exits with TS6306 before Vite runs, so the build and typecheck fail.
Enable composite: true in both referenced TypeScript configs, or change the scripts so they do not use project build mode.
Prompt for AI agents
In `package.json` at line 13:
**TypeScript build always fails**
When the build or typecheck script runs, `tsc -b` treats `tsconfig.app.json` and `tsconfig.node.json` as referenced projects, but neither enables `composite`; it exits with TS6306 before Vite runs, so the build and typecheck fail.
Enable `composite: true` in both referenced TypeScript configs, or change the scripts so they do not use project build mode.| "description": "Web app that grades a GitHub profile against 10 criteria.", | ||
| "type": "module", | ||
| "engines": { | ||
| "node": ">=20" |
There was a problem hiding this comment.
🟡 Medium · Supported Node versions cannot run Vite
When a contributor uses an early Node 20 release below Vite 8's minimum supported version, the >=20 engine range and setup instructions allow Node releases that Vite 8 cannot run on, so contributors on those versions cannot start the dev server or build the app.
Raise the package engine range and setup instructions to Vite 8's minimum supported Node version.
Also at README.md:41, package.json:10.
Prompt for AI agents
In `package.json` at line 9:
**Supported Node versions cannot run Vite**
When a contributor uses an early Node 20 release below Vite 8's minimum supported version, the `>=20` engine range and setup instructions allow Node releases that Vite 8 cannot run on, so contributors on those versions cannot start the dev server or build the app.
Raise the package engine range and setup instructions to Vite 8's minimum supported Node version.
Also at `README.md:41`, `package.json:10`.| import.meta.env.VITE_EVALUATOR_API_URL ?? | ||
| "https://github-profile-evaluator.betrybe.dev"; |
There was a problem hiding this comment.
🟡 Medium · Blank API setting breaks evaluations
When VITE_EVALUATOR_API_URL is set to an empty string in a deployment environment, API_URL becomes an empty string, so fetchEvaluation requests /evaluation/{username} from the frontend origin instead of the evaluator API; the SPA fallback can return HTML, causing JSON parsing to fail and the result page to show an error.
Trim and validate the configured URL, treating an empty value as unset or failing clearly during startup/build.
Prompt for AI agents
In `src/api/evaluator.ts` at lines 2-3:
**Blank API setting breaks evaluations**
When `VITE_EVALUATOR_API_URL` is set to an empty string in a deployment environment, `API_URL` becomes an empty string, so `fetchEvaluation` requests `/evaluation/{username}` from the frontend origin instead of the evaluator API; the SPA fallback can return HTML, causing JSON parsing to fail and the result page to show an error.
Trim and validate the configured URL, treating an empty value as unset or failing clearly during startup/build.| if (!isValidUsername(username)) throw new UserNotFoundError(username); | ||
|
|
||
| const response = await fetch( | ||
| `${API_URL}/evaluation/${encodeURIComponent(username)}`, |
There was a problem hiding this comment.
🟡 Medium · Trailing slash breaks API requests
When VITE_EVALUATOR_API_URL is configured with a trailing slash, the configured URL produces //evaluation/{username}; the evaluator route does not match that path, so the request fails and users see the error page instead of a result.
Strip trailing slashes from the configured base URL before appending the evaluation path.
Prompt for AI agents
In `src/api/evaluator.ts` at line 65:
**Trailing slash breaks API requests**
When `VITE_EVALUATOR_API_URL` is configured with a trailing slash, the configured URL produces `//evaluation/{username}`; the evaluator route does not match that path, so the request fails and users see the error page instead of a result.
Strip trailing slashes from the configured base URL before appending the evaluation path.| useEffect(() => { | ||
| document.body.classList.toggle("bg-trybe", darkMode); | ||
| document.body.classList.toggle("bg-trybelight", !darkMode); | ||
| localStorage.setItem(STORAGE_KEY, JSON.stringify(darkMode)); |
There was a problem hiding this comment.
🟡 Medium · Theme changes fail when storage is blocked
When the browser blocks local-storage writes or they fail, localStorage.setItem throws from the effect after the body classes change, leaving an uncaught runtime error and a theme preference that is not persisted; the app falls back to the default theme after reload.
Catch storage write failures so the selected theme continues to work for the session.
Prompt for AI agents
In `src/hooks/useTheme.tsx` at line 33:
**Theme changes fail when storage is blocked**
When the browser blocks local-storage writes or they fail, `localStorage.setItem` throws from the effect after the body classes change, leaving an uncaught runtime error and a theme preference that is not persisted; the app falls back to the default theme after reload.
Catch storage write failures so the selected theme continues to work for the session.| const response = await fetch( | ||
| `${API_URL}/evaluation/${encodeURIComponent(username)}`, | ||
| { signal }, |
There was a problem hiding this comment.
🟡 Medium · Slow evaluations spin indefinitely
When the evaluator API or network stalls without promptly failing, fetch has no deadline; if the evaluator API or network leaves the request pending, EvaluationPage remains in its loading state until the request eventually settles or the user leaves the page.
Apply a finite request timeout and transition timed-out requests to a recoverable error state.
Prompt for AI agents
In `src/api/evaluator.ts` at lines 64-66:
**Slow evaluations spin indefinitely**
When the evaluator API or network stalls without promptly failing, `fetch` has no deadline; if the evaluator API or network leaves the request pending, `EvaluationPage` remains in its loading state until the request eventually settles or the user leaves the page.
Apply a finite request timeout and transition timed-out requests to a recoverable error state.| setState({ | ||
| status: error instanceof UserNotFoundError ? "not-found" : "error", | ||
| }); |
There was a problem hiding this comment.
🟡 Medium · API failures lack diagnostics
When the API request fails or its response cannot be parsed, the catch handler discards the error and stores only status: "error"; ErrorPage shows the same generic message for all failures, so API outages and response/parsing problems are not distinguishable to operators from this app.
Report the failure to available telemetry or at least log its status and cause while keeping the user-facing error generic.
Prompt for AI agents
In `src/pages/EvaluationPage.tsx` at lines 34-36:
**API failures lack diagnostics**
When the API request fails or its response cannot be parsed, the catch handler discards the error and stores only `status: "error"`; `ErrorPage` shows the same generic message for all failures, so API outages and response/parsing problems are not distinguishable to operators from this app.
Report the failure to available telemetry or at least log its status and cause while keeping the user-facing error generic.| > | ||
| <div className="relative items-center flex group"> | ||
| <input | ||
| className="rounded-full w-[580px] h-20 bg-white text-2xl text-[#0B5A47] pl-9 peer outline-none" |
There was a problem hiding this comment.
🟡 Medium · Submit button goes off-screen
When the app is viewed on a narrow viewport, the input stays 580px wide and the submit button is positioned 463px from its left edge, so the form overflows and the button is partly or entirely off-screen; users cannot submit without horizontal scrolling.
Make the input width and submit-button positioning responsive to narrow viewports.
Also at src/components/SearchForm.tsx:55.
Prompt for AI agents
In `src/components/SearchForm.tsx` at line 33:
**Submit button goes off-screen**
When the app is viewed on a narrow viewport, the input stays 580px wide and the submit button is positioned 463px from its left edge, so the form overflows and the button is partly or entirely off-screen; users cannot submit without horizontal scrolling.
Make the input width and submit-button positioning responsive to narrow viewports.
Also at `src/components/SearchForm.tsx:55`.| id="github_user" | ||
| type="text" | ||
| autoComplete="off" | ||
| maxLength={39} |
There was a problem hiding this comment.
🟡 Medium · Prefixed valid usernames are truncated
When a user enters @ followed by a 39-character GitHub username, maxLength={39} counts the leading @ before handleSubmit removes it, so the browser truncates the username and the app evaluates a different account.
Allow for the optional @ in the input length limit or remove it before applying the limit.
Also at src/components/SearchForm.tsx:15.
Prompt for AI agents
In `src/components/SearchForm.tsx` at line 39:
**Prefixed valid usernames are truncated**
When a user enters `@` followed by a 39-character GitHub username, `maxLength={39}` counts the leading `@` before `handleSubmit` removes it, so the browser truncates the username and the app evaluates a different account.
Allow for the optional `@` in the input length limit or remove it before applying the limit.
Also at `src/components/SearchForm.tsx:15`.
Summary
The app no longer worked, and the external evaluator API is being shut down. This PR does these things:
GET /api/evaluation?user=<username>reads public data from the GitHub API and calculates the 10 criteria. It runs as a Vercel function and also innpm run dev.api/,server/,shared/, andsrc/./evaluation/:username, so you can refresh it and share the link.Changes in the criteria
Required setup
Add a
GITHUB_TOKENenvironment variable in the Vercel project before you merge. A fine-grained token with public repository access only is enough.Pending before merge
package-lock.json. The install could not run because the local registry token expired.npm run buildand test the app in the browser.Test results
The 14 unit tests pass. The endpoint was tested against real GitHub users, a user that does not exist (404), and an invalid username (400).
🤖 Generated with Claude Code