Spaces:
Sleeping
Sleeping
File size: 5,086 Bytes
2abc620 | 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | # vBot Central Server Setup Guide
## Overview
This guide provides detailed instructions for setting up the central vBot server that handles call transcription and analysis. The central server is deployed on Hugging Face Space and manages customer accounts, API keys, and webhook delivery.
## Prerequisites
- Hugging Face account
- MySQL database (version 5.7 or higher)
- Python 3.8 or higher
- Git
## Step 1: Deploy to Hugging Face Space
1. Create a new Space:
- Go to https://huggingface.co/spaces
- Click "New Space"
- Choose "Gradio" as the SDK
- Set the Space name (e.g., "vBot")
- Set visibility (public/private)
2. Clone the repository:
```bash
git clone https://huggingface.co/spaces/iajitpanday/vBot
cd vBot
```
3. Configure environment variables:
```bash
cp .env.example .env
# Edit .env with your configuration
```
4. Required environment variables:
```bash
DATABASE_URL=mysql://user:password@host:port/database
SECRET_KEY=your-secret-key
API_BASE_URL=https://your-space.huggingface.space
```
5. Push to Hugging Face:
```bash
git add .
git commit -m "Initial deployment"
git push
```
## Step 2: Database Setup
1. Create the database:
```sql
CREATE DATABASE vbot_central;
USE vbot_central;
```
2. Create required tables:
```sql
CREATE TABLE customers (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
company_name VARCHAR(255),
email VARCHAR(255) NOT NULL,
api_key VARCHAR(64) NOT NULL UNIQUE,
webhook_url VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
```
## Step 3: Admin Setup
1. Access the admin interface:
- URL: `https://your-space.huggingface.space/admin`
- Default credentials: admin/admin
2. Change admin password:
- Click "Change Password"
- Enter new secure password
- Save changes
3. Create first customer:
- Click "Add Customer"
- Fill in customer details
- System will generate API key
- Save customer information
## Step 4: API Configuration
1. Verify API endpoints:
```bash
curl https://your-space.huggingface.space/health
```
2. Test customer API:
```bash
curl -X POST https://your-space.huggingface.space/api/process-call \
-H "X-API-Key: customer-api-key" \
-H "Content-Type: multipart/form-data" \
-F "file=@test.wav" \
-H "caller_number=+1234567890" \
-H "called_number=+0987654321"
```
## Step 5: Security Setup
1. Configure SSL:
- Hugging Face Spaces provides SSL by default
- Verify SSL certificate is valid
2. API Security:
- All API endpoints require valid API key
- Implement rate limiting
- Validate input data
- Sanitize output data
3. Webhook Security:
- Require HTTPS for webhook URLs
- Validate webhook signatures
- Implement retry mechanism
- Log webhook delivery attempts
## Step 6: Monitoring Setup
1. Log Configuration:
```bash
# Application logs
tail -f logs/app.log
# Error logs
tail -f logs/error.log
# Access logs
tail -f logs/access.log
```
2. Health Monitoring:
- Set up health check endpoint
- Monitor API response times
- Track webhook delivery success
- Monitor database performance
## Step 7: Maintenance
1. Regular Tasks:
- Monitor system logs
- Check API performance
- Verify webhook delivery
- Review security logs
2. Backup Strategy:
- Regular database backups
- Configuration backups
- Log rotation
- API key rotation
3. Update Process:
```bash
# Update code
git pull
# Update dependencies
pip install -r requirements.txt
# Restart application
```
## Troubleshooting
1. Common Issues:
- API authentication failures
- Webhook delivery failures
- Database connection issues
- Performance problems
2. Debug Tools:
```bash
# Check application logs
tail -f logs/app.log
# Check error logs
tail -f logs/error.log
# Check database connection
mysql -u user -p vbot_central
```
3. Support:
- Check documentation
- Review logs
- Contact support
- Submit issues
## Security Best Practices
1. API Security:
- Use strong API keys
- Implement rate limiting
- Validate all inputs
- Sanitize all outputs
2. Database Security:
- Use strong passwords
- Limit database access
- Regular backups
- Encryption at rest
3. Webhook Security:
- Require HTTPS
- Validate signatures
- Implement retries
- Monitor delivery
## Performance Optimization
1. API Optimization:
- Implement caching
- Optimize database queries
- Use connection pooling
- Monitor response times
2. Webhook Optimization:
- Implement queue system
- Use async processing
- Monitor delivery times
- Handle failures gracefully
3. Database Optimization:
- Index frequently queried columns
- Optimize table structure
- Regular maintenance
- Monitor performance |