Commit Graph

39 Commits

Author SHA1 Message Date
Adrian Flores Cortes
42d18759b5 feat: Implement BLOCKER-001 proactive refresh + E2E video tests (frontend)
BLOCKER-001: Token Refresh Improvements (FASE 4 frontend)
- Proactive refresh scheduler: refresh 5min before token expiry
- Multi-tab synchronization with BroadcastChannel API
- Automatic scheduling on X-Token-Expires-At header reception
- Background token refresh to prevent user interruption

E2E Tests: Video Upload Module (frontend - 62 tests)
- Suite 1: Form tests (27 tests) - 3-step wizard validation
- Suite 2: Service tests (20 tests) - Multipart upload logic
- Suite 3: Integration tests (15 tests) - Complete flow validation

Test infrastructure:
- vitest.config.ts (NEW) - Vitest configuration with jsdom
- src/__tests__/setup.ts (NEW) - Global test setup and mocks
- Updated payments-stripe-elements.test.tsx to use Vitest (vi.mock)

Changes:
- apiClient.ts: Proactive refresh scheduler + BroadcastChannel sync
- payments-stripe-elements.test.tsx: Migrated from Jest to Vitest

Tests created:
- video-upload-form.test.tsx (27 tests) - Component validation
- video-upload-service.test.ts (20 tests) - Service logic validation
- video-upload-integration.test.tsx (15 tests) - Integration flow

Additional documentation:
- Module README.md files for assistant, auth, education, investment, payments, portfolio, trading
- Investment module: Analysis, contracts, gaps, delivery documentation
- Payments module: Stripe integration, wallet specification

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 01:44:40 -06:00
Adrian Flores Cortes
3fb1ff4f5c test(payments): Add E2E tests for Stripe Elements integration (ST4.2.3)
Comprehensive frontend E2E tests validating PCI-DSS compliance with Stripe Elements.

New Files:
- src/__tests__/e2e/payments-stripe-elements.test.tsx (550+ lines)
  - 7 test suites, 20+ test cases
  - Stripe CardElement rendering (iframe, not native input)
  - Payment Intent confirmation flow
  - Checkout Session redirect (Stripe hosted)
  - Payment Method tokenization
  - Component state validation (no card data)
  - Error handling (Stripe validation errors)
  - Security best practices (HTTPS, no logging)

Test Coverage:
 Stripe CardElement renders as iframe (NOT native input)
 NO card data in React component state
 confirmCardPayment called with clientSecret
 NO card data sent to backend
 Checkout redirects to Stripe hosted page (stripe.com)
 Payment method tokenized before backend call
 NO sensitive data logged to console

PCI-DSS Frontend Validation:
- CardElement is iframe from stripe.com (not our domain)
- Card data sent directly to Stripe (bypasses our servers)
- Only tokens/IDs sent to backend
- No cardNumber, cvv, expiryDate in React state
- All API calls use HTTPS
- Stripe validation errors displayed (proves validation in Stripe iframe)

Mock Infrastructure:
- @stripe/stripe-js mocked
- @stripe/react-stripe-js mocked
- apiClient mocked
- window.location mocked (redirect tests)

Test Scenarios:
1. Wallet deposit (Payment Intent + confirmCardPayment)
2. Checkout session (redirect to Stripe hosted page)
3. Payment method attachment (createPaymentMethod + tokenization)
4. Error handling (card validation, network errors)
5. Security (HTTPS, console logging, state validation)

Key Validations:
- CardElement is iframe (NOT <input type="text" />)
- confirmCardPayment receives CardElement (Stripe iframe reference)
- Backend receives paymentMethodId (NOT raw card data)
- Checkout URL is checkout.stripe.com (NOT our domain)
- React state has NO cardNumber, cvv, expiryDate properties

Status: BLOCKER-002 (ST4.2) - Frontend tests complete
Task: #3 ST4.2.3 - Tests E2E flujos de pago PCI-DSS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 21:57:57 -06:00
Adrian Flores Cortes
ff404a84aa feat(education): Integrate real video upload API (ST4.3.5)
Replace simulated video upload with real multipart upload to backend.

