/** * @fileoverview v0.18.0 Canonical Routes - /api/infra/* Standardization * Infrastructure Team Consensus: Standardize on /api/infra/* as canonical pattern * Purpose: Unified API surface with enhanced endpoints from Infrastructure audit */ // === AUTHENTICATION & AUTHORIZATION === (Frontend Critical Requirement) export const AUTH_ROUTES = { LOGIN: '/api/auth/login', LOGOUT: '/api/auth/logout', REFRESH: '/api/auth/refresh', VALIDATE: '/api/auth/validate', // Token validation JWKS: '/api/auth/jwks', // JWKS endpoint for JWT validation WHOAMI: '/api/auth/whoami', // Frontend guard requirement PERMISSIONS: '/api/auth/permissions', // Role validation // Enhanced auth endpoints (Frontend requirements) SESSION: '/api/auth/session', // ✅ SSR getUser() endpoint SESSION_VALIDATE: '/api/auth/session/validate', // Session validation TOKEN_REFRESH: '/api/auth/token/refresh', // Token refresh LOGOUT_ALL: '/api/auth/logout/all' // Logout all sessions } as const; // === USER MANAGEMENT === (Frontend Protected Routes Requirement) export const USER_ROUTES = { PROFILE: '/api/user/profile', // User profile management PREFERENCES: '/api/user/preferences', // User preferences SESSIONS: '/api/user/sessions', // Active sessions ORGANIZATIONS: '/api/user/organizations', // User organizations // Enhanced user endpoints (Frontend requirements) ROLES: '/api/user/roles', // User role display ACTIVITY: '/api/user/activity', // User activity log SETTINGS: '/api/user/settings', // User settings NOTIFICATIONS: '/api/user/notifications' // User notifications } as const; // === ADMIN ROUTES === (Admin-only endpoints) export const ADMIN_ROUTES = { USERS: '/api/admin/users', // User management ROLES: '/api/admin/roles', // Role management PERMISSIONS: '/api/admin/permissions', // Permission management SYSTEM: '/api/admin/system', // System administration // Enhanced admin endpoints (Frontend requirements) AUDIT: '/api/admin/audit', // Audit logs ORGANIZATIONS: '/api/admin/organizations', // Organization management SECURITY: '/api/admin/security', // Security settings MONITORING: '/api/admin/monitoring' // System monitoring } as const; // === CANONICAL INFRASTRUCTURE ROUTES === (All teams consensus) export const INFRA_ROUTES = { // === PORTFOLIO DOMAIN === PORTFOLIO: { SUMMARY: '/api/infra/portfolio/summary', // Portfolio overview ACCOUNTS: '/api/infra/portfolio/accounts', // HL accounts (SIPP, ISA, GIA) HOLDINGS: '/api/infra/portfolio/holdings', // HL holdings INVESTMENTS: '/api/infra/portfolio/investments', // Manual investments MANUAL_ADD: '/api/infra/portfolio/manual/add', // Add manual investment SNAPSHOTS: '/api/infra/portfolio/snapshots', // Portfolio snapshots VALUE: '/api/infra/portfolio/value', // Current portfolio value SYNC: '/api/infra/portfolio/sync' // Sync HL data }, // === MARKET DATA DOMAIN === MARKET: { // Core data endpoints OHLCV: '/api/infra/market/data/ohlcv', // OHLCV bars INDICATORS: '/api/infra/market/data/indicators', // Technical indicators BARS: '/api/infra/market/data/bars', // Alternative bars endpoint PRECOMPUTED: '/api/infra/market/data/precomputed', // Pre-computed indicators // Control endpoints (Infrastructure audit findings) UNIVERSE: '/api/infra/market/meta/universe', // Available symbols TIMEFRAMES: '/api/infra/market/meta/timeframes', // Supported timeframes STATUS: '/api/infra/market/meta/status', // Ingestion status PROVIDERS: '/api/infra/market/meta/providers', // Data providers // Data management STORE_BARS: '/api/infra/market/data/bars/store', // Store market bars STORE_INDICATORS: '/api/infra/market/data/indicators/store', // Store indicators HEALTH: '/api/infra/market/health' // Market data health }, // === ML DOMAIN === ML: { // Model management MODELS: '/api/infra/ml/models', // Model registry MODELS_REGISTER: '/api/infra/ml/models/register', // Register new model MODELS_PERFORMANCE: '/api/infra/ml/models/performance', // Model performance MODEL_METRICS: '/api/infra/ml/models/:id/metrics', // Model-specific metrics (ML Critical) MODEL_DEPLOY: '/api/infra/ml/models/:id/deploy', // Model deployment (ML Critical) // Signal operations SIGNALS_STORE: '/api/infra/ml/signals/store', // Store signal SIGNALS_LATEST: '/api/infra/ml/signals/latest', // Latest signals SIGNALS_HISTORY: '/api/infra/ml/signals/history', // Signal history SIGNALS_STREAM: '/api/infra/ml/signals/stream', // Real-time signal stream (SSE) // Consensus operations CONSENSUS_STORE: '/api/infra/ml/consensus/store', // Store consensus CONSENSUS_LATEST: '/api/infra/ml/consensus/latest', // Latest consensus CONSENSUS_HISTORY: '/api/infra/ml/consensus/history', // Consensus history // Feature pipeline (ML Critical) FEATURES_LATEST: '/api/infra/ml/features/latest', // Latest features (ML Critical) FEATURES_STORE: '/api/infra/ml/features/store', // Store features // Ensemble management (ML Enhancement) ENSEMBLE_WEIGHTS: '/api/infra/ml/ensemble/weights', // Ensemble weights (ML Critical) ENSEMBLE_UPDATE: '/api/infra/ml/ensemble/update', // Update ensemble // Analytics and monitoring PERFORMANCE: '/api/infra/ml/performance', // ML performance analytics (ML Critical) ANALYTICS: '/api/infra/ml/analytics', // ML analytics dashboard // Health HEALTH: '/api/infra/ml/health' // ML service health }, // === TRADING DOMAIN === TRADING: { // Account management (Infrastructure audit: new table) ACCOUNTS: '/api/infra/trading/accounts', // Enhanced trading accounts ACCOUNTS_SYNC: '/api/infra/trading/accounts/sync', // Sync account data // Position management POSITIONS: '/api/infra/trading/positions', // Open positions POSITIONS_OPEN: '/api/infra/trading/positions/open', // Open new position POSITIONS_CLOSE: '/api/infra/trading/positions/close', // Close position POSITIONS_HISTORY: '/api/infra/trading/positions/history', // Position history // Trade management TRADES: '/api/infra/trading/trades', // Trade history TRADES_RECENT: '/api/infra/trading/trades/recent', // Recent trades // Order management ORDERS: '/api/infra/trading/orders', // Order history ORDERS_PENDING: '/api/infra/trading/orders/pending', // Pending orders // Health and monitoring HEALTH: '/api/infra/trading/health' // Trading service health }, // === JOBS SYSTEM === (Infrastructure consensus) JOBS: { CREATE: '/api/infra/jobs', // Create job LIST: '/api/infra/jobs/recent', // List recent jobs GET: '/api/infra/jobs/:id', // Get job details UPDATE: '/api/infra/jobs/:id', // Update job CANCEL: '/api/infra/jobs/:id/cancel', // Cancel job LOGS: '/api/infra/jobs/:id/logs', // Job logs (with SSE) CLAIM: '/api/infra/jobs/claim', // Worker claims job HEARTBEAT: '/api/infra/jobs/:id/heartbeat', // Worker heartbeat TRIGGER: '/api/infra/jobs/trigger' // Trigger job type }, // === WEALTH MANAGEMENT === WEALTH: { HL: '/api/infra/wealth/hl', // HL account aggregation SUMMARY: '/api/infra/wealth/summary', // Wealth summary ACCOUNTS: '/api/infra/wealth/accounts', // All wealth accounts SYNC: '/api/infra/wealth/sync' // Sync wealth data }, // === REAL-TIME STREAMING === (Frontend requirement) REALTIME: { POSITIONS: '/api/infra/realtime/positions', // Live position updates SIGNALS: '/api/infra/realtime/signals', // Live signal stream JOBS: '/api/infra/realtime/jobs/:id', // Live job progress PRICES: '/api/infra/realtime/prices' // Live price stream }, // === MARKETPLACE STUBS === (Enhanced for external developers) MARKETPLACE: { // Vendor management (Marketplace Critical) VENDORS: '/api/infra/marketplace/vendors', // Vendor management (stub) VENDORS_REGISTER: '/api/infra/marketplace/vendors/register', // External vendor signup (Critical) VENDORS_PROFILE: '/api/infra/marketplace/vendors/profile', // Vendor profile (Critical) // Model catalog (Marketplace Critical) MODELS: '/api/infra/marketplace/models', // Model catalog (stub) MODELS_CATALOG: '/api/infra/marketplace/models/catalog', // Public model discovery (Critical) MODELS_SUBMIT: '/api/infra/marketplace/models/submit', // Model submission (Critical) // Deployment orchestration (Marketplace Critical) DEPLOYMENTS: '/api/infra/marketplace/deployments', // Deployments (stub) DEPLOYMENTS_CREATE: '/api/infra/marketplace/deployments/create', // RunPod deployment (Critical) DEPLOYMENTS_HEALTH: '/api/infra/marketplace/deployments/health', // Health monitoring (Critical) // Authentication for external developers (Marketplace Critical) AUTH_API_KEYS: '/api/infra/marketplace/auth/api-keys', // CLI authentication (Critical) AUTH_REGISTER: '/api/infra/marketplace/auth/register', // External developer signup (Critical) // Training workflows (Marketplace High Priority) TRAINING_JOBS: '/api/infra/marketplace/training/jobs', // Managed training (High) TRAINING_SUBMIT: '/api/infra/marketplace/training/submit', // Training submission (High) // Revenue and analytics (Marketplace Medium Priority) BILLING: '/api/infra/marketplace/billing', // Revenue tracking (stub) REVENUE_TRACKING: '/api/infra/marketplace/revenue/tracking', // Vendor earnings (Medium) ANALYTICS_PERFORMANCE: '/api/infra/marketplace/analytics/performance', // Model analytics (Medium) ANALYTICS_USAGE: '/api/infra/marketplace/analytics/usage' // Resource usage (Medium) }, // === SYSTEM & HEALTH === SYSTEM: { HEALTH: '/api/infra/health', // Overall system health STATUS: '/api/infra/status', // System status METRICS: '/api/infra/metrics', // System metrics VERSION: '/api/infra/version' // API version info } } as const; // === LEGACY COMPATIBILITY ROUTES === (Deprecation timeline: v0.20.0 removal) export const LEGACY_ROUTES = { // v0.17.0 routes (dual support during transition) PORTFOLIO: { SUMMARY: '/api/portfolio/summary', // Legacy: use INFRA_ROUTES.PORTFOLIO.SUMMARY INVESTMENTS: '/api/portfolio/investments', // Legacy: use INFRA_ROUTES.PORTFOLIO.INVESTMENTS VALUE: '/api/portfolio/value', // Legacy: use INFRA_ROUTES.PORTFOLIO.VALUE HOLDINGS: '/api/portfolio/holdings', // Legacy: use INFRA_ROUTES.PORTFOLIO.HOLDINGS ACCOUNTS: '/api/portfolio/accounts', // Legacy: use INFRA_ROUTES.PORTFOLIO.ACCOUNTS MANUAL_LIST: '/api/portfolio/manual/list', // Legacy: use INFRA_ROUTES.PORTFOLIO.INVESTMENTS MANUAL_ADD: '/api/portfolio/manual/add' // Legacy: use INFRA_ROUTES.PORTFOLIO.MANUAL_ADD }, MARKET: { OHLCV: '/api/marketdata/ohlcv', // Legacy: use INFRA_ROUTES.MARKET.OHLCV INDICATORS: '/api/marketdata/indicators', // Legacy: use INFRA_ROUTES.MARKET.INDICATORS SYMBOLS: '/api/marketdata/symbols' // Legacy: use INFRA_ROUTES.MARKET.UNIVERSE }, ML: { SIGNALS_STORE: '/api/signals/store', // Legacy: use INFRA_ROUTES.ML.SIGNALS_STORE SIGNALS_LATEST: '/api/signals/latest', // Legacy: use INFRA_ROUTES.ML.SIGNALS_LATEST MODELS: '/api/models', // Legacy: use INFRA_ROUTES.ML.MODELS CONSENSUS_LATEST: '/api/consensus/latest', // Legacy: use INFRA_ROUTES.ML.CONSENSUS_LATEST BACKTEST: '/api/ml/backtest', // Legacy: new endpoint PREDICT: '/api/ml/predict' // Legacy: new endpoint }, TRADING: { POSITIONS: '/api/trading/positions', // Legacy: use INFRA_ROUTES.TRADING.POSITIONS TRADES: '/api/trading/trades', // Legacy: use INFRA_ROUTES.TRADING.TRADES ACCOUNTS: '/api/trading/accounts', // Legacy: use INFRA_ROUTES.TRADING.ACCOUNTS TRADES_OPEN: '/api/trading/trades/open', // Legacy: new endpoint TRADES_CLOSED: '/api/trading/trades/closed', // Legacy: new endpoint HISTORY: '/api/trading/history', // Legacy: use INFRA_ROUTES.TRADING.POSITIONS_HISTORY ORDERS: '/api/trading/orders' // Legacy: use INFRA_ROUTES.TRADING.ORDERS } } as const; // === CONSOLIDATED ROUTES OBJECT === export const ROUTES = { // Modern canonical routes (v0.18.0+) AUTH: AUTH_ROUTES, USER: USER_ROUTES, ADMIN: ADMIN_ROUTES, INFRA: INFRA_ROUTES, // Legacy compatibility (deprecated in v0.19.0, removed in v0.20.0) PORTFOLIO: LEGACY_ROUTES.PORTFOLIO, // @deprecated Use INFRA.PORTFOLIO MARKET: LEGACY_ROUTES.MARKET, // @deprecated Use INFRA.MARKET ML: LEGACY_ROUTES.ML, // @deprecated Use INFRA.ML TRADING: LEGACY_ROUTES.TRADING // @deprecated Use INFRA.TRADING } as const; // Type exports export type AuthRoutesType = typeof AUTH_ROUTES; export type UserRoutesType = typeof USER_ROUTES; export type AdminRoutesType = typeof ADMIN_ROUTES; export type InfraRoutesType = typeof INFRA_ROUTES; export type LegacyRoutesType = typeof LEGACY_ROUTES; export type RoutesType = typeof ROUTES;