File size: 4,423 Bytes
4718630
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# SPARKNET Deployment Architecture

## Quick Answer

**For Streamlit Cloud:** Push to **GitHub only** (`git push origin main`), then reboot the app.

**For Hugging Face Spaces:** Push to **Hugging Face only** (`git push hf main`).

They are **independent deployments** - you choose which platform to use.

---

## Architecture Overview

```
+------------------+          +-------------------+
|    Your Code     |          |   Lytos Server    |
|   (Local/Git)    |          |   172.24.50.21    |
+--------+---------+          +---------+---------+
         |                              |
         |                              | Backend API
    +----+----+                         | (port 8000)
    |         |                         |
    v         v                         v
+-------+  +--------+           +---------------+
|GitHub |  |Hugging |           | localtunnel   |
|       |  |Face    |           | (public URL)  |
+---+---+  +---+----+           +-------+-------+
    |          |                        |
    |          |                        |
    v          v                        |
+----------+  +-----------+             |
|Streamlit |  |HF Spaces  |<------------+
|Cloud     |  |           |   Backend calls
+----------+  +-----------+
```

---

## Platform Comparison

| Feature | Streamlit Cloud | Hugging Face Spaces |
|---------|-----------------|---------------------|
| **Source** | GitHub repo | HF repo (or GitHub) |
| **Push command** | `git push origin main` | `git push hf main` |
| **Auto-rebuild** | Yes (on push) | Yes (on push) |
| **Secrets** | Dashboard > Settings > Secrets | Settings > Variables |
| **Free tier** | Yes (limited resources) | Yes (limited resources) |
| **Custom domain** | Premium only | Premium only |
| **GPU support** | No | Yes (paid) |

---

## Your Current Setup

### Git Remotes
```bash
origin  -> github.com:MHHamdan/SPARKNET.git     # For Streamlit Cloud
hf      -> hf.co:spaces/mhamdan/SPARKNET.git   # For Hugging Face Spaces
```

### Deployment URLs
- **Streamlit Cloud:** `https://mhhamdan-sparknet.streamlit.app`
- **Hugging Face:** `https://huggingface.co/spaces/mhamdan/SPARKNET`

### Backend (Lytos GPU Server)
- **Internal:** `http://172.24.50.21:8000`
- **Public (via tunnel):** `https://selfish-crab-86.loca.lt`

---

## How to Deploy

### Option 1: Streamlit Cloud (Recommended)

```bash
# 1. Make changes locally
# 2. Commit
git add .
git commit -m "Your message"

# 3. Push to GitHub
git push origin main

# 4. Streamlit Cloud auto-rebuilds (or manually reboot in dashboard)
```

**Secrets location:** https://share.streamlit.io > Your App > Settings > Secrets

### Option 2: Hugging Face Spaces

```bash
# 1. Make changes locally
# 2. Commit
git add .
git commit -m "Your message"

# 3. Push to Hugging Face
git push hf main

# 4. HF Spaces auto-rebuilds
```

**Secrets location:** https://huggingface.co/spaces/mhamdan/SPARKNET/settings

---

## Keeping Both in Sync

If you want both platforms updated:

```bash
git push origin main && git push hf main
```

Or push to both at once:
```bash
git remote add all git@github.com:MHHamdan/SPARKNET.git
git remote set-url --add all git@hf.co:spaces/mhamdan/SPARKNET.git
git push all main
```

---

## Backend Connection Flow

```
User Browser
     |
     v
Streamlit Cloud (frontend)
     |
     | HTTP requests to BACKEND_URL
     v
localtunnel (https://selfish-crab-86.loca.lt)
     |
     | tunnels to
     v
Lytos Server (172.24.50.21:8000)
     |
     | processes with
     v
PaddleOCR + Ollama + GPU
```

---

## Required Secrets (Streamlit Cloud)

```toml
[auth]
password = "SPARKNET@2026"

BACKEND_URL = "https://selfish-crab-86.loca.lt"

GROQ_API_KEY = "your-key"
HF_TOKEN = "your-token"
GOOGLE_API_KEY = "your-key"
OPENROUTER_API_KEY = "your-key"
MISTRAL_API_KEY = "your-key"
```

---

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Changes not appearing | Reboot app in Streamlit dashboard |
| Backend connection failed | Check if localtunnel is running (`screen -r lt-tunnel`) |
| Tunnel URL changed | Update `BACKEND_URL` in Streamlit secrets |
| PaddleOCR warning | Normal on Streamlit Cloud - backend handles OCR |

---

## Screen Sessions on Lytos

```bash
screen -ls                    # List sessions
screen -r sparknet-backend    # Attach to backend
screen -r lt-tunnel           # Attach to tunnel
screen -r ollama              # Attach to Ollama
```