Email verification is no longer enforced (see backend), and sign-up now auto-signs-in, so route to clinic onboarding instead of /verify-email. Update CLAUDE.md: the app now talks to ../backend (auth + patient API), route protection via proxy.ts, and build/type-check guidance. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6.6 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
@AGENTS.md
The import above is load-bearing: this is a customized Next.js 16 with breaking changes vs. public docs. Before writing any Next.js code (routing, metadata,
next/image,next/font, route handlers, config), read the relevant guide undernode_modules/next/dist/docs/01-app/.
What this is
temetro — an open-source clinical "AI middleman" (see the project vision in the root
../CLAUDE.md). This app is the clinician-facing chat UI. It is now wired to the real
../backend/ for authentication and patient data (no longer a standalone UI-only demo); the AI
chat replies are still mocked (no LLM call yet).
- The chat parses
/patient <file#>(or a bare/<file#>) incomponents/chat/chat-panel.tsxand renders the record as a horizontal row of cards (components/chat/patient-cards.tsx), with small dependency-free trend sparklines (components/chat/sparkline.tsx). Each card opens a detail dialog; the Summary card has an Edit record button. - Patients can be created and edited via the shared
components/chat/patient-form-dialog.tsx(modecreate|edit). The "Add patient" pill inchat-input.tsxopens it. - Non-command messages still get a mock assistant reply.
Auth & data (talks to ../backend)
lib/patients.tskeeps the canonicalPatienttypes but its data functions (getPatient,listPatients,createPatient,updatePatient) now call the backend vialib/api-client.ts(fetchwithcredentials: "include"; 401 →/login). The old in-memory fixture is gone.lib/auth-client.ts— Better Auth React client (useSession,signIn/up/out,organization.*,useActiveOrganization,useListOrganizations). Base URL fromNEXT_PUBLIC_API_URL(defaulthttp://localhost:4000); it appends/api/auth.lib/access.tsmirrors the backend's RBAC roles for the org client.app/(auth)/— designed auth pages (login, signup, verify-email, forgot/reset-password, onboarding = create clinic, accept-invite), in their own chrome-less layout.- Route protection: this Next renames
middleware→proxy.ts(root) — an optimistic redirect to/loginwhen no session cookie. The authoritative gate is client-side:components/auth/app-auth-guard.tsx(wrappingapp/(app)/layout.tsx) requires a session and an active clinic, else redirects to/login//onboarding. - Clinics (organizations):
components/sidebar-02/team-switcher.tsxis now theOrgSwitcher;components/settings/settings-care-team.tsxmanages members + invitations. .env.local/.env.exampleholdNEXT_PUBLIC_API_URL.
The signing / patient-owned-storage / approval features from the root vision are still not built.
Commands
npm run dev # Next dev server (Turbopack) on http://localhost:3000
npm run build # production build (runs a full TypeScript typecheck — see caveat below)
npm run start # serve the production build
npm run lint # eslint (eslint-config-next: core-web-vitals + typescript)
There is no test runner configured (no test script, no vitest/jest/playwright). Don't invent
test commands; verify changes by running the dev server.
Version control: this folder is its own git repo. Commit after every change
(git -C . add -A && git commit), with the Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
trailer. See the root ../CLAUDE.md for the project-wide per-folder commit policy.
Architecture
- Stack: Next.js 16.2.6 (App Router) · React 19 · TypeScript · Tailwind CSS v4. Path alias
@/*→ repo root (tsconfig.json).cn()(clsx + tailwind-merge) lives inlib/utils.ts. app/— App Router.app/page.tsxis the product chat page (sidebar + chat panel);app/layout.tsxforces dark mode by puttingdarkon<html>and loads the fonts.components/ui/— shadcn components, but built on Base UI (@base-ui/react), not Radix. APIs differ: composition uses therenderprop anduseRender/mergeProps, notasChild. Match existing files when adding/editing primitives. Config incomponents.json(stylebase-luma, baseColorneutral).components/ai-elements/— a large AI-chat primitive library (PromptInput,Conversation,Message,Suggestion, etc.) typed against AI SDK v6 (aipackage:UIMessage,ChatStatus,FileUIPart). Note:@ai-sdk/react(useChat) is not installed — chat state is managed with local React state.components/sidebar-02/— the dashboard sidebar (SidebarProvider/Sidebar/SidebarInsetfromcomponents/ui/sidebar.tsx).app-sidebar.tsxholds the nav config (New chat · Patients · Settings) + notifications;team-switcher.tsxexists but is no longer used.components/chat/— the product chat UI.chat-panel.tsxowns message state + empty/active layouts;chat-input.tsxis a bespoke (non–ai-elements) input matching a specific design.
Theming
Tailwind v4 with @theme inline and oklch CSS variables in app/globals.css (a
Linear-inspired dark palette; --primary is indigo #5e6ad2). The app is dark-only. The radius
scale (rounded-2xl … rounded-4xl) is derived from --radius, so those utilities are larger than
stock Tailwind.
Gotchas
- Route protection lives in
proxy.ts, notmiddleware.ts— this customized Next renamed the convention (export function proxy(request)+config.matcher, Node runtime). Seenode_modules/next/dist/docs/01-app/.../proxy.md. components/ai-elements/*has pre-existing type/lint errors (Base UI drift) that used to failnext build.next.config.tsnow setsoutput: "standalone"plustypescript.ignoreBuildErrors/eslint.ignoreDuringBuildsso production/Docker builds succeed — type-check app code withnpx tsc --noEmit(filter outcomponents/ai-elements/), not vianext build. There's aDockerfilefor the standalone build.lucide-react@1.17dropped brand glyphs (e.g.Github,Discord) — import them and you get a build error. Use inline SVGs instead.lucide-react@1.17dropped brand glyphs (e.g.Github,Discord) — import them and you get a build error. Use inline SVGs instead.- A sibling
../landing-page/directory is a copy of this app with a marketing landing page (components/landing/); it is a separate project, not part of this git repo. - Multiple lockfiles in the tree produce a harmless Turbopack "inferred workspace root" warning.