Running the Dashboard Locally
For developers working on the web client, or anyone self-hosting TrailAI.
Prerequisites
| Requirement | Notes |
|---|---|
| Node.js | A current LTS release |
| npm | Ships with Node |
| PostgreSQL | 14 or newer, running locally (e.g. Docker postgres:16) or reachable remotely |
| TrailAI server | The backend must be running — the dashboard is a client of it |
The dashboard cannot run usefully on its own; every page reads from the server API.
Configuration
Copy the template and fill it in:
cd web-client
cp .env.example .env.local
# Base URL of the TrailAI backend API
EXTERNAL_API_URL=http://localhost:4040/
# NextAuth — generate a fresh secret: openssl rand -base64 32
NEXTAUTH_SECRET=
NEXTAUTH_URL=http://localhost:3000
# Google OAuth (public client id)
GOOGLE_CLIENT_ID=your_client_id_google_auth
| Variable | Purpose |
|---|---|
EXTERNAL_API_URL |
Where the Next.js API routes proxy to. Include the trailing slash |
NEXTAUTH_SECRET |
Signs session tokens. Generate with openssl rand -base64 32 |
NEXTAUTH_URL |
The dashboard's own URL. Must match how you access it |
GOOGLE_CLIENT_ID |
Enables Google sign-in. Omit to use email/password only |
Never commit .env.local. It is already in .gitignore — keep it that way.
Running
npm install
npm run dev
The dashboard starts on http://localhost:3000 with Turbopack.
Available scripts
| Command | Does |
|---|---|
npm run dev |
Development server with hot reload (Turbopack) |
npm run dev-https |
Development server over HTTPS — needed for some OAuth flows |
npm run build |
Production build |
npm start |
Serve the production build |
npm run lint |
ESLint |
npm test |
Jest in watch mode |
npm run test:ci |
Jest once, for CI |
Running the whole platform
The dashboard needs the server, and the server needs PostgreSQL:
PostgreSQL → TrailAI server (:4040) → Web client (:3000)
Start them in that order. The repository includes a run-platform-locally skill that automates
bringing all three up together — check .claude/skills/ if you're working inside this repo.
Once running:
- Open http://localhost:3000
- Register an account (email confirmation needs SendGrid configured on the server — without it,
activate the account directly in the database:
UPDATE users SET is_verified = true WHERE lower(email) = lower('you@example.com');) - Complete the onboarding wizard
- Generate an API key
- Point an app at
http://localhost:4040/api/sdk/v1
Generating demo data
An empty dashboard is hard to develop against, and useless for screenshots. Use the synthetic load
generator at tools/loadgen:
provision → run → teardown
It fabricates realistic LLM, embedding, vector-DB, and nested-agent traces and sends them through the
same OTLP path as the real SDK, into a dedicated synthetic project. teardown wipes the data but
keeps the project and its API key.
This is the correct way to populate a demo environment before capturing the screenshots this documentation set expects. See assets/index.md.
Project structure
web-client/
├── app/
│ ├── (auth)/ # public pages: login, register, forgot-password, confirm-email
│ ├── (dashboard)/ # the authenticated app
│ ├── api/ # Next.js API routes — proxy to the backend
│ └── docs/ # in-app documentation page
├── components/
│ ├── (auth)/
│ ├── (dashboard)/ # per-feature components
│ ├── common/ # sidebar, nav, data table, project switcher
│ ├── table/
│ └── ui/ # design-system primitives (Radix-based)
├── constants/ # route and endpoint maps
├── context/ # React context providers
├── helpers/ # shared helpers
├── hooks/ # custom hooks
├── interfaces/ types/ # TypeScript definitions
├── lib/ # utilities
├── middleware/ # route protection
├── selectors/ store/ # Zustand state
├── styles/ # global styles
└── __tests__/ # Jest tests
Two files worth knowing:
constants/endpoints.ts—Routes(every dashboard path) andLocalEndpoints(every internal API route). The fastest way to find the page or handler behind a feature.components/common/app-sidebar.tsx— the navigation tree, including the sections currently commented out.
Technology
| Concern | Choice |
|---|---|
| Framework | Next.js (App Router) |
| Auth | NextAuth |
| State | Zustand (with zustand-lens) |
| UI primitives | Radix UI + MUI |
| Styling | Tailwind CSS |
| Tables | TanStack Table |
| Drag & drop | dnd-kit (prompt message reordering) |
| Toasts | Sonner |
| Icons | Lucide |
| Testing | Jest |
Common local issues
| Symptom | Cause | Fix |
|---|---|---|
| Every page errors on load | Server not running or wrong EXTERNAL_API_URL |
Start the server; check the URL and its trailing slash |
| Login redirects in a loop | NEXTAUTH_URL doesn't match your access URL |
Set it to exactly http://localhost:3000 |
| "Invalid session" after restart | NEXTAUTH_SECRET changed or is empty |
Set a stable secret |
| Google sign-in fails | Missing GOOGLE_CLIENT_ID, or redirect URI not whitelisted |
Add the client ID; register the callback in Google Cloud Console |
| No confirmation email | SendGrid not configured on the server | Configure it, or set is_verified = true on the user row in PostgreSQL |
| Dashboard loads but everything is empty | No data yet, or wrong project | Send data, or use tools/loadgen |
More UI-side symptoms in Troubleshooting.
Related
- Architecture — how the dashboard fits the wider system
- Troubleshooting — dashboard behaviour issues