New Files:
- src/services/video-upload.service.ts (NEW): Complete multipart upload service
  - Initialize upload with backend
  - Split file into 5MB parts
  - Upload parts to S3/R2 using presigned URLs
  - Upload max 3 parts in parallel
  - Complete upload and return video object
  - Full upload flow with progress callbacks

Updated Files:
- src/modules/education/components/VideoUploadForm.tsx (UPDATED):
  - Import videoUploadService
  - Replace simulated upload (lines 214-248) with real API calls
  - Use progress callbacks to update UI
  - Handle real video ID on completion
  - Maintain all existing UI/UX behavior

Upload Flow:
1. User selects video + fills metadata
2. Call videoUploadService.uploadVideo()
3. Backend initializes multipart upload
4. Split file into 5MB chunks
5. Upload chunks to S3/R2 (presigned URLs)
6. Backend completes upload
7. Video processing starts automatically
8. UI shows real-time progress

Technical Details:
- Part size: 5MB (optimal for network)
- Max concurrent uploads: 3 parts
- Uses fetch API for S3 direct upload
- ETags returned for multipart completion
- Full error handling and retry capability

Status: BLOCKER-003 (ST4.3) - 89% complete (5/6 tasks done)
Task: #10 ST4.3.5 - Frontend integrar VideoUploadForm con backend

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 20:41:18 -06:00
Adrian Flores Cortes
3f98938972 feat(payments): Remove insecure PaymentMethodForm component (ST4.2.1)
- Delete PaymentMethodForm.tsx (PCI-DSS violation)
- Remove export from components/payments/index.ts
- Component was NOT in use (legacy/demo code)

Violation: Component handled card data directly (PAN, CVV, expiry)
in state and sent raw data to backend.

Compliant alternatives:
- Stripe Customer Portal (add payment methods)
- CardElement + Payment Intents (one-time payments)

Blocker: BLOCKER-002 (ST4.2 PCI-DSS Compliance)
Epic: OQI-005

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 19:50:19 -06:00
Adrian Flores Cortes
b6654f27ae feat(auth): Implement auto-refresh token interceptor (ST4.1)
BLOCKER-001: Auto-Refresh Tokens - Core functionality

Implemented:
- Centralized API client with auto-refresh interceptor
- Request queueing (prevents multiple simultaneous refreshes)
- Retry logic (max 1 retry per request)
- Token management (getAccessToken, getRefreshToken, setTokens, clearTokens)
- Auth service migrated to use apiClient

Files:
- src/lib/apiClient.ts (new, 237 lines)
- src/services/auth.service.ts (updated to use apiClient)

Part of ST4.1: Auto-Refresh Tokens.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 19:16:58 -06:00
Adrian Flores Cortes
e204853398 fix(coherence): Add all trading enums aligned with DDL (E-COH-002, ST1.4)
- Extended src/types/trading.types.ts with all DDL trading enums
- Added OrderType, OrderSide, OrderStatus enums
- Added PositionStatus enum (open, closed, liquidated)
- Added SignalType enum (entry_long, entry_short, exit_long, exit_short, hold)
- Added ConfidenceLevel enum (low, medium, high, very_high)
- Added Timeframe enum (1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w, 1M)
- Added BotType enum (paper, live, backtest)
- Added BotStatus enum (active, paused, stopped, error)
- Deprecated old Interval type in favor of Timeframe

All types now aligned with trading.* enums from DDL schema and backend types.
Replaces hardcoded string literals with proper enum definitions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 17:07:28 -06:00
Adrian Flores Cortes
c18459558f fix(coherence): Create centralized portfolio types (E-COH-004, ST1.3)
- Created src/types/portfolio.types.ts
- Added all portfolio type definitions aligned with DDL
- Includes WebSocket event types for real-time updates
- Types match backend portfolio.types.ts structure

