The web client#
The web client in client/ is a Next.js 16 App Router application on React 19 and Tailwind 4. It renders the landing page and the public docs, the dashboard of a user's repositories, five views of each repository (overview, explorer, glossary, graph and chat, plus settings), and the account settings. This page explains its routes, how it fetches data, how authentication gates pages, its component layout, and the conventions that matter when changing it.
Terms used on this page#
- Server component: a React component rendered on the Next.js server. It can read cookies and call the backend before any HTML is sent.
- Client component: a file marked
"use client", rendered in the browser too, which can hold state and handle events. - Server action: a function in a
"use server"file that a component calls like a local function; Next.js runs it on the server. - Proxy: Next.js 16's name for what earlier versions called middleware: code that runs before a route renders. Illume's is
src/proxy.ts.
Next.js 16 changed APIs and file conventions. client/AGENTS.md tells contributors to read the bundled guides in node_modules/next/dist/docs/ before writing client code, rather than relying on remembered Next.js behaviour.
Stack#
| Package | Version | Used for |
|---|---|---|
next | 16.2 | routing, server components, server actions |
react | 19.2 | |
tailwindcss | 4 | styling, configured in app/globals.css |
react-force-graph-3d, three | 1.29, 0.183 | the 3D graph page |
react-markdown, remark-gfm, rehype-* | the docs site and chat answers | |
mermaid | 12.3 | diagrams in the docs |
geist | Geist Sans for text, Geist Pixel Square for labels | |
vitest, @playwright/test | 5, 1.63 | unit and end-to-end tests |
Path alias @/* maps to src/*. The only environment variable is NEXT_PUBLIC_BACKEND_URL; see environment variables.
Routes#
| Route | File | Access | What it shows |
|---|---|---|---|
/ | app/page.tsx | public | the landing page: hero constellation, features, walkthrough, FAQ |
/login | app/login/page.tsx | public | GitHub sign-in beside a live graph |
/contact | app/contact/page.tsx | public | the contact form |
/mobile | app/mobile/page.tsx | public | download page for the Android app |
/privacy | app/privacy/page.tsx | public | the privacy policy, including how to delete an account |
/docs, /docs/... | app/docs/ | public | these documents; see the docs site |
/dashboard | app/dashboard/page.tsx | signed in | the repository collection, the free-tier banner, adding a repository; when empty, a card opening the sample repository |
/settings | app/settings/page.tsx | signed in | account, AI credentials, free-tier allowance, agent settings, MCP tokens, account deletion |
/repo/[id] | app/repo/[id]/page.tsx | signed in | while ingesting, the live pipeline board; when ready, the overview: brief, stats, where to start, risky files, owners |
/repo/[id]/explorer | app/repo/[id]/explorer/page.tsx | signed in | the file tree with reading order, and a selected file's risk, owners, symbols, history and neighbourhood |
/repo/[id]/glossary | app/repo/[id]/glossary/page.tsx | signed in | the glossary, paginated, with an A to Z rail and search |
/repo/[id]/graph | app/repo/[id]/graph/page.tsx | signed in | the 3D dependency graph; see rendering |
/repo/[id]/chat | app/repo/[id]/chat/page.tsx | signed in | conversations, presets, streamed agent answers, the live graph |
/repo/[id]/settings | app/repo/[id]/settings/page.tsx | signed in | auto-update, the read-only share link, the analysed version, export, re-ingest and delete |
/share/[token] | app/share/[token]/page.tsx | public | a shared repository, read-only: the overview, plus chat (switched off), graph, explorer and glossary; no settings |
/dev/pipeline | app/dev/pipeline/page.tsx | public | a harness that replays recorded ingest frames through the real pipeline board |
[id] is the repository's repo_number, not its UUID. Pages that call UUID-keyed endpoints first load the repository to get its id.
Every route has a loading.tsx skeleton, so navigation streams immediately. app/error.tsx and app/repo/[id]/error.tsx are error boundaries, and app/not-found.tsx is the 404 page; the last two use StatusScreen. The root layout (app/layout.tsx) draws Starfield, a fixed canvas of twinkling pixel stars, behind every page at -z-20; the favicon and touch icon are app/icon.svg, app/favicon.ico and app/apple-icon.png. There is no /signup route: sign-in is through GitHub OAuth, and SignupForm.tsx is no longer rendered anywhere.
The repository layout#
app/repo/[id]/layout.tsx is a server component shared by every repository route. It loads the repository and its file-level graph once, wraps the children in RepoGraphProvider (RepoGraphContext.tsx) so client pages can read the graph without fetching it again, and renders RepoNavbar and BackgroundGraph. On the graph and settings routes the background is veiled; on the chat route it gives way to the chat's own live graph.
Shared views#
app/share/[token]/layout.tsx is the shell of the public, read-only view. It resolves the link through api/share.ts, which sends no cookie, and renders ShareNavbar, a "Read-only shared view" banner with a sign-up link, and the same ambient graph. The graph and chat fill the screen below the header, so the banner steps aside on them (isFullHeightSharePath) rather than push their bottom edge off screen: the graph shows the same notice as ReadOnlyPanel, passed to GraphClient through its notice prop and drawn above the search panel, and the chat page draws the same strip inside its fixed frame. Its metadata sets robots: { index: false } and referrer: "no-referrer". A wrong or switched-off link is notFound(), caught by app/share/not-found.tsx; a repository still being analysed (summary status, or a 409) and a rate limit (429) get their own ShareNotice.
The pages reuse the owner's presentational components rather than copying them: RepoOverview, GlossaryView, GraphClient and ExplorerClient take a basePath (where internal links point) and a readOnly flag (no chat links), and the explorer takes source="share" so its per-file requests go to the public routes without credentials (a string rather than loader functions, because a server page cannot pass functions to a client component). The owner's pages pass /repo/<number> and keep working unchanged.
The chat is listed in the shared navigation but switched off, since an answer runs a model on the owner's account. /share/[token]/chat renders SharedChat, the chat's empty state with the composer, the model picker and the starter questions all disabled under the read-only strip; it sends no request. Every shared route has a loading.tsx that re-exports the owner's skeleton for the same page, and app/share/loading.tsx, one segment up, covers the layout's own loading with a skeleton header, navigation and overview.
The sample repository#
lib/sample.ts holds SAMPLE_SHARE_URL, the share link of a sample repository the operator has analysed and shared. The landing page's "Try it on a real repo" button and "Sample repository" footer link and the empty dashboard's "Explore a sample repository" card all open it, so a visitor can see a finished analysis before signing up or adding a repository. It is a constant, not an environment variable: set it to the real /share/<token> path once, and never regenerate or switch off that link, or they all lead to the "link not available" page. Re-analysing the sample keeps its link.
Authentication#
sequenceDiagram
participant B as Browser
participant P as proxy.ts
participant N as Next server
participant A as API
B->>P: GET /repo/12
alt no access_token cookie
P-->>B: redirect to /login
else cookie present
P->>N: continue
N->>A: fetch with the forwarded cookie
A-->>N: data, or 401
N-->>B: HTML
end
- The session is the backend's httponly
access_tokencookie. The client never stores a token inlocalStorage. proxy.tsredirects a request without the cookie away from any path starting with/dashboard,/repoor/settings, and a request with the cookie away from exactly/or/loginto the dashboard. It only checks that the cookie exists; the backend validates it. Its matcher skipsapi,_next/static,_next/imageand.pngpaths.- Because
/redirects a signed-in user, the landing page is visible only when signed out. - Signing in sends the browser to
${NEXT_PUBLIC_BACKEND_URL}/api/v1/auth/github; the backend sets the cookie on its callback. See authentication.
Data fetching#
Fetching is hybrid, deliberately:
| Where | How | Cache |
|---|---|---|
server components, via src/api/* | fetch with cookie: (await headers()).get("cookie") forwarded | no-store |
server actions in src/actions/* | fetch with Cookie: cookieStore.toString() | no-store |
| client components and hooks | fetch(..., { credentials: "include" }) straight to the backend origin | browser |
Every file under src/api/ and src/actions/ is "use server". The browser reaches the backend at the absolute NEXT_PUBLIC_BACKEND_URL; there are no rewrites, so the backend's CORS configuration must allow the frontend origin with credentials.
| Module | Fetches |
|---|---|
api/auth.ts | the current user |
api/repository.ts | the repository list and one repository |
api/graph.ts | GET /graph?level= |
api/guide.ts | the onboarding guide and stats |
api/glossary.ts | glossary pages and search |
api/ownership.ts | ownership and knowledge silos |
api/fileDetail.ts | one file's symbols and history |
api/chat.ts | chat history |
api/github.ts | the GitHub proxy (branches, commits, repository search) |
Server actions cover writes: deleting, re-ingesting and syncing a repository, auto-update settings, AI credentials and agent settings, MCP tokens, and the .illume export. Actions that end in redirect() are called through utils/redirectingAction.ts, which tells a real redirect apart from a failure.
Client components that talk to the backend directly: the chat (useAgentStream, useConversation, useConversationList), the ingest WebSocket (useIngestStream), the repository picker and timeline (RepoPickerModal, useGitGraph), repository settings, repository thumbnails, the GitHub star count and the status line (SystemStatus, which reads the backend health probe).
Polling#
DashboardRefreshcallsrouter.refresh()periodically while any repository on the dashboard is ingesting.RepoStatusPollerdoes the same on a repository page while a background sync is running or the ingest has not finished.IngestFlowrefreshes once when an ingest completes or fails; see the WebSocket page.
The chat client#
The chat is the most involved part of the client and is documented with the backend it talks to:
hooks/useAgentStream.tsposts to the streaming endpoint and parses the response body with the small SSE parser inlib/agent/sse.ts.lib/agent/reducer.tsis a pure state machine that folds events into a turn: steps, lanes, highlights for the live graph, the answer text and its citations.lib/agent/presets.tslists the presets, which are disabled for the user's tier and model, the advanced overrides, and what is remembered between visits.ChatPage,TurnView,ActivityBlock,AnswerView,CitationCard,PresetPicker,AdvancedDrawer,ConversationSidebarandStaleNoticerender it.
See chat and citations and the agent.
Component layout#
client/src/
app/ routes, layouts, loading and error files, globals.css
api/ "use server" reads for server components
actions/ "use server" writes
components/ page-level components
chat/ the chat page and its parts
docs/ the docs site renderer
ingest/ the pipeline board and raw log
landing/ landing page sections and demos
ui/ shared building blocks: Button, Modal, Select, Switch, cards
hooks/ client state and fetching
lib/ pure logic: agent state, pixel graph scenes, docs loading, GitHub helpers
utils/ small pure helpers
types/ shared TypeScript types for API payloads
proxy.ts the auth gatePure logic lives in lib/ and utils/ with no React imports, so it can be unit-tested in Vitest's Node environment. utils/ingestFlow.ts and lib/agent/reducer.ts are the two examples that matter most.
Conventions#
- WebGL only in the browser. Any component that uses Three.js is imported with
next/dynamicand{ ssr: false }, asGraphClientdoes. - Dynamic imports for heavy client-only code. The chat's
LiveGraphis loaded only on wide screens; Mermaid is imported after mount. - Prettier formatting, two-space indent, format on save (configured in
.zed/settings.json). - ESLint over
src/is report-only in CI.npm run lintcurrently reports about 50 problems, 30 of themno-explicit-any. Lint overtests/,e2e/,e2e-prod/andvitest.config.tsblocks. - Type-check with typegen first:
npx next typegenthennpx tsc --noEmit(alsonpm run typecheck), becausenext-env.d.tsis gitignored. - One dark theme. The interface ships one palette; colours are CSS variables in
globals.css. - The
Graphtype is loose.types/graph.tsdeclareslanguage,fan_inandfan_outon every node, but symbol-level nodes from the API do not carry them.
Design trade-offs and limits#
- Hybrid fetching. Server components give fast first paint with the session cookie; client fetches keep interactive pages live. The price is two ways of calling the same backend, and CORS configuration that must be right.
- Existence-only gating. The proxy cannot tell an expired cookie from a valid one, so an expired session reaches a page and fails there with a 401 from the backend.
- No client cache. Everything is
no-store, so every navigation refetches. - Uncommitted redesign. Documentation and
maindisagree until the redesign is committed.
Related documentation#
- The docs site: how these pages are served.
- Rendering the graph: the graph components.
- Frontend and end-to-end tests: how the client is tested.
- The mobile app: the native client.
- API reference: every endpoint the client calls.