Skip to main content

Apollon GPS Tracking System

Apollon is a real-time GPS tracking system for logistics and cargo, built on Peplink router hardware. It provides REST, GraphQL and WebSocket APIs for live position tracking, trip management and client administration.

Architecture

┌──────────────┐
│ Peplink │
│ Router │
└──────┬───────┘

┌─────────────┐ ┌──────┴───────┐ ┌────────────────┐
│ Next.js │────▶│ Rust API │────▶│ PostgreSQL │
│ Frontend │ │ (Actix-web) │ │ (Relational) │
└──────┬──────┘ └──────────────┘ └────────────────┘
│ ┌────────────────┐
│ WebSocket (direct) │ TimescaleDB │
└─────────────────────────────────▶│ (GPS Series) │
└────────────────┘

Data Flow:

  • Browser → fetch() → Next.js API Routes → gql() → Rust API /v1/gql
  • Browser → WebSocket → Rust API /v1/ws (direct, no proxy)

Core Components

ComponentTechnologyPurpose
APIRust (Actix-web, sqlx, async-graphql)REST + GraphQL + WebSocket server
WebNext.js 16, React 19, shadcn/ui, Tailwind CSS 4Frontend with live map and trip management
Shared API@elcto/api (TypeScript)GraphQL client, WebSocket client, types
Shared UI@elcto/ui (React)Map, Spinner, ThemeToggle components
DatabasePostgreSQL 18Clients, trips, categories, contacts
Time-SeriesTimescaleDBGPS locations with hypertable compression
GPS SourcePeplink Router APIHardware GPS with automatic token auth

Monorepo Structure

shared/
api/ @elcto/api — GraphQL client, WebSocket, types
ui/ @elcto/ui — Map, Spinner, ThemeToggle
platform/
api/ Rust API (10 crates)
web/ Next.js 16 frontend
docs/ Documentation (Docusaurus)

Crate Structure

The Rust API is organized as a Cargo workspace with 10 crates:

CratePurpose
apollon-commonShared types, error handling, API response format
apollon-configTOML + env var configuration loading
apollon-dbDatabase models and sqlx queries
apollon-restREST handlers, middleware (auth, rate limit, security)
apollon-graphqlGraphQL schema, queries, mutations
apollon-websocketWebSocket server for live speed broadcasting
apollon-peplinkPeplink router client with token management
apollon-forwardingGPS data forwarding to external services
apollon-telemetryTracing and Sentry integration
apiMain binary, server startup, background loops

API Protocols

  • REST — 23 endpoints under /v1 with OpenAPI documentation
  • GraphQL — Full schema at /v1/gql with GraphiQL IDE
  • WebSocket — Live speed broadcasting at /v1/ws