Part of coherence gap fix E-COH-004 - Frontend portfolio types.
Types align with DDL schema (portfolio.* enums and tables).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 17:02:41 -06:00
Adrian Flores Cortes
f7a5ddcca8 [OQI-006] feat: Add 3 ML utility panel components
- ModelSelector: Model selection with dropdown/tabs/cards variants
- EnsemblePanel: Ensemble voting configuration with weight sliders
- ICTAnalysisPanel: ICT analysis parameters with collapsible sections

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 11:03:20 -06:00
Adrian Flores Cortes
8347c6ad48 [OQI-005] feat: Add 4 advanced payment components
- StripeElementsWrapper: PCI-DSS compliance foundation with HOC and hook
- InvoicePreview: Pre-checkout invoice display with itemized breakdown
- RefundRequestModal: Modal for refund requests with validation
- RefundList: Paginated refund history with status filters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 09:52:05 -06:00
Adrian Flores Cortes
339c645036 [OQI-004] feat: Add 4 advanced investment components
- CreateAccountWizard: Multi-step wizard for account creation (620 LOC)
- RiskAnalysisPanel: Risk metrics with VaR, Sharpe, Sortino (480 LOC)
- PortfolioOptimizerWidget: Portfolio allocation optimizer (520 LOC)
- AccountTransferModal: Modal for inter-account transfers (450 LOC)

Updates OQI-004 progress from 35% to 55%

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 23:20:40 -06:00
Adrian Flores Cortes
fc99c34749 [OQI-002] feat: Add 4 advanced education components
- VideoUploadForm: Multi-step video upload with drag-drop (450 LOC)
- CreatorDashboard: Creator stats, courses, activity feed (450 LOC)
- CertificateGenerator: Templates, PDF/PNG download, sharing (453 LOC)
- LiveStreamPlayer: Live streaming with chat, reactions (480 LOC)

