# Livelocd Documentation
**Livelocd** is a lightweight plugin for [Axum](https://github.com/tokio-rs/axum) that enables **real-time location tracking** using WebSockets.
## π§ Installation
```toml
# Cargo.toml
[dependencies]
livelocd = "0.1.0"
```
## π Features
- Realtime WebSocket tracking for any client
- Broadcast to all clients or to individual subscribers
- JSON API to fetch user location(s)
- Built on Axum and Tokio β fast and async-native
- Easily embeddable in other projects
---
## π¦ Usage
```rust
use axum::{Router};
use livelocd::livelocd_routes;
#[tokio::main]
async fn main() {
let app = Router::new().merge(livelocd_routes());
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
}
```
---
## π‘ WebSocket Endpoints
### `GET /ws/send-location`
Send JSON objects from clients in the following format:
```json
{
"user_id": "user123",
"location": "33.7489954,-84.3879824"
}
```
### `GET /ws/subscribe`
Broadcasts **all user locations** to subscribers in real-time.
### `GET /ws/subscribe/:user_id`
Broadcasts updates only for a **specific user**.
---
## π REST API Endpoints
### `GET /api/users`
Returns a JSON map of all users and their last known locations:
```json
{
"user123": "33.7489954,-84.3879824",
"user456": "40.712776,-74.005974"
}
```
### `GET /api/users/:user_id`
Returns a single userβs location:
```json
{
"user_id": "user123",
"location": "33.7489954,-84.3879824"
}
```
---
## π§© Integration Ideas
- Live delivery driver tracking
- Real-time multiplayer player positions
- IoT device geolocation
- Emergency response dashboards
---
## β License
MIT Β© [Bailey Burnsed](https://github.com/Burnsedia)
## π Repository
[https://github.com/Burnsedia/livelocd](https://github.com/Burnsedia/livelocd)