learning_ai_invt_trdg/backend/src/services
Saravana Achu Mac 938ed86044 feat: live data wiring (Alpaca/FMP) + strategy builder + screener
Wires the new dashboard to real market data and adds the strategy
builder & screener UIs that were stubbed in the previous commit.

Frontend (web/src/):
- lib/marketApi.ts: authenticated fetch helpers for chart bars,
  market indices, news, and FMP research endpoints
- views/HomeView.tsx: StockChart now fetches live OHLCV via
  fetchChartBars on symbol/period change with loading/error states;
  ResearchCards replaces the static placeholder with live FMP
  profile/metrics/earnings (next-earnings + last 3 historical)
- components/layout/Header.tsx: live SPY/DIA/QQQ price + change%
  via fetchMarketIndices, refreshing every 60s; removed unused
  static sparkline placeholder
- components/strategy/VisualRuleBuilder.tsx: drag-and-drop IF/THEN
  rule composer using @dnd-kit (RSI/MACD/EMA/Price/Volume,
  above/below/crosses, BUY/SELL with shares or % of capital);
  saves via POST /api/profiles
- components/strategy/CodeStrategyEditor.tsx: Monaco editor with
  JS strategy template; "Run Backtest" posts to /api/backtest and
  renders return/win-rate/Sharpe/drawdown plus trade log
- views/ResearchView.tsx: adds "Visual Builder" and "Code Editor"
  sub-tabs alongside Strategies / Signals / Backtesting
- views/ScreenerView.tsx: live FMP screener with market-cap and
  sector filters, sortable columns, click-to-load-symbol routing
- index.css: light theme background; @keyframes spin for loaders
- App.dom.test.tsx: rewritten for router-based AppShell (was
  asserting on the removed tab UI; fixes 5 prior failures)

Backend (backend/src/services/apiServer.ts):
- /api/chart/bars: detects crypto symbols (contains "/") and
  routes to Alpaca v1beta3/crypto/us/bars; equities use
  v2/stocks/{symbol}/bars with iex feed
- (existing) /api/news, /api/market/indices, /api/research/{
  profile,metrics,earnings}, /api/screener proxy endpoints

Build/config:
- web/vite.config.ts: dedupe react / react/jsx-runtime /
  react-router-dom so the vendored react-auth dist resolves the
  same React instance (fixes "Cannot resolve react/jsx-runtime"
  Rollup error)
- web/tsconfig.app.json: exclude shared/platform-clients.ts and
  shared/platform-mobile.ts (mobile-only, missing RN SDK)
- web/package.json: add react-router-dom, @monaco-editor/react,
  @dnd-kit/core, @dnd-kit/sortable, @dnd-kit/utilities

