File size: 7,746 Bytes
a9dc537 | 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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | # SPARKNET Remote Access Guide
## Problem Solved ✅
Your SPARKNET frontend and backend are running on a remote server, and you need to access them from your local browser.
## Solution Applied
I've configured both services to bind to all network interfaces (0.0.0.0) so they're accessible from your local machine.
---
## Your Server IP Address
```
172.24.50.21
```
---
## Quick Start (Easiest Method)
### Step 1: Start Services
On your **remote server**, run:
```bash
cd /home/mhamdan/SPARKNET
bash start_services.sh
```
This will start both backend and frontend in the background.
### Step 2: Access from Local Browser
On your **local computer**, open your browser and go to:
```
http://172.24.50.21:3000
```
That's it! 🎉
---
## URLs Reference
| Service | URL | Description |
|---------|-----|-------------|
| **Frontend** | http://172.24.50.21:3000 | Main SPARKNET UI |
| **Backend API** | http://172.24.50.21:8000 | API endpoints |
| **API Docs** | http://172.24.50.21:8000/api/docs | Interactive API documentation |
| **Health Check** | http://172.24.50.21:8000/api/health | Backend health status |
---
## Manual Start (Alternative)
If you prefer to start services manually:
### Terminal 1 - Backend
```bash
cd /home/mhamdan/SPARKNET
conda activate agentic-ai
python -m api.main
```
### Terminal 2 - Frontend
```bash
cd /home/mhamdan/SPARKNET/frontend
conda activate agentic-ai
npm run dev
```
---
## Managing Services
### View Logs
If using screen (automatic with start_services.sh):
```bash
# View backend logs
screen -r sparknet-backend
# View frontend logs
screen -r sparknet-frontend
# Detach from screen (keeps it running)
Press: Ctrl+A then D
```
### Stop Services
```bash
cd /home/mhamdan/SPARKNET
bash stop_services.sh
```
Or manually:
```bash
# Stop backend screen
screen -S sparknet-backend -X quit
# Stop frontend screen
screen -S sparknet-frontend -X quit
```
---
## Troubleshooting
### Issue 1: Cannot Access from Local Browser
**Check 1**: Are services running?
```bash
# Check if ports are open
ss -tlnp | grep -E ':(3000|8000)'
```
You should see:
```
tcp LISTEN 0.0.0.0:3000 (frontend)
tcp LISTEN 0.0.0.0:8000 (backend)
```
**Check 2**: Firewall blocking?
```bash
# Check firewall status
sudo ufw status
# If firewall is active, allow ports
sudo ufw allow 3000
sudo ufw allow 8000
```
**Check 3**: Can you ping the server?
```bash
# On your local machine
ping 172.24.50.21
```
**Check 4**: Try curl from local machine
```bash
# On your local machine, try:
curl http://172.24.50.21:8000/api/health
```
### Issue 2: Services Not Starting
**Check Node.js**:
```bash
source /home/mhamdan/miniconda3/etc/profile.d/conda.sh
conda activate agentic-ai
node --version # Should show v24.9.0
```
**Check Backend**:
```bash
cd /home/mhamdan/SPARKNET
python -m api.main
# Look for errors in output
```
**Check Frontend**:
```bash
cd /home/mhamdan/SPARKNET/frontend
npm run dev
# Look for errors in output
```
### Issue 3: CORS Errors
If you see CORS errors in browser console, verify:
1. Backend CORS settings include your IP:
```bash
grep -A 5 "allow_origins" /home/mhamdan/SPARKNET/api/main.py
```
Should include: `http://172.24.50.21:3000`
2. Frontend .env.local has correct API URL:
```bash
cat /home/mhamdan/SPARKNET/frontend/.env.local
```
Should show: `NEXT_PUBLIC_API_URL=http://172.24.50.21:8000`
---
## Network Configuration Summary
### What Was Changed
1. **Frontend (Next.js)**:
- Changed bind address from `localhost` to `0.0.0.0`
- Updated `.env.local` to use server IP instead of localhost
- Modified `package.json` scripts to use `-H 0.0.0.0`
2. **Backend (FastAPI)**:
- Already binding to `0.0.0.0` (no change needed)
- Added server IP to CORS allowed origins
- Ports: Backend on 8000, Frontend on 3000
---
## Alternative Access Methods
### Method 1: SSH Port Forwarding (If Direct Access Doesn't Work)
On your **local machine**, create an SSH tunnel:
```bash
ssh -L 3000:localhost:3000 -L 8000:localhost:8000 mhamdan@172.24.50.21
```
Then access via:
- Frontend: http://localhost:3000
- Backend: http://localhost:8000
Keep the SSH connection open while using the app.
### Method 2: ngrok (For External Access)
If you want to access from anywhere:
```bash
# Install ngrok
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null
echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list
sudo apt update && sudo apt install ngrok
# Start tunnels (in separate terminals)
ngrok http 3000 # Frontend
ngrok http 8000 # Backend
```
---
## Testing the Application
### 1. Test Backend API
```bash
# From your local machine
curl http://172.24.50.21:8000/api/health
```
Expected response:
```json
{
"status": "healthy",
"components": { ... },
"statistics": { ... }
}
```
### 2. Test Frontend
Open browser to: http://172.24.50.21:3000
You should see:
- Beautiful landing page with gradient SPARKNET logo
- "Transform Dormant Patents..." heading
- Features showcase
- "Start Patent Analysis" button
### 3. Test Full Workflow
1. Click "Start Patent Analysis" or go to http://172.24.50.21:3000/upload
2. Drag-and-drop a PDF from your Dataset/
3. Watch real-time progress at http://172.24.50.21:3000/workflow/{id}
4. View results at http://172.24.50.21:3000/results/{id}
---
## Performance Notes
### Expected Speed
- Frontend load: < 1 second
- API response: < 100ms
- WebSocket latency: < 50ms
- Patent analysis: 2-5 minutes
### Network Requirements
- Minimum bandwidth: 1 Mbps
- Recommended: 10+ Mbps for smooth experience
- Stable connection for WebSocket real-time updates
---
## Security Notes
### Current Setup (Development)
- ⚠️ No authentication
- ⚠️ HTTP (not HTTPS)
- ⚠️ No rate limiting
- ✅ CORS configured for specific origins
- ✅ File validation (PDF only, max 50MB)
- ✅ Input sanitization
### For Production
Consider adding:
- HTTPS/SSL certificates
- JWT authentication
- Rate limiting
- API keys
- Firewall rules limiting access
---
## Quick Commands Reference
```bash
# Start everything
cd /home/mhamdan/SPARKNET && bash start_services.sh
# Stop everything
cd /home/mhamdan/SPARKNET && bash stop_services.sh
# View backend logs
screen -r sparknet-backend
# View frontend logs
screen -r sparknet-frontend
# Check if running
ss -tlnp | grep -E ':(3000|8000)'
# Test backend
curl http://172.24.50.21:8000/api/health
# Test frontend
curl http://172.24.50.21:3000
```
---
## Success Checklist
- [ ] Services started with `bash start_services.sh`
- [ ] Can access http://172.24.50.21:8000/api/health from local browser
- [ ] Can access http://172.24.50.21:3000 from local browser
- [ ] Landing page loads correctly
- [ ] Can upload a patent PDF
- [ ] Real-time progress updates work
- [ ] Results display correctly
- [ ] Can download valorization brief
---
## Need Help?
### Check Logs
```bash
# Backend logs
screen -r sparknet-backend
# Frontend logs
screen -r sparknet-frontend
# System logs
journalctl -xe
```
### Common Issues
1. **Connection Refused**: Services not running or firewall blocking
2. **CORS Error**: Check CORS configuration in backend
3. **404 Error**: Wrong URL or service not started
4. **Slow Loading**: Network congestion or server resources
---
## Summary
**Your SPARKNET application is now accessible from your local browser!**
Simply open: **http://172.24.50.21:3000**
The frontend will automatically connect to the backend API at http://172.24.50.21:8000 for all operations including:
- Patent upload
- Workflow execution
- Real-time WebSocket updates
- Results retrieval
- PDF download
Enjoy your beautiful SPARKNET interface! 🚀
|