Updates OQI-002 progress from 30% to 40%

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 14:44:05 -06:00
Adrian Flores Cortes
c145878c24 [OQI-003] feat: Add advanced market depth and screener components
- OrderBookDepthVisualization: Canvas-based depth chart with bid/ask areas
- MarketDepthPanel: Complete market depth with filters and grouping
- SymbolComparisonChart: Multi-symbol comparison with normalization modes
- TradingScreener: Advanced screener with filters and saved presets

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 14:24:52 -06:00
Adrian Flores Cortes
5ee7f14f25 [OQI-007] feat: Add LLM strategy agent advanced components
- AnalysisRequestForm: Structured request builder for complex analysis tasks
- StrategyTemplateSelector: Pre-built strategy templates with AI recommendations
- LLMConfigPanel: Model selection and inference parameters (Claude models)
- ContextMemoryDisplay: Conversation context and memory visualization

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 12:31:08 -06:00
Adrian Flores Cortes
7d9e8d2da9 [OQI-004] feat: Add investment account management components
- AccountSummaryCard: Reusable account stats with balance, gains, and status
- ProductComparisonTable: Side-by-side product comparison (Atlas/Orion/Nova)
- PerformanceWidgetChart: Compact sparkline chart for embedding in cards
- AccountSettingsPanel: Account configuration (distribution, reinvest, alerts)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 12:24:01 -06:00
Adrian Flores Cortes
e9aa29fccd [OQI-006] feat: Add ML confidence and performance tracking components
- ConfidenceMeter: Advanced confidence visualization with model agreement
- SignalPerformanceTracker: Signal history with filters and statistics
- ModelAccuracyDashboard: Individual model metrics and comparison
- BacktestResultsVisualization: Backtest results with trades and monthly returns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 12:17:16 -06:00
Adrian Flores Cortes
cbb6637966 [OQI-002] feat: Add education progress and assessment components
- CourseProgressTracker: Comprehensive progress visualization
- LearningPathVisualizer: Visual roadmap for learning paths
- VideoProgressPlayer: Enhanced video player with bookmarks and controls
- AssessmentSummaryCard: Quiz results analysis and review

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 12:07:12 -06:00
Adrian Flores Cortes
7ac32466be [OQI-003] feat: Add chart analysis and trading journal components
- IndicatorConfigPanel: Advanced technical indicator configuration
- ChartDrawingToolsPanel: Drawing tools for technical analysis
- SymbolInfoPanel: Comprehensive symbol information sidebar
- TradeJournalPanel: Trade review and journaling for paper trading

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 11:59:12 -06:00
Adrian Flores Cortes
51c0a846c0 [OQI-009] feat: Add MT4 trading dashboard and risk management components
- MT4LiveTradesPanel: Real-time positions dashboard with aggregate metrics
- PositionModifierDialog: Modal for modifying SL/TP with price/pips modes
- RiskBasedPositionSizer: Position size calculator based on risk percentage
- TradeAlertsNotificationCenter: Unified notification hub for MT4 events

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 11:50:11 -06:00
Adrian Flores Cortes
c7626f841c [OQI-005] feat: Add invoice and subscription management components
- InvoiceList: Paginated invoice table with filters
- InvoiceDetail: Full invoice modal with line items
- PaymentMethodsList: Manage saved payment methods
- SubscriptionUpgradeFlow: Plan upgrade/downgrade with preview

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 11:39:33 -06:00
Adrian Flores Cortes
c956ac0c0f [OQI-007] feat: Add assistant UI components for chat enhancement
- MessageList: Virtualized message list with auto-scroll
- ChatHeader: Header with title editing, actions menu, status
- MessageSearch: Search within conversation with filters
- MarkdownRenderer: Custom markdown rendering with code copy

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 11:32:32 -06:00
Adrian Flores Cortes
4d2c00ac30 [OQI-009] feat: Add MT4 trading components and WebSocket hook
- QuickOrderPanel: One-click trading with lot presets
- TradeExecutionHistory: Session trade history with P&L stats
- TradingMetricsCard: Daily trading metrics and performance
- useMT4WebSocket: Real-time account/position updates hook

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 11:23:33 -06:00
Adrian Flores Cortes
d2c0a09b1b [OQI-005] feat: Add payment form components
- CouponForm: Apply and validate discount codes
- PaymentMethodForm: Add payment methods with card validation
- TransactionHistory: Wallet transactions with filtering/pagination
- BillingInfoForm: Edit billing address and tax information

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 11:15:12 -06:00
Adrian Flores Cortes
ed2e1472f4 [OQI-007] feat: Add hooks, utils, and SignalExecutionPanel
- useChatAssistant: Centralized chat logic with retry and streaming support
- useStreamingChat: SSE streaming with token animation
- messageFormatters: Signal parsing, price formatting, markdown processing
- SignalExecutionPanel: Execute trading signals with risk validation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 11:05:55 -06:00
Adrian Flores Cortes
bf726a595c [OQI-009] feat: Add advanced MT4 trading components
- MT4PositionsManager: Container for all live positions with filtering/sorting
- AdvancedOrderEntry: Professional order form with risk calculator, SL/TP modes
- AccountHealthDashboard: Unified account metrics with health status

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:56:41 -06:00
Adrian Flores Cortes
bfaf76ccf8 [OQI-007] feat: Add LLM assistant UX components
- ToolCallCard: Display tool execution results with expandable details
- MessageFeedback: Thumbs up/down with detailed feedback form
- StreamingIndicator: Multiple variants for thinking/analyzing/generating states
- AssistantSettingsPanel: Settings modal with risk profile, preferences

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:48:47 -06:00
Adrian Flores Cortes
423be4062c [OQI-009] feat: Add MT4 live trading components
- MT4ConnectionStatus: Connection indicator with account info display
- LivePositionCard: Real-time position card with P&L, modify/close actions
- RiskMonitor: Risk management dashboard with metrics and warnings
- index.ts: Centralized exports for all trading components

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:41:01 -06:00
Adrian Flores Cortes
fc0ab528c3 [OQI-002] feat: Add education UX components
- CertificatePreview: Display earned certificates with download/share
- CourseReviews: Reviews section with rating summary and filtering
- LessonNotes: Note-taking with timestamps and auto-save
- RecommendedCourses: Course recommendations with multiple layouts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:27:25 -06:00
Adrian Flores Cortes
442051f93b [OQI-007] feat: Add ConversationHistory and ContextPanel components
- ConversationHistory: Session list with search, delete, and selection
- ContextPanel: Display trading context (watchlist, risk profile, favorites)
- Update Assistant page to use chatStore for session management
- Wire sidebar to load/create/delete sessions
- Add error banner and responsive design

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:17:52 -06:00
Adrian Flores Cortes
ee307ee91a [OQI-005] feat: Add wallet modals and checkout pages
- Add WalletDepositModal for depositing funds to wallet
- Add WalletWithdrawModal for withdrawing funds from wallet
- Add CheckoutSuccess page for successful Stripe checkout
- Add CheckoutCancel page for canceled checkout
- Update Billing page to use new wallet modals
- Add routes for /payments/success and /payments/cancel
- Export new modals from payments index

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:07:14 -06:00
Adrian Flores Cortes
d87c2b8e54 [OQI-003] feat: Add Settings tab to PaperTradingPanel
- Add Settings tab with account info and reset functionality
- Show initial balance, total trades, open positions
- Reset account confirmation dialog
- Danger zone styling for reset action

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:53:41 -06:00
Adrian Flores Cortes
b798e2678c [OQI-003] feat: Add TradingStatsPanel and OrderBookPanel components
- Create TradingStatsPanel with trading metrics (win rate, P&L, profit factor)
- Create OrderBookPanel with bids/asks visualization and spread
- Update Trading.tsx with toggle buttons for all panels
- Implement indicator toggle logic with Set state
- Add stats panel: current streak, avg hold time, portfolio summary
- Add order book: depth bars, click-to-fill, configurable rows

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:51:07 -06:00
Adrian Flores Cortes
49d6492c91 [OQI-003] feat: Add AlertsPanel component for price alerts management
- Create AlertsPanel component with full CRUD functionality
- Add alerts API functions to trading.service.ts
- Integrate AlertsPanel into Trading.tsx with toggle button
- Support for above/below/crosses conditions
- Push and email notification options
- Recurring alerts support
- Filter by active/inactive status

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:41:05 -06:00
Adrian Flores Cortes
639c70587a [OQI-004] feat: Complete investment module with all pages
- Add Withdrawals.tsx with global withdrawals list and status filters
- Add Transactions.tsx with global transaction history and type/account filters
- Add Reports.tsx with allocation chart, performance bars, and export
- Add ProductDetail.tsx with performance chart and investment form
- Add routes for all new pages in App.tsx

