Finance is a Next.js 16 stock research terminal from Chloei. It is auth-gated, FMP-backed, and designed around US equities first, with watchlists, screeners, stock dossiers, calendars, market breadth, and a secondary /copilot workspace that preserves the Chloei agent stack.
- Node.js 20+
- pnpm 9+
- PostgreSQL
pnpm install
cp .env.example .env.local
pnpm auth:migrate
pnpm threads:migrate
pnpm markets:migrate
pnpm devThe app runs on http://localhost:3000.
- Start with
AGENTS.mdfor the repo contract. - Use the nearest nested
AGENTS.mdfor specialized areas, includingsrc/app/api,src/app/api/agent,src/lib/server/markets, andsrc/components/agent. - Expanded repo guidance lives in
docs/agents/*and architecture notes live indocs/architecture/*.
DATABASE_URLBETTER_AUTH_SECRETBETTER_AUTH_URLfor local development and any non-Vercel deployment
AUTH_DATABASE_URL: optional Better Auth database override; falls back toDATABASE_URLwhen unsetBETTER_AUTH_COOKIE_DOMAIN: optional shared cookie domain for cross-subdomain Better Auth sessions (for examplechloei.ai)FMP_API_KEY: enables Financial Modeling Prep market data and FMP MCP tools inside/copilotFMP_PLAN_TIER: manual Financial Modeling Prep plan label used for server-side capability gating (STARTER,PREMIUM, orULTIMATE)OPENROUTER_API_KEY: enables the/copilotagent workspaceTAVILY_API_KEY: enables search tools inside/copilot
Without FMP_API_KEY, the market shell still renders but the data sections remain empty and show setup warnings.
pnpm dev: start the Next.js dev serverpnpm build: build the production apppnpm start: run the production apppnpm auth:migrate: apply Better Auth schema changespnpm threads:migrate: apply thread storage schema changespnpm markets:migrate: apply market storage schema changespnpm markets:capabilities: probe representative FMP endpoints against the current key to audit tier access assumptionspnpm lint: run ESLintpnpm lint:fix: run ESLint autofixespnpm format: run Prettierpnpm format:check: verify formattingpnpm test: run the Vitest suitepnpm test:e2e: run the Playwright browser smoke suite for auth + market flowspnpm test:e2e:copilot: run the live/copilotsmoke suite (uses the configured AI key)pnpm test:e2e:install: install the Chromium browser used by Playwrightpnpm test:watch: run Vitest in watch modepnpm typecheck: run TypeScript checks
/: market overview workspace/news: market news feed/history: recent research history/portfolio: user portfolio workspace/settings: account and data settings/watchlists/[id]: durable user watchlist/stocks/[symbol]: stock dossier page/etfs/[symbol]: ETF dossier page/copilot: Finance copilot workspace
pnpm markets:migrate creates:
symbol_directorywatchlistwatchlist_itemssaved_screensmarket_cache_entriesmarket_api_usage_dailymarket_api_usage_minute
- FMP access is server-only. The browser never sees the API key. The same
FMP_API_KEYnow powers both the market workspace and FMP MCP tool access in/copilot. - Tests now live in domain-local
__tests__directories to keep runtime folders lower-noise for both humans and Codex. - To share logins with another Chloei app, point both apps at the same Better Auth database and secret, set
BETTER_AUTH_COOKIE_DOMAINto the shared parent domain, and include every live subdomain inBETTER_AUTH_TRUSTED_ORIGINS. - The FMP integration uses
/stable/*endpoints with plan-aware fallbacks for tiers that do not expose batch quotes, batch index quotes, ETF asset exposure, or DCF. /copilotauto-enables the full remote FMP MCP catalog whenFMP_API_KEYis configured and falls back to the existing tool set if MCP discovery is unavailable.- On Vercel preview deployments, Better Auth falls back to the deployment URL when
BETTER_AUTH_URLis unset. - Set
FMP_PLAN_TIER=STARTERfor Starter access. Starter is treated as US-only with 300 calls per minute and 20 GB over a trailing 30-day window. - Thread metadata now supports a bound stock symbol so the copilot path can attach to a company later without creating a separate chat system.
Before closing a substantial change, run:
pnpm test
pnpm test:e2e
pnpm lint
pnpm typecheck
pnpm buildWhen market capability assumptions or storage behavior change, also run pnpm markets:capabilities.