File size: 4,453 Bytes
eebf5c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Crypto Monitor Extended API - Hugging Face Spaces Deployment

This repository is configured to run as a **Docker Space** on Hugging Face.

## πŸš€ Quick Deploy to Hugging Face Spaces

1. **Create a new Space** on Hugging Face
2. **Select Docker as the SDK**
3. **Clone this repository** or push it to your Space
4. The Space will automatically build and deploy

## πŸ“‹ Configuration

### Space Settings

- **SDK**: Docker
- **Hardware**: CPU Basic (or higher for better performance)
- **Visibility**: Public or Private (your choice)

### Environment Variables (Optional)

You can set these in your Space settings under "Repository secrets":

- `PORT` - Port number (default: 7860 for HF Spaces)
- `ENABLE_AUTO_DISCOVERY` - Enable auto-discovery service (default: false)

## πŸ”§ Technical Details

### Main Application

The FastAPI application is defined in `api_server_extended.py` and exposes:

- **Main API**: `http://your-space.hf.space/`
- **API Docs**: `http://your-space.hf.space/docs`
- **Health Check**: `http://your-space.hf.space/health`
- **WebSocket**: `ws://your-space.hf.space/ws`

### Features

βœ… **Provider Management** - Manage 200+ crypto data providers
βœ… **Pool Management** - Create and manage provider pools with rotation strategies
βœ… **Real-time WebSocket** - Live updates and monitoring
βœ… **Health Monitoring** - Automatic health checks for all providers
βœ… **Auto-Discovery** - Discover new crypto data sources automatically
βœ… **Diagnostics** - Built-in diagnostics and auto-repair
βœ… **Logging** - Comprehensive logging system
βœ… **Resource Management** - Import/export provider configurations

### API Endpoints

#### Core Endpoints
- `GET /` - Main dashboard
- `GET /health` - Health check
- `GET /api/status` - System status
- `GET /api/stats` - Statistics

#### Provider Management
- `GET /api/providers` - List all providers
- `GET /api/providers/{id}` - Get provider details
- `POST /api/providers/{id}/health-check` - Check provider health
- `GET /api/providers/category/{category}` - Get providers by category

#### Pool Management
- `GET /api/pools` - List all pools
- `POST /api/pools` - Create new pool
- `POST /api/pools/{id}/members` - Add member to pool
- `POST /api/pools/{id}/rotate` - Rotate pool

#### WebSocket
- `WS /ws` - WebSocket connection for real-time updates

See `/docs` for complete API documentation.

## πŸ—οΈ Local Development

### Using Docker

```bash

# Build the image

docker build -t crypto-monitor .



# Run the container

docker run -p 8000:8000 crypto-monitor

```

### Using Python directly

```bash

# Install dependencies

pip install -r requirements.txt



# Run the server

python main.py

```

Or with uvicorn directly:

```bash

uvicorn api_server_extended:app --host 0.0.0.0 --port 8000 --reload

```

## πŸ“Š Monitoring

Once deployed, you can monitor your Space:

1. Check the **Logs** tab in your Space
2. Visit `/health` endpoint for health status
3. Visit `/api/status` for detailed system status
4. Use `/docs` for interactive API documentation

## πŸ” Troubleshooting

### Space not starting?

1. Check the **Logs** tab for error messages
2. Verify all required files are present
3. Ensure `api_server_extended.py` defines `app = FastAPI(...)`
4. Check that all dependencies in `requirements.txt` are valid

### Health check failing?

The health check runs after 40 seconds of startup. If it fails:

1. Increase `start-period` in Dockerfile HEALTHCHECK
2. Check if the app is listening on the correct PORT
3. Verify `/health` endpoint returns 200 OK

### Performance issues?

1. Upgrade to better hardware (CPU or GPU)
2. Disable auto-discovery: Set `ENABLE_AUTO_DISCOVERY=false`
3. Reduce the number of providers being monitored

## πŸ“ Notes

- The application uses **no API keys** by default - all data sources are free
- SQLite database is used for persistence (stored in `/app/data/`)
- Logs are stored in `/app/logs/`
- The app runs in **degraded mode** if some providers are unavailable
- WebSocket connections are supported for real-time updates

## 🀝 Support

For issues or questions:
- Check the `/api/diagnostics/run` endpoint for automatic diagnostics
- Review logs in the Hugging Face Space logs tab
- Check the `/health` endpoint for system status

## πŸ“„ License

See LICENSE file for details.