Verification: `npm run build` in web/ → clean (✓ built in 3s);
backend tsc --noEmit → clean. Test suite: 151/155 pass; the 4
remaining failures are pre-existing (3 useTabFeatureFlags module
cache leaks, 1 EntryForm), not introduced here.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 06:16:46 -07:00
..
aiClient.ts feat(backend): wire Azure Key Vault secret resolution at startup 2026-04-05 18:28:47 -07:00
apiServer.ts feat: live data wiring (Alpaca/FMP) + strategy builder + screener 2026-05-04 06:16:46 -07:00
auditRepository.ts feat(backend): WebSocket namespaces, audit persistence, tab flags, telemetry 2026-04-29 19:35:00 -04:00
AutoTrader.ts refactor: move runtime trading records to cosmos 2026-04-04 17:48:49 -07:00
canonicalLifecycleService.ts refactor(backend): extract shared trading persistence types from SupabaseService 2026-04-04 18:56:20 -07:00
CapitalLedger.ts refactor(backend): resolve legacy Supabase client inside capital ledger repository 2026-04-04 18:53:29 -07:00
capitalLedgerRepository.ts refactor(backend): route legacy Postgres access through legacySupabaseClient 2026-04-04 19:30:15 -07:00
distributedLockRepository.ts refactor: move distributed locks to cosmos-first repository 2026-04-04 16:33:27 -07:00
distributedLockService.ts refactor(backend): route legacy Postgres access through legacySupabaseClient 2026-04-04 19:30:15 -07:00
dynamicConfigRepository.ts refactor: remove dynamic config legacy fallback 2026-04-04 18:13:41 -07:00
executionManager.ts refactor: align reconciliation runtime flows with repository 2026-04-04 16:28:59 -07:00
healthTracker.ts feat: adopt platform auth and cosmos trading control 2026-04-04 13:13:08 -07:00
legacySupabaseClient.ts refactor(backend): route legacy Postgres access through legacySupabaseClient 2026-04-04 19:30:15 -07:00
manualEntryRepository.ts refactor: move runtime trading records to cosmos 2026-04-04 17:48:49 -07:00
ManualTrader.ts refactor(backend): resolve legacy Supabase client inside user, profile, and snapshot repositories 2026-04-04 18:47:23 -07:00
MetricsService.ts feat: scaffold trading monorepo foundation 2026-04-04 11:18:21 -07:00
notifier.ts feat: scaffold trading monorepo foundation 2026-04-04 11:18:21 -07:00
observabilityService.ts feat: scaffold trading monorepo foundation 2026-04-04 11:18:21 -07:00
orderActivityRepository.ts refactor: move runtime trading records to cosmos 2026-04-04 17:48:49 -07:00
OrderStatusSyncService.ts refactor: route backend order history access through repository 2026-04-04 16:25:46 -07:00
platformAuthService.ts fix(backend): route alerts admin scoping through isTradingAdmin 2026-04-04 18:58:06 -07:00
profileRepository.ts refactor(backend): route legacy Postgres access through legacySupabaseClient 2026-04-04 19:30:15 -07:00
reconciliationExitBackfillService.ts refactor(backend): extract shared trading persistence types from SupabaseService 2026-04-04 18:56:20 -07:00
reconciliationOrderCoverageService.ts refactor: align reconciliation runtime flows with repository 2026-04-04 16:28:59 -07:00
reconciliationParityHeartbeatService.ts refactor(backend): resolve legacy Supabase client inside user, profile, and snapshot repositories 2026-04-04 18:47:23 -07:00
reconciliationService.ts refactor: route backend order history access through repository 2026-04-04 16:25:46 -07:00
reconciliationSubTagRepairService.ts refactor(backend): extract shared trading persistence types from SupabaseService 2026-04-04 18:56:20 -07:00
reconciliationWatchdogAutoResumeService.ts feat: scaffold trading monorepo foundation 2026-04-04 11:18:21 -07:00
riskEngine.ts feat: scaffold trading monorepo foundation 2026-04-04 11:18:21 -07:00
runtimeOrderRepository.ts refactor(backend): extract shared trading persistence types from SupabaseService 2026-04-04 18:56:20 -07:00
snapshotRepository.ts refactor(backend): route legacy Postgres access through legacySupabaseClient 2026-04-04 19:30:15 -07:00
stateMerge.ts feat: scaffold trading monorepo foundation 2026-04-04 11:18:21 -07:00
strategyPresetRepository.ts refactor(backend): route legacy Postgres access through legacySupabaseClient 2026-04-04 19:30:15 -07:00
SupabaseService.ts feat(backend): WebSocket namespaces, audit persistence, tab flags, telemetry 2026-04-29 19:35:00 -04:00
TradeExecutor.ts refactor: route backend order history access through repository 2026-04-04 16:25:46 -07:00
tradeHistoryRepository.ts refactor: move runtime trading records to cosmos 2026-04-04 17:48:49 -07:00
tradeMonitor.ts refactor: align reconciliation runtime flows with repository 2026-04-04 16:28:59 -07:00
tradingControlRepository.ts feat: adopt platform auth and cosmos trading control 2026-04-04 13:13:08 -07:00
tradingPersistenceTypes.ts refactor(backend): extract shared trading persistence types from SupabaseService 2026-04-04 18:56:20 -07:00
tradingRecordStore.ts refactor: move runtime trading records to cosmos 2026-04-04 17:48:49 -07:00
tradingTelemetry.ts feat(backend): WebSocket namespaces, audit persistence, tab flags, telemetry 2026-04-29 19:35:00 -04:00
tradingUserTypes.ts refactor(backend): extract UserConfig to tradingUserTypes 2026-04-04 19:02:45 -07:00
userRepository.ts refactor(backend): route legacy Postgres access through legacySupabaseClient 2026-04-04 19:30:15 -07:00