Vasily.onl 010adb30f0 Implement modular architecture for Crypto Trading Bot Dashboard
- Introduced a new modular structure for the dashboard, enhancing maintainability and scalability.
- Created main application entry point in `app_new.py`, integrating all components and callbacks.
- Developed layout modules for market data, bot management, performance analytics, and system health in the `layouts` directory.
- Implemented callback modules for navigation, charts, indicators, and system health in the `callbacks` directory.
- Established reusable UI components in the `components` directory, including chart controls and indicator modals.
- Enhanced documentation to reflect the new modular structure and provide clear usage guidelines.
- Ensured all components are under 300-400 lines for better readability and maintainability.
2025-06-04 13:30:16 +08:00

73 lines
2.2 KiB
Python

"""
Main dashboard application module.
"""
import dash
from dash import html, dcc
from utils.logger import get_logger
from dashboard.layouts import (
get_market_data_layout,
get_bot_management_layout,
get_performance_layout,
get_system_health_layout
)
from dashboard.components import create_indicator_modal
logger = get_logger("dashboard_app")
def create_app():
"""Create and configure the Dash application."""
# Initialize Dash app
app = dash.Dash(__name__, suppress_callback_exceptions=True)
# Define the main layout
app.layout = html.Div([
# Page title
html.H1("🚀 Crypto Trading Bot Dashboard",
style={'text-align': 'center', 'color': '#2c3e50', 'margin-bottom': '30px'}),
# Navigation tabs
dcc.Tabs(id='main-tabs', value='market-data', children=[
dcc.Tab(label='📊 Market Data', value='market-data'),
dcc.Tab(label='🤖 Bot Management', value='bot-management'),
dcc.Tab(label='📈 Performance', value='performance'),
dcc.Tab(label='⚙️ System Health', value='system-health'),
], style={'margin-bottom': '20px'}),
# Tab content container
html.Div(id='tab-content'),
# Hidden button for callback compatibility (real button is in market data layout)
html.Button(id='add-indicator-btn', style={'display': 'none'}),
# Add Indicator Modal
create_indicator_modal(),
# Auto-refresh interval
dcc.Interval(
id='interval-component',
interval=30*1000, # Update every 30 seconds
n_intervals=0
)
])
return app
def register_callbacks(app):
"""Register all dashboard callbacks."""
from dashboard.callbacks import (
register_navigation_callbacks,
register_chart_callbacks,
register_indicator_callbacks,
register_system_health_callbacks
)
# Register all callback modules
register_navigation_callbacks(app)
register_chart_callbacks(app)
register_indicator_callbacks(app)
register_system_health_callbacks(app)
logger.info("All dashboard callbacks registered successfully")