5-Layer System Architecture
Microservices architecture with clear separation: presentation layer (React), API gateway (Flask), message queue (RabbitMQ), ML workers (Python), and storage (PostgreSQL).
Frontend
React/Next.js with TypeScript. 4 user segment dashboards with forms, charts, and real-time updates.
API Gateway
Flask REST API with Pydantic schema validation, JWT auth, and RabbitMQ RPC client.
Message Queue
RabbitMQ decouples API from workers, enables horizontal scaling, and provides reliability.
ML Workers
Python workers with custom AI models (LSTM, CNN, Transformer), feature engineering, and signal generation.
Storage
PostgreSQL for metadata and audit trail, file system for model weights and historical CSV data.
Prediction Request Flow
End-to-end sequence from user form submission to prediction result display, showing all system components and their interactions.
JSON Input-Output Contract
Simple 3-box diagram showing the complete JSON transformation: User Configuration → Processing Pipeline → System Response. This is the API contract with exact field names matching your image.
{
'user_segment':
'short_term_trader',
'stocks': ['AAPL', 'MSFT'],
'data_frequency': '1min',
'prediction_horizon': '1h',
'confidence_level': 0.7,
'entry_window':
{'start':'10:00','end':'11:30'},
'exit_window': {'end':'14:00'},
'entry_price': 185.50,
'stop_loss': 182.00,
'capital_at_risk': 0.02,
'features':
['SMA','EMA','MACD','volatility'],
'sentiment_enabled': true,
'model_preferences': {
'architecture': 'LSTM',
'epochs': 20
}
}"] B["Processing Pipeline"] C["System JSON Response
{
'predicted_price': 187.25,
'confidence': 0.85,
'trade_signal': 'Enter',
'direction': 'Long',
'suggested_exit_time':
'14:00',
'position_size': 200,
'suggestion_text': 'Entering
LONG on AAPL
at $185.50 with stop-loss
$182.00.
Trade size: 200 shares.
Confidence: 0.85.',
'risk_metrics': {
'max_loss': '$700',
'risk_reward_ratio': 1.5
}
}"] A --> B B --> C style A fill:#e8f5e9,stroke:#4CAF50,stroke-width:2px style B fill:#f3e5f5,stroke:#9C27B0,stroke-width:2px style C fill:#e3f2fd,stroke:#2196F3,stroke-width:2px
User Configuration (13 fields)
User segment, stocks list, timing (data frequency, prediction horizon, entry/exit windows), risk parameters (confidence level, stop loss, capital at risk), features selection, sentiment analysis toggle, model preferences.
Processing Pipeline (6 steps)
Validate Schema → Load Market Data → Compute Technical Features (SMA, EMA, MACD, volatility) → Run AI Model → Generate Trade Signals → Calculate Risk Metrics.
System Response (8 fields)
Price prediction, confidence score, trade signal (Enter/Exit/Hold), direction (Long/Short), suggested exit time, position size, human-readable suggestion text, risk metrics (max loss, risk/reward ratio).
End-to-End Flow
Complete JSON-to-JSON transformation showing exactly what the frontend sends and what the backend returns. This is the API contract between UI and ML pipeline.
JSON Examples
User JSON Configuration
{
'user_segment':
'short_term_trader',
'stocks': ['AAPL', 'MSFT'],
'data_frequency': '1min',
'prediction_horizon': '1h',
'confidence_level': 0.7,
'entry_window':
{'start':'10:00','end':'11:30'},
'exit_window': {'end':'14:00'},
'entry_price': 185.50,
'stop_loss': 182.00,
'capital_at_risk': 0.02,
'features':
['SMA','EMA','MACD','volatility'],
'sentiment_enabled': true,
'model_preferences': {
'architecture': 'LSTM',
'epochs': 20
}
}
System JSON Response
{
'predicted_price': 187.25,
'confidence': 0.85,
'trade_signal': 'Enter',
'direction': 'Long',
'suggested_exit_time':
'14:00',
'position_size': 200,
'suggestion_text': 'Entering
LONG on AAPL
at $185.50 with stop-loss
$182.00.
Trade size: 200 shares.
Confidence: 0.85.',
'risk_metrics': {
'max_loss': '$700',
'risk_reward_ratio': 1.5
}
}
Full Application Workflow - Inference + Creation
Complete state machine showing two workflows: Inference (synchronous predictions using custom-trained AI models), and Creation (asynchronous agent training with external market data). Users need zero AI knowledge - the platform handles all ML complexity and supports multiple architectures (LSTM, CNN, Transformer).
Inference (Synchronous)
User selects their custom-trained agent, submits prediction request. System fetches live data via Refinitiv, computes features, runs custom-trained AI model (LSTM, CNN, or Transformer architecture), returns signal in seconds.
Creation (Asynchronous)
User configures agent (equity, data source, date range, features, risk params). Training job queued to RabbitMQ. Worker fetches historical data, trains AI model with selected architecture. Takes minutes to hours.
Training Lifecycle
Submit → Queue → Fetch Data → Validate → Initialize Model → Training Loop → Evaluate. If fails: set FAILED in DB, notify user. If succeeds: save weights, set READY, notify user.
User Needs Zero AI Knowledge
The form is finance-focused: pick stocks, date ranges, indicators. System handles all ML complexity (architecture, hyperparameters, training). User only sees results and performance metrics.
Data Sources
System fetches data from Refinitiv or Bloomberg APIs automatically. Historical data for training, live data for inference. User never uploads data manually.
Connection: Creation feeds Inference
Agents created in the Creation workflow become available in the Inference workflow. Both share the same database - Creation writes agent weights, Inference reads them.