livelocd

Crates.iolivelocd
lib.rslivelocd
version0.1.0
created_at2025-06-24 18:05:41.874217+00
updated_at2025-06-24 18:05:41.874217+00
descriptionA simple Axum plugin for real-time location tracking via WebSockets and JSON API.
homepagehttps://github.com/Burnsedia/livelocd
repositoryhttps://github.com/Burnsedia/livelocd
max_upload_size
id1724843
size35,456
Bailey Burnsed (Burnsedia)

documentation

https://docs.rs/livelocd

README

Livelocd

Livelocd is a lightweight Axum-compatible plugin for real-time location tracking via WebSockets and a JSON API. Easily drop it into any Rust backend to enable live geolocation dashboards, game user tracking, or delivery fleet monitoring.


✨ Features

  • πŸ“‘ WebSocket support for sending real-time location updates
  • πŸ‘‚ Subscribe to all users or individual users' locations
  • 🌐 REST API to query current locations
  • 🧩 Designed as a plugin for Axum or Loco.rs apps
  • ⚑ Built with minimal dependencies, powered by tokio, axum, and serde_json

πŸ“¦ Installation

In your project’s Cargo.toml:

livelocd = { path = "../livelocd" } # or use Git/crates.io in the future

πŸ”Œ Usage

In your Axum project:

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 with a user_id and any arbitrary fields (e.g., lat/lng)
  • GET /ws/subscribe β€” Receive real-time updates for all users
  • GET /ws/subscribe/:user_id β€” Subscribe to updates for a specific user

Example JSON payload:

{
  "user_id": "user123",
  "lat": 33.7489954,
  "lng": -84.3879824,
  "status": "moving"
}

πŸ” REST API Endpoints

  • GET /api/users β€” Get current known location for all users
  • GET /api/users/:user_id β€” Get most recent location for a single user

πŸ”’ Privacy & Security

You are responsible for securing the WebSocket and API endpoints (auth, rate limiting, etc.) based on your use case.


πŸš€ Use Cases

  • Live fleet or delivery tracking
  • Multiplayer game player positions
  • Dashboards for location-aware apps
  • IoT geolocation feeds

πŸ§ͺ Testing Locally

Use websocat:

# Send location
websocat ws://localhost:3000/ws/send-location
{"user_id": "car-1", "lat": 40.7, "lng": -74.0}

# Subscribe to all
websocat ws://localhost:3000/ws/subscribe

πŸ›  Built With


πŸ“„ License

MIT


🀝 Contributing

Pull requests welcome! Let’s make real-time dashboards in Rust even easier.

Commit count: 0

cargo fmt