File size: 2,282 Bytes
93c19dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Quick Start - Deploy to Hugging Face in 5 Minutes

## Prerequisites

- Hugging Face account
- NVIDIA API key
- MySQL database URL

---

## Step 1: Create Hugging Face Space

```bash
# Go to https://huggingface.co/spaces
# Click "Create new Space"
# Select "Docker" as SDK
# Name it: domify-academy-bot
```

---

## Step 2: Get Your Repository URL

After creating the Space, you'll see:

```
https://huggingface.co/spaces/YOUR_USERNAME/domify-academy-bot
```

---

## Step 3: Push Code

```bash
cd /path/to/domify-academy-bot

# Initialize git (if not already done)
git init

# Add all files
git add .

# Commit
git commit -m "Initial commit"

# Add Hugging Face remote
git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/domify-academy-bot

# Push to Hugging Face
git push -u origin main
```

---

## Step 4: Set Environment Variables

In Hugging Face Space settings:

1. Go to **Settings****Repository secrets**
2. Add these variables:

| Key | Value |
|-----|-------|
| `DATABASE_URL` | `mysql://user:pass@host/db` |
| `NVIDIA_API_KEY` | Your NVIDIA API key |
| `JWT_SECRET` | `openssl rand -base64 32` |

---

## Step 5: Wait for Build

Hugging Face automatically:

1. Detects `Dockerfile`
2. Builds the image
3. Deploys the container
4. Assigns a public URL

**Check status in the "Build" tab**

---

## Step 6: Test

Once deployed:

```bash
# Test health endpoint
curl https://YOUR_SPACE_URL/api/health

# Should return:
# {"status":"healthy","uptime":123.45,...}
```

---

## Done! 🎉

Your backend is now live on Hugging Face Spaces!

---

## Troubleshooting

### Build fails

**Check logs:**
- Go to "Build" tab
- Look for error messages
- Common issues:
  - Missing environment variables
  - Database connection error
  - Invalid NVIDIA API key

### Application crashes

**Check logs:**
- Go to "Logs" tab
- Look for error messages
- Restart the Space if needed

### Slow responses

**Possible causes:**
- Database too slow
- NVIDIA API busy
- Rate limiting triggered

---

## Next Steps

1. Build the frontend
2. Deploy to same Space or separate URL
3. Configure custom domain
4. Set up monitoring and alerts

---

## Support

- Deployment issues: See `DEPLOYMENT.md`
- Backend details: See `BACKEND_README.md`
- Architecture: See `ARCHITECTURE.md`