Apps:
- API (NestJS) — REST + WebSocket
- Worker (NestJS) — queues, ingestion, scoring, publishers
- Frontend (Next.js) — optional for now
- Node 18+ (or latest LTS)
- Redis (local
redis://localhost:6379or Upstash URL)
npm installSet env files as needed.
API (apps/api/.env):
PORT=3001
FRONTEND_ORIGIN=http://localhost:3000
# Optional: set if you have Redis
# REDIS_URL=redis://localhost:6379Worker (apps/worker/.env):
# Optional: set if you have Redis (recommended for WS live)
# REDIS_URL=redis://localhost:6379Note: API uses SQLite by default (no DB setup required). The DB file is apps/api/prisma/dev.db.
cd apps/api
npm run db:setup
# runs prisma generate → migrate → seed (adds demo token/signals)In two terminals:
- Worker (queues, ingestion, scoring)
cd apps/worker
npm run start:dev- API (REST + WS)
cd apps/api
npm run start:devOptional 3) Frontend (if you want UI now)
cd apps/frontend
# ensure NEXT_PUBLIC_API_URL points to API, e.g. http://localhost:3001
npm run dev-
REST:
-
WebSocket (without frontend):
npm i -g wscat
wscat -c ws://localhost:3001
# expect messages: {"type":"signals:live","data":{ tokenId, score, label, at }}- Worker enqueues market and scoring jobs on intervals.
- Market snapshots are persisted; scoring computes
Signalrows and publishes tosignals:livevia Redis if configured. - API serves REST from SQLite and relays WS events (falls back to mock if Redis not set).
- Port already in use: stop previous processes or change PORT in
.env. - No WS updates: ensure
REDIS_URLis set for both API and worker or rely on API mock fallback. - See data: run
npx prisma studioinapps/apito view tables.
- The monorepo contains
apps/api(NestJS),apps/worker(NestJS worker),apps/frontend(Next.js), and sharedpackages/*TS libs. - DB schema and migrations (Prisma) were updated; run
cd apps/api && npm run db:syncto apply migrations, regenerate client, and seed local DB. - For full realtime behaviour set
REDIS_URLin both API and Worker environments.
Direction: prioritize developer DX (db sync script added), add CI checks to run db:sync before tests, and consider migrating from SQLite to Postgres for production.