Dashboard, scoring, and alerts for the Weekly Market Health Checklist (macro, equities, crypto, sentiment).
- Local: NestJS API, TypeORM, BullMQ, Postgres, Redis; Next.js 14 + Tailwind.
- Netlify: Next.js on Netlify; API and jobs as serverless functions (no Redis/BullMQ). Database: Supabase (Postgres).
-
Database (Supabase)
- Create a project at supabase.com.
- Get the connection string: Project Settings → Database → Connection string → URI (use "Transaction" mode, or "Session" if you prefer). For serverless (Netlify functions), the Connection pooling URI (port 6543) is recommended.
- Run the migration: in Supabase → SQL Editor, paste and run the contents of
apps/api/src/database/migrations/001_initial_schema.sql. Or locally:psql "$DATABASE_URL" -f apps/api/src/database/migrations/001_initial_schema.sql.
-
Netlify: Connect the repo (build settings from repo
netlify.toml):- Build command:
npm install && npm run build:web - Publish directory:
apps/web/out - Functions directory:
netlify/functions
- Build command:
-
Environment variables (Site settings → Environment variables). Set these in Netlify so the API and cron can connect:
DATABASE_URL– Preferred. Supabase Postgres connection string: Project Settings → Database → Connection string → URI (use the pooler URI, port 6543, for serverless). When set, the API and cron use TypeORM over Postgres.- When Postgres is not directly accessible: leave
DATABASE_URLunset and setSUPABASE_URLandSUPABASE_SERVICE_ROLE_KEY. The app will use Supabase’s REST API (no direct DB connection). Ensure the same tables exist (run the migration in Supabase SQL Editor). SUPABASE_ANON_KEY– Optional; use if you add Supabase Auth/Realtime/Storage from the frontend.FRED_API_KEY– FRED (10Y yield)TWELVE_DATA_API_KEY– optional (DXY, Nasdaq, leaders)NEXT_PUBLIC_API_URL– your Netlify site URL (e.g.https://your-site.netlify.app) so the app calls/apion the same originCRON_SECRET– optional; set to a secret string if you want to protect manual trigger of run-jobs (POST withX-Cron-Secret: <CRON_SECRET>)SENDGRID_API_KEY,SENDGRID_FROM_EMAIL,ALERT_EMAIL,DASHBOARD_LINK– optional (alerts)
-
Jobs: The
run-jobsfunction runs on a schedule (every 15 minutes via Netlify Scheduled Functions). No Redis or worker process. To trigger manually:POST https://your-site.netlify.app/.netlify/functions/run-jobswith headerX-Cron-Secret: <CRON_SECRET>if set.Indicators show no data? Data is filled by
run-jobs. SetFRED_API_KEY(required for 10Y yield and others) and optionallyTWELVE_DATA_API_KEYin Netlify so the job can fetch data. After deploy, wait up to 15 minutes for the first scheduled run, or trigger the job manually (see above). Check Netlify → Functions → run-jobs logs for errors. -
Redirect:
netlify.tomlrewrites/api/*to/.netlify/functions/api. The Next.js app usesNEXT_PUBLIC_API_URLor same-origin/api.
-
Start Postgres and Redis
docker compose up -d postgres redis
-
Apply database migration
psql "$DATABASE_URL" -f apps/api/src/database/migrations/001_initial_schema.sqlOr set
DATABASE_URL=postgresql://market:market@localhost:5432/market_healthif using default Docker Compose. -
Install and run API
npm install npm run dev:api
API runs at http://localhost:3000. Set
FRED_API_KEYand optionallyTWELVE_DATA_API_KEYfor full data (BTC and Fear & Greed work without keys). -
Run web
npm run dev:web
Web runs at http://localhost:3001. Set
NEXT_PUBLIC_API_URL=http://localhost:3000in.envor.env.localinapps/webif needed.
| Indicator | Source | API key / notes |
|---|---|---|
| macro.us10y | FRED (DGS10) | FRED_API_KEY (free at fred.stlouisfed.org) |
| macro.dxy | Twelve Data | TWELVE_DATA_API_KEY (free tier) |
| eq.nasdaq | Twelve Data | TWELVE_DATA_API_KEY |
| eq.leaders | Twelve Data | NVDA, MSFT, AAPL, GOOGL |
| crypto.btc | CoinGecko (primary), Binance (fallback) | No key for CoinGecko; works from any region. Binance often returns 451 from serverless (Netlify/AWS). |
| sent.fng | Alternative.me | No key; Fear & Greed index |
BTC was previously Binance-only; Binance returns 451 Unavailable For Legal Reasons from many datacenter IPs (e.g. Netlify). The app now uses CoinGecko first for crypto.btc (free, no key, no regional block).
There is no UI in the app to store API keys. They are server-only and must be set in your hosting environment so they are never exposed to the browser.
- On Netlify: Site configuration → Environment variables. Add
FRED_API_KEY,TWELVE_DATA_API_KEY, etc. Redeploy after changing them. - Local:
.envin the repo root (see.env.example).
The job and API read them via process.env.*; they are not stored in the database.
DATABASE_URL– Postgres connection string (required for API)REDIS_URLorREDIS_HOST/REDIS_PORT– Redis for BullMQFRED_API_KEY– FRED (10Y yield)TWELVE_DATA_API_KEY– DXY, Nasdaq, mega-caps (optional; DXY/equities disabled without it)NEXT_PUBLIC_API_URL– API base URL for the Next.js app (e.g. http://localhost:3000)SENDGRID_API_KEY,SENDGRID_FROM_EMAIL,ALERT_EMAIL– optional; for email alerts (SendGrid)DASHBOARD_LINK– optional; link in alert emails (default http://localhost:3001/dashboard)
apps/api– NestJS API (local), provider adapters, status/rules engine, shared entities and servicesapps/web– Next.js dashboardnetlify/functions/api.ts– serverless API (same routes as NestJS)netlify/functions/run-jobs.ts– scheduled job runner (fetch → aggregate → derived → status → rules)netlify.toml– build, redirects (/api → function)apps/api/src/indicators/registry.json– indicator config; copy innetlify/functions/registry.jsonfor serverlessapps/api/src/database/migrations/– SQL migrations (Supabase / plain Postgres)