This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
GraphHub is a GitHub follow-relationship visualizer. Users authenticate via GitHub OAuth, enter any GitHub username, and see an interactive force-directed graph of that user's followers and following relationships.
npm run dev # Start dev server with Turbo mode (http://localhost:3000)
npm run build # Production build
npm run check # Run lint + typecheck together
npm run lint # ESLint only
npm run typecheck # TypeScript check only
npm run format:write # Format with PrettierNo test suite is currently configured.
Copy .env.example to .env and fill in:
AUTH_SECRET= # Generate with: npx auth secret
GITHUB_CLIENT_ID= # GitHub OAuth App client ID
GITHUB_CLIENT_SECRET= # GitHub OAuth App client secret
NEXTAUTH_URL= # e.g. http://localhost:3000
The env schema is validated at startup via src/env.js using @t3-oss/env-nextjs.
This is a T3 Stack app (Next.js 14 + tRPC + NextAuth + Tailwind).
- User logs in via GitHub OAuth → NextAuth stores the GitHub access token in a JWT session
- The access token is forwarded through
ctx.session.user.accessTokenin every tRPC call - The tRPC
githubRoutercalls GitHub REST API (/users/:username,/followers,/following) using that token (5000 req/h rate limit) NetworkGraphcomponent renders a force-directed graph withforce-graph/ForceGraph2D
| Path | Role |
|---|---|
src/server/auth/config.ts |
NextAuth config — GitHub provider, JWT callbacks that attach accessToken to session |
src/server/api/trpc.ts |
tRPC context factory — reads session, enforces auth via protectedProcedure |
src/server/api/routers/github.ts |
getUser, getFollowers, getFollowing procedures |
src/server/api/root.ts |
Combines routers into AppRouter |
src/trpc/react.ts |
Client-side tRPC hook (api) |
src/app/_components/NetworkGraph.tsx |
Force-graph canvas component (shared) |
src/app/graph/[username]/page.tsx |
Graph page — redirects to /login if unauthenticated |
src/app/page.tsx |
Home page with UsernameForm — navigates to /graph/:username |
All tRPC procedures use protectedProcedure. The middleware reads ctx.token (the GitHub OAuth access token), and throws UNAUTHORIZED if absent. The token is extracted from the JWT session in createTRPCContext.
NetworkGraph uses force-graph (imperative canvas API via ForceGraph2D()). It is initialized inside useEffect after all three tRPC queries resolve. On cleanup or re-render, graph.destroy() is called. Node colors: blue = target user, green = followers, red = following.
next.config.jshasignoreBuildErrors: trueandignoreDuringBuilds: truefor TypeScript and ESLint — builds won't fail on type errors.- Webpack polyfills are added for
crypto,buffer,stream,process,util(required by some dependencies in the browser). - GitHub avatar images are whitelisted in
next.config.jsunderimages.remotePatterns.
- Do not change library versions without explicit approval.
- Do not modify UI/UX design (layout, colors, fonts, spacing) without approval.
- Do not add unrequested features; propose first and wait for approval.
- Keep
todo.mdupdated after each feature implementation (the project uses a task-tracking file).