File size: 7,252 Bytes
ebcc4b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: LeRobot Arena Frontend
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: static
app_build_command: bun install && bun run build
app_file: build/index.html
pinned: false
license: mit
short_description: A web-based robotics control and simulation platform
tags:
  - robotics
  - control
  - simulation
  - svelte
  - static
  - frontend
---

# πŸ€– LeRobot Arena

A web-based robotics control and simulation platform that bridges digital twins and physical robots. Built with Svelte for the frontend and FastAPI for the backend.

## πŸš€ Simple Deployment Options

Here are the easiest ways to deploy this Svelte frontend:

### πŸ† Option 1: Hugging Face Spaces (Static) - RECOMMENDED ✨

**Automatic deployment** (easiest):
1. **Fork this repository** to your GitHub account
2. **Create a new Space** on [Hugging Face Spaces](https://huggingface.co/spaces)
3. **Connect your GitHub repo** - it will auto-detect the static SDK
4. **Push to main branch** - auto-builds and deploys!

The frontmatter is already configured with:
```yaml
sdk: static
app_build_command: bun install && bun run build
app_file: build/index.html
```

**Manual upload**:
1. Run `bun install && bun run build` locally
2. Create a Space with "Static HTML" SDK
3. Upload all files from `build/` folder

### πŸš€ Option 2: Vercel - One-Click Deploy

[![Deploy to Vercel](https://vercel.com/button)](https://vercel.com/new)

Settings: Build command `bun run build`, Output directory `build`

### πŸ“ Option 3: Netlify - Drag & Drop

1. Build locally: `bun install && bun run build`
2. Drag `build/` folder to [Netlify](https://netlify.com)

### πŸ†“ Option 4: GitHub Pages

Add this workflow file (`.github/workflows/deploy.yml`):
```yaml
name: Deploy to GitHub Pages
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v1
      - run: bun install --frozen-lockfile
      - run: bun run build
      - uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./build
```

### 🐳 Option 5: Docker (Optional)

For local development or custom hosting:
```bash
docker build -t lerobot-arena-frontend .
docker run -p 7860:7860 lerobot-arena-frontend
```

The Docker setup uses Bun's simple static server - much simpler than the complex server.js approach!

## πŸ› οΈ Development Setup

For local development with hot-reload capabilities:

### Frontend Development

```bash
# Install dependencies
bun install

# Start the development server
bun run dev

# Or open in browser automatically
bun run dev -- --open
```

### Backend Development

```bash
# Navigate to Python backend
cd src-python

# Install Python dependencies (using uv)
uv sync

# Or using pip
pip install -e .

# Start the backend server
python start_server.py
```

### Building Standalone Executable

The backend can be packaged as a standalone executable using box-packager:

```bash
# Navigate to Python backend
cd src-python

# Install box-packager (if not already installed)
uv pip install box-packager

# Package the application
box package

# The executable will be in target/release/lerobot-arena-server
./target/release/lerobot-arena-server
```

Note: Requires [Rust/Cargo](https://rustup.rs/) to be installed for box-packager to work.

## πŸ“‹ Project Structure

```
lerobot-arena/
β”œβ”€β”€ src/                    # Svelte frontend source
β”‚   β”œβ”€β”€ lib/               # Reusable components and utilities
β”‚   β”œβ”€β”€ routes/            # SvelteKit routes
β”‚   └── app.html           # App template
β”œβ”€β”€ src-python/            # Python backend
β”‚   β”œβ”€β”€ src/               # Python source code
β”‚   β”œβ”€β”€ start_server.py    # Server entry point
β”‚   β”œβ”€β”€ target/            # Box-packager build output (excluded from git)
β”‚   └── pyproject.toml     # Python dependencies
β”œβ”€β”€ static/                # Static assets
β”œβ”€β”€ Dockerfile             # Docker configuration
β”œβ”€β”€ docker-compose.yml     # Docker Compose setup
└── package.json           # Node.js dependencies
```

## 🐳 Docker Information

The Docker setup includes:

- **Multi-stage build**: Optimized for production using Bun and uv
- **Automatic startup**: Both services start together
- **Port mapping**: Backend on 8080, Frontend on 7860 (HF Spaces compatible)
- **Static file serving**: Compiled Svelte app served efficiently
- **User permissions**: Properly configured for Hugging Face Spaces
- **Standalone executable**: Backend packaged with box-packager for faster startup

For detailed Docker documentation, see [DOCKER_README.md](./DOCKER_README.md).

## πŸ”§ Building for Production

### Frontend Only

```bash
bun run build
```

### Backend Standalone Executable

```bash
cd src-python
box package
```

### Complete Docker Build

```bash
docker-compose up --build
```

## 🌐 What's Included

- **Real-time Robot Control**: WebSocket-based communication
- **3D Visualization**: Three.js integration for robot visualization
- **URDF Support**: Load and display robot models
- **Multi-robot Management**: Control multiple robots simultaneously
- **WebSocket API**: Real-time bidirectional communication
- **Standalone Distribution**: Self-contained executable with box-packager

## 🚨 Troubleshooting

### Port Conflicts

If ports 8080 or 7860 are already in use:

```bash
# Check what's using the ports
lsof -i :8080
lsof -i :7860

# Use different ports
docker run -p 8081:8080 -p 7861:7860 lerobot-arena
```

### Container Issues

```bash
# View logs
docker-compose logs lerobot-arena

# Rebuild without cache
docker-compose build --no-cache
docker-compose up
```

### Development Issues

```bash
# Clear node modules and reinstall
rm -rf node_modules
bun install

# Clear Svelte kit cache
rm -rf .svelte-kit
bun run dev
```

### Box-packager Issues

```bash
# Clean build artifacts
cd src-python
box clean

# Rebuild executable
box package

# Install cargo if missing
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

## πŸš€ Hugging Face Spaces Deployment

This project is configured for **Static HTML** deployment on Hugging Face Spaces (much simpler than Docker!):

**Manual Upload (Easiest):**
1. Run `bun install && bun run build` locally
2. Create a new Space with "Static HTML" SDK
3. Upload all files from `build/` folder
4. Your app is live!

**GitHub Integration:**
1. Fork this repository 
2. Create a Space and connect your GitHub repo
3. The Static HTML SDK will be auto-detected from the README frontmatter
4. Push changes to auto-deploy

No Docker, no complex setup - just static files! πŸŽ‰

## πŸ“š Additional Documentation

- [Docker Setup Guide](./DOCKER_README.md) - Detailed Docker instructions
- [Robot Architecture](./ROBOT_ARCHITECTURE.md) - System architecture overview
- [Robot Instancing Guide](./ROBOT_INSTANCING_README.md) - Multi-robot setup

## 🀝 Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Test with Docker: `docker-compose up --build`
5. Submit a pull request

## πŸ“„ License

This project is licensed under the MIT License.

---

**Built with ❀️ for the robotics community** πŸ€–