code/ cruisebuddy /README.md
90 lines · 2.3 KB · markdown Raw
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
# CruiseBuddy v1

Real-time group drive tracking web app. No app store, no accounts — just open the link, set your name, and drive together.

## Quick Start (Windows VPS)

1. **Install Python 3.10+** if you don't have it already
   - Download from https://python.org
   - Make sure to check "Add to PATH" during installation

2. **Install dependency**
   ```
   pip install aiohttp
   ```

3. **Copy files to your VPS**
   Put `server.py` and `index.html` in the same folder, e.g.:
   ```
   C:\CruiseBuddy\
   ├── server.py
   ├── index.html
   └── requirements.txt
   ```

4. **Run the server**
   ```
   cd C:\CruiseBuddy
   python server.py
   ```

5. **Open in browser**
   - Local: http://localhost:8765
   - From other devices on your network: http://YOUR_VPS_IP:8765
   - Make sure port 8765 is open in Windows Firewall

## Firewall (Windows)

To allow connections from outside:
```
netsh advfirewall firewall add rule name="CruiseBuddy" dir=in action=allow protocol=TCP localport=8765
```

## Running in Background (Windows)

To keep it running after you close the terminal, use:
```
start /B python server.py > cruisebuddy.log 2>&1
```

Or use NSSM (Non-Sucking Service Manager) to install it as a Windows Service.

## For Linux (later migration)

Same exact steps, just:
```bash
pip install aiohttp
python3 server.py
```

Or with PM2:
```bash
pm2 start server.py --interpreter python3 --name cruisebuddy
```

## Architecture

- **Frontend**: Single HTML file with Leaflet.js (CartoDB Dark Matter tiles), WebSocket client, GPS Geolocation API
- **Backend**: Python aiohttp server handling WebSocket connections, room management, position relay, and chat
- **Protocol**: JSON over WebSocket — positions sent every 2 seconds during active drives

## Features

- Leader creates room with 5-digit code, sets max participants (2-10)
- Members join via code, see participant list
- Leader starts/pauses/resumes/ends the drive
- Real-time GPS tracking with blue line from follower to leader
- Line turns red when drive is paused
- Group chat available during the session
- Screen wake lock to prevent phone sleep
- Auto-reconnect on connection loss
- No accounts, no data storage — everything is ephemeral

## Port & Host Config

Edit the top of `server.py` to change:
```python
HOST = "0.0.0.0"   # Listen on all interfaces
PORT = 8765         # Change if needed
```