OQI-004 progress: 45% -> 75%

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:24:15 -06:00
Adrian Flores Cortes
e158d4228e [OQI-004] feat: Add AccountDetail page and investment service
- Create AccountDetail.tsx with tabs for overview, transactions, distributions, deposit, withdraw
- Create investment.service.ts with full API client for investment endpoints
- Add routes /investment/portfolio, /investment/products, /investment/accounts/:accountId
- Integrate DepositForm and WithdrawForm components
- Add canvas-based performance chart

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:16:24 -06:00
Adrian Flores Cortes
fd54724ede [OQI-008] feat: Add portfolio store with WebSocket real-time updates
- Create portfolioStore.ts with Zustand for state management
- Add portfolioWS instance for real-time portfolio updates
- Add usePortfolioUpdates hook for WebSocket subscriptions
- Refactor PortfolioDashboard to use store instead of local state
- Add WebSocket connection status indicator (Live/Offline)
- Add last update timestamp display

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:47:46 -06:00
Adrian Flores Cortes
c02625f37b [OQI-008] feat: Add portfolio Phase 3 - Performance chart and edit allocations
- Add PerformanceChart component with canvas-based line chart
- Add EditAllocations page for modifying target allocations
- Integrate PerformanceChart into PortfolioDashboard
- Add route for /portfolio/:portfolioId/edit
- Extend portfolio.service with performance API functions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:40:47 -06:00
Adrian Flores Cortes
b8a7cbe691 [OQI-008] feat: Add Portfolio Manager frontend module
- Created portfolio.service.ts with API client functions
- Created AllocationChart component (donut chart)
- Created AllocationTable component (detailed positions)
- Created RebalanceCard component (rebalancing recommendations)
- Created GoalCard component (financial goal progress)
- Created PortfolioDashboard page (main dashboard)
- Created CreatePortfolio page (new portfolio form)
- Created CreateGoal page (new goal form)
- Updated App.tsx with portfolio routes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:31:26 -06:00
Adrian Flores Cortes
b7de2a3d58 feat: Add NotificationCenter UI components
- Add notification service for API calls
- Add notification Zustand store with WebSocket integration
- Create NotificationBell component with badge
- Create NotificationDropdown with recent notifications
- Create NotificationItem with icons and actions
- Update MainLayout to use NotificationBell

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 03:57:45 -06:00
5b53c2539a feat: Initial commit - Trading Platform Frontend
React frontend with:
- Authentication UI
- Trading dashboard
- ML signals display
- Portfolio management

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 04:30:39 -06:00