Really-amin's picture
Upload 577 files
b190b45 verified
|
raw
history blame
17.9 kB
# Complete Site Map - Crypto Monitor ULTIMATE
## πŸ“‹ Table of Contents
1. [Frontend Pages & Routes](#frontend-pages--routes)
2. [Backend API Endpoints](#backend-api-endpoints)
3. [Static Assets](#static-assets)
4. [Backend Services](#backend-services)
5. [Database Files](#database-files)
6. [Configuration Files](#configuration-files)
7. [System Monitor Components](#system-monitor-components)
---
## 🌐 Frontend Pages & Routes
### Main Application Pages
| Route | File Path | Description | Access URL |
|-------|-----------|-------------|------------|
| `/` | `static/pages/dashboard/index.html` | Main Dashboard | `http://localhost:7860/` |
| `/dashboard` | `static/pages/dashboard/index.html` | Dashboard Page | `http://localhost:7860/dashboard` |
| `/market` | `static/pages/market/index.html` | Market Data Page | `http://localhost:7860/market` |
| `/models` | `static/pages/models/index.html` | AI Models Page | `http://localhost:7860/models` |
| `/sentiment` | `static/pages/sentiment/index.html` | Sentiment Analysis | `http://localhost:7860/sentiment` |
| `/ai-analyst` | `static/pages/ai-analyst/index.html` | AI Analyst Tool | `http://localhost:7860/ai-analyst` |
| `/technical-analysis` | `static/pages/technical-analysis/index.html` | Technical Analysis | `http://localhost:7860/technical-analysis` |
| `/trading-assistant` | `static/pages/trading-assistant/index.html` | Trading Assistant | `http://localhost:7860/trading-assistant` |
| `/news` | `static/pages/news/index.html` | Crypto News | `http://localhost:7860/news` |
| `/providers` | `static/pages/providers/index.html` | Data Providers | `http://localhost:7860/providers` |
| `/system-monitor` | `static/pages/system-monitor/index.html` | **System Monitor** | `http://localhost:7860/system-monitor` |
| `/help` | `static/pages/help/index.html` | Help & Documentation | `http://localhost:7860/help` |
| `/api-explorer` | `static/pages/api-explorer/index.html` | API Explorer | `http://localhost:7860/api-explorer` |
| `/crypto-api-hub` | `static/pages/crypto-api-hub/index.html` | Crypto API Hub | `http://localhost:7860/crypto-api-hub` |
| `/diagnostics` | `static/pages/diagnostics/index.html` | System Diagnostics | `http://localhost:7860/diagnostics` |
### Static File Structure
```
static/
β”œβ”€β”€ pages/
β”‚ β”œβ”€β”€ dashboard/
β”‚ β”‚ β”œβ”€β”€ index.html
β”‚ β”‚ β”œβ”€β”€ dashboard.js
β”‚ β”‚ └── dashboard.css
β”‚ β”œβ”€β”€ system-monitor/ ⭐ System Monitor
β”‚ β”‚ β”œβ”€β”€ index.html β†’ Main page HTML
β”‚ β”‚ β”œβ”€β”€ system-monitor.js β†’ JavaScript logic
β”‚ β”‚ β”œβ”€β”€ system-monitor.css β†’ Styling
β”‚ β”‚ └── README.md β†’ Documentation
β”‚ β”œβ”€β”€ market/
β”‚ β”œβ”€β”€ models/
β”‚ β”œβ”€β”€ sentiment/
β”‚ β”œβ”€β”€ ai-analyst/
β”‚ β”œβ”€β”€ technical-analysis/
β”‚ β”œβ”€β”€ trading-assistant/
β”‚ β”œβ”€β”€ news/
β”‚ β”œβ”€β”€ providers/
β”‚ β”œβ”€β”€ help/
β”‚ β”œβ”€β”€ api-explorer/
β”‚ └── crypto-api-hub/
β”œβ”€β”€ shared/
β”‚ β”œβ”€β”€ layouts/
β”‚ β”‚ β”œβ”€β”€ sidebar.html β†’ Main sidebar (includes System Monitor link)
β”‚ β”‚ └── sidebar-modern.html β†’ Modern sidebar variant
β”‚ β”œβ”€β”€ js/
β”‚ β”‚ β”œβ”€β”€ core/
β”‚ β”‚ β”‚ β”œβ”€β”€ layout-manager.js β†’ Loads sidebar/header
β”‚ β”‚ β”‚ β”œβ”€β”€ api-client.js β†’ API client
β”‚ β”‚ β”‚ └── models-client.js β†’ Models API client
β”‚ β”‚ └── sidebar-manager.js
β”‚ └── css/
β”‚ β”œβ”€β”€ design-system.css
β”‚ β”œβ”€β”€ global.css
β”‚ β”œβ”€β”€ components.css
β”‚ └── layout.css
└── assets/
└── icons/
└── crypto-icons.js β†’ Crypto SVG icons
```
---
## πŸ”Œ Backend API Endpoints
### System Monitor API Endpoints
| Endpoint | Method | File Location | Description |
|----------|--------|---------------|-------------|
| `/api/monitoring/status` | GET | `backend/routers/realtime_monitoring_api.py:40` | Get comprehensive system status |
| `/api/monitoring/ws` | WebSocket | `backend/routers/realtime_monitoring_api.py:188` | Real-time WebSocket updates |
| `/api/monitoring/sources/detailed` | GET | `backend/routers/realtime_monitoring_api.py:138` | Get detailed source information |
| `/api/monitoring/requests/recent` | GET | `backend/routers/realtime_monitoring_api.py:171` | Get recent API requests |
| `/api/monitoring/requests/log` | POST | `backend/routers/realtime_monitoring_api.py:181` | Log an API request |
### Core API Endpoints
| Endpoint | Method | File Location | Description |
|----------|--------|---------------|-------------|
| `/api/health` | GET | `hf_unified_server.py` | Health check |
| `/api/status` | GET | `hf_unified_server.py` | System status |
| `/api/models/summary` | GET | `hf_unified_server.py:1226` | Models summary with categories |
| `/api/models/status` | GET | `hf_unified_server.py:814` | Models status |
| `/api/models/list` | GET | `hf_unified_server.py:786` | List all models |
| `/api/resources` | GET | `hf_unified_server.py` | Resources statistics |
| `/api/resources/summary` | GET | `hf_unified_server.py` | Resources summary |
| `/api/resources/categories` | GET | `hf_unified_server.py` | Resources by category |
### Router Endpoints
All routers are included in `hf_unified_server.py`:
1. **Unified Service API** (`backend/routers/unified_service_api.py`)
- `/api/service/rate`
- `/api/service/rate/batch`
- `/api/service/pair/{pair}`
- `/api/service/sentiment`
- `/api/service/history`
- `/api/service/market-status`
2. **Real Data API** (`backend/routers/real_data_api.py`)
- `/api/models/list`
- `/api/models/initialize`
- `/api/sentiment/analyze`
- `/api/providers`
3. **Direct API** (`backend/routers/direct_api.py`)
- `/api/v1/coingecko/price`
- `/api/v1/binance/klines`
- `/api/v1/hf/sentiment`
- `/api/v1/hf/models`
4. **Crypto API Hub** (`backend/routers/crypto_api_hub_router.py`)
- `/api/crypto-hub/*`
5. **AI API** (`backend/routers/ai_api.py`)
- `/api/ai/*`
6. **Market API** (`backend/routers/market_api.py`)
- `/api/market/*`
7. **Technical Analysis API** (`backend/routers/technical_analysis_api.py`)
- `/api/technical/*`
8. **Real-Time Monitoring API** (`backend/routers/realtime_monitoring_api.py`) ⭐
- `/api/monitoring/*` - **System Monitor endpoints**
---
## 🎨 Static Assets
### CSS Files
| File | Path | Used By |
|------|------|---------|
| Design System | `static/shared/css/design-system.css` | All pages |
| Global Styles | `static/shared/css/global.css` | All pages |
| Components | `static/shared/css/components.css` | All pages |
| Layout | `static/shared/css/layout.css` | All pages |
| Dashboard | `static/pages/dashboard/dashboard.css` | Dashboard page |
| **System Monitor** | `static/pages/system-monitor/system-monitor.css` | **System Monitor page** |
### JavaScript Files
| File | Path | Purpose |
|------|------|---------|
| Layout Manager | `static/shared/js/core/layout-manager.js` | Loads sidebar/header |
| API Client | `static/shared/js/core/api-client.js` | API communication |
| Models Client | `static/shared/js/core/models-client.js` | Models API client |
| **System Monitor** | `static/pages/system-monitor/system-monitor.js` | **System Monitor logic** |
| Crypto Icons | `static/assets/icons/crypto-icons.js` | SVG icons library |
---
## βš™οΈ Backend Services
### Service Files
| Service | File Path | Used By |
|---------|-----------|---------|
| AI Models Monitor | `backend/services/ai_models_monitor.py` | System Monitor, Models API |
| Source Pool Manager | `monitoring/source_pool_manager.py` | System Monitor |
| Database Manager | `database/db_manager.py` | All services |
| Backtesting Service | `backend/services/backtesting_service.py` | Trading API |
| ML Training Service | `backend/services/ml_training_service.py` | AI API |
### Main Application File
| File | Path | Purpose |
|------|------|---------|
| FastAPI Server | `hf_unified_server.py` | Main application entry point |
| Server Runner | `main.py` | Start server with uvicorn |
| AI Models Registry | `ai_models.py` | Model management |
---
## πŸ’Ύ Database Files
| Database | Path | Purpose |
|----------|------|---------|
| AI Models DB | `data/ai_models.db` | AI models monitoring data |
| Main Database | SQLite via `database/db_manager.py` | Providers, sources, pools |
### Database Models
| Model | File Path | Description |
|-------|-----------|-------------|
| Provider | `database/models.py` | Data provider information |
| SourcePool | `database/models.py` | Source pool management |
| PoolMember | `database/models.py` | Pool member details |
---
## πŸ“ Configuration Files
| File | Path | Purpose |
|------|------|---------|
| Environment | `.env` | Environment variables |
| Config | `config.py` | Application configuration |
| Requirements | `requirements.txt` | Python dependencies |
| Package | `package.json` | Node.js dependencies (if any) |
---
## 🎯 System Monitor Components
### Frontend Components
#### HTML Structure
```
static/pages/system-monitor/index.html
β”œβ”€β”€ <head>
β”‚ β”œβ”€β”€ Meta tags
β”‚ β”œβ”€β”€ Theme CSS (design-system, global, components, layout)
β”‚ └── System Monitor CSS
β”œβ”€β”€ <body>
β”‚ β”œβ”€β”€ app-container
β”‚ β”‚ β”œβ”€β”€ sidebar-container (injected by LayoutManager)
β”‚ β”‚ └── main-content
β”‚ β”‚ β”œβ”€β”€ header-container (injected by LayoutManager)
β”‚ β”‚ └── page-content
β”‚ β”‚ β”œβ”€β”€ page-header (title, status badge, refresh button)
β”‚ β”‚ β”œβ”€β”€ stats-grid (4 stat cards)
β”‚ β”‚ β”‚ β”œβ”€β”€ Database Status Card
β”‚ β”‚ β”‚ β”œβ”€β”€ AI Models Card
β”‚ β”‚ β”‚ β”œβ”€β”€ Data Sources Card
β”‚ β”‚ β”‚ └── Active Requests Card
β”‚ β”‚ └── network-section
β”‚ β”‚ β”œβ”€β”€ section-header (title + legend)
β”‚ β”‚ └── network-canvas-container
β”‚ β”‚ └── #network-canvas
β”‚ β”œβ”€β”€ connection-status (fixed bottom-right)
β”‚ └── toast-container
└── <script>
└── LayoutManager.init('system-monitor')
└── SystemMonitor class initialization
```
#### JavaScript Class Structure
```
static/pages/system-monitor/system-monitor.js
└── SystemMonitor class
β”œβ”€β”€ constructor()
β”œβ”€β”€ init()
β”œβ”€β”€ setupCanvas()
β”œβ”€β”€ connectWebSocket() β†’ /api/monitoring/ws
β”œβ”€β”€ startPolling() β†’ /api/monitoring/status
β”œβ”€β”€ fetchSystemStatus()
β”œβ”€β”€ updateSystemStatus(data)
β”œβ”€β”€ updateHeader()
β”œβ”€β”€ updateDatabaseStatus()
β”œβ”€β”€ updateAIModels()
β”œβ”€β”€ updateDataSources()
β”œβ”€β”€ updateRequests()
β”œβ”€β”€ updateNetworkNodes()
β”œβ”€β”€ createPacket()
β”œβ”€β”€ startAnimation()
β”œβ”€β”€ draw() (canvas rendering)
└── destroy()
```
#### CSS Structure
```
static/pages/system-monitor/system-monitor.css
β”œβ”€β”€ Page Header Styles
β”œβ”€β”€ Stats Grid Layout
β”œβ”€β”€ Stat Cards
β”œβ”€β”€ Status Indicators
β”œβ”€β”€ Network Section
β”œβ”€β”€ Canvas Container
β”œβ”€β”€ Connection Status
└── Responsive Media Queries
```
### Backend Components
#### API Router
```
backend/routers/realtime_monitoring_api.py
β”œβ”€β”€ Router: APIRouter(prefix="/api/monitoring")
β”œβ”€β”€ Endpoints:
β”‚ β”œβ”€β”€ GET /status β†’ get_system_status()
β”‚ β”œβ”€β”€ GET /sources/detailed β†’ get_detailed_sources()
β”‚ β”œβ”€β”€ GET /requests/recent β†’ get_recent_requests()
β”‚ β”œβ”€β”€ POST /requests/log β†’ log_request()
β”‚ └── WebSocket /ws β†’ websocket_endpoint()
└── Dependencies:
β”œβ”€β”€ ai_models_db (AI models database)
β”œβ”€β”€ db_manager (Main database)
└── SourcePoolManager (Source pool management)
```
#### Data Flow
```
Frontend (system-monitor.js)
↓
β”œβ”€β†’ WebSocket: /api/monitoring/ws
β”‚ └─→ Real-time updates every 2 seconds
β”‚
└─→ HTTP Polling: /api/monitoring/status
└─→ Fallback if WebSocket fails
Backend (realtime_monitoring_api.py)
↓
β”œβ”€β†’ AI Models Monitor Service
β”‚ └─→ Get models status, health, metrics
β”‚
β”œβ”€β†’ Database Manager
β”‚ └─→ Get providers, sources, pools
β”‚
└─→ Request Log (in-memory)
└─→ Recent API requests tracking
```
---
## πŸ”„ Execution Flow
### Server Startup
1. **Entry Point**: `main.py`
```bash
python main.py
```
2. **Server File**: `hf_unified_server.py`
- Loads all routers
- Includes `realtime_monitoring_router`
- Sets up middleware
- Starts uvicorn server on port 7860
3. **Routes Registered**:
- All page routes (`/system-monitor`, `/dashboard`, etc.)
- All API routes (`/api/*`)
- WebSocket routes (`/api/monitoring/ws`)
### System Monitor Page Load
1. **User navigates to**: `http://localhost:7860/system-monitor`
2. **FastAPI serves**: `static/pages/system-monitor/index.html`
3. **HTML loads**:
- LayoutManager initializes
- Sidebar injected from `static/shared/layouts/sidebar.html`
- Header injected
- System Monitor CSS loaded
4. **JavaScript executes**:
- `SystemMonitor` class instantiated
- Canvas setup
- WebSocket connection to `/api/monitoring/ws`
- HTTP polling to `/api/monitoring/status` (every 2s)
5. **Data updates**:
- Backend gathers status from:
- AI Models Monitor DB
- Main Database (providers, sources)
- Request log
- Returns JSON to frontend
- Frontend updates UI and canvas animation
---
## πŸ“‚ Complete File Tree
```
crypto-dt-source-main/
β”œβ”€β”€ hf_unified_server.py β†’ Main FastAPI application
β”œβ”€β”€ main.py β†’ Server entry point
β”œβ”€β”€ ai_models.py β†’ AI models registry
β”œβ”€β”€ config.py β†’ Configuration
β”œβ”€β”€ requirements.txt β†’ Dependencies
β”‚
β”œβ”€β”€ static/
β”‚ β”œβ”€β”€ pages/
β”‚ β”‚ β”œβ”€β”€ system-monitor/ ⭐ System Monitor
β”‚ β”‚ β”‚ β”œβ”€β”€ index.html
β”‚ β”‚ β”‚ β”œβ”€β”€ system-monitor.js
β”‚ β”‚ β”‚ β”œβ”€β”€ system-monitor.css
β”‚ β”‚ β”‚ └── README.md
β”‚ β”‚ β”œβ”€β”€ dashboard/
β”‚ β”‚ β”œβ”€β”€ market/
β”‚ β”‚ β”œβ”€β”€ models/
β”‚ β”‚ └── ... (other pages)
β”‚ β”‚
β”‚ β”œβ”€β”€ shared/
β”‚ β”‚ β”œβ”€β”€ layouts/
β”‚ β”‚ β”‚ β”œβ”€β”€ sidebar.html β†’ Includes System Monitor link
β”‚ β”‚ β”‚ └── sidebar-modern.html
β”‚ β”‚ β”œβ”€β”€ js/
β”‚ β”‚ β”‚ β”œβ”€β”€ core/
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ layout-manager.js
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ api-client.js
β”‚ β”‚ β”‚ β”‚ └── models-client.js
β”‚ β”‚ β”‚ └── sidebar-manager.js
β”‚ β”‚ └── css/
β”‚ β”‚ β”œβ”€β”€ design-system.css
β”‚ β”‚ β”œβ”€β”€ global.css
β”‚ β”‚ β”œβ”€β”€ components.css
β”‚ β”‚ └── layout.css
β”‚ β”‚
β”‚ └── assets/
β”‚ └── icons/
β”‚ └── crypto-icons.js
β”‚
β”œβ”€β”€ backend/
β”‚ β”œβ”€β”€ routers/
β”‚ β”‚ β”œβ”€β”€ realtime_monitoring_api.py ⭐ System Monitor API
β”‚ β”‚ β”œβ”€β”€ unified_service_api.py
β”‚ β”‚ β”œβ”€β”€ real_data_api.py
β”‚ β”‚ β”œβ”€β”€ direct_api.py
β”‚ β”‚ β”œβ”€β”€ ai_api.py
β”‚ β”‚ β”œβ”€β”€ market_api.py
β”‚ β”‚ └── ... (other routers)
β”‚ β”‚
β”‚ └── services/
β”‚ β”œβ”€β”€ ai_models_monitor.py β†’ Used by System Monitor
β”‚ β”œβ”€β”€ backtesting_service.py
β”‚ └── ml_training_service.py
β”‚
β”œβ”€β”€ database/
β”‚ β”œβ”€β”€ db_manager.py β†’ Used by System Monitor
β”‚ └── models.py β†’ Provider, SourcePool, etc.
β”‚
β”œβ”€β”€ monitoring/
β”‚ └── source_pool_manager.py β†’ Used by System Monitor
β”‚
└── data/
└── ai_models.db β†’ AI models monitoring database
```
---
## πŸš€ Quick Reference
### Access System Monitor
- **URL**: `http://localhost:7860/system-monitor`
- **Route Handler**: `hf_unified_server.py:409` β†’ `system_monitor_page()`
- **HTML File**: `static/pages/system-monitor/index.html`
### API Endpoints
- **Status**: `GET http://localhost:7860/api/monitoring/status`
- **WebSocket**: `WS ws://localhost:7860/api/monitoring/ws`
- **Recent Requests**: `GET http://localhost:7860/api/monitoring/requests/recent`
### Key Files
- **Frontend**: `static/pages/system-monitor/index.html`
- **JavaScript**: `static/pages/system-monitor/system-monitor.js`
- **CSS**: `static/pages/system-monitor/system-monitor.css`
- **Backend API**: `backend/routers/realtime_monitoring_api.py`
- **Sidebar**: `static/shared/layouts/sidebar.html` (line ~157)
---
## πŸ“ Notes
- All paths are relative to project root: `crypto-dt-source-main/`
- Server runs on port **7860** by default (configurable via `PORT` env var)
- System Monitor uses both WebSocket and HTTP polling for reliability
- Sidebar is injected by `LayoutManager` on page load
- Theme is applied via CSS variables defined in `design-system.css`
---
**Last Updated**: 2025-12-08
**Version**: 2.0