How eusonlito/gps-tracker works
Project type and purpose
• This is a monolithic, full-stack GPS tracking platform built on Laravel 12 (PHP 8.2) with MySQL 8 and Redis.
• It exposes an HTTP web UI for administrators, a REST/JSON API for clients and public sharing, and custom TCP/UDP servers for ingesting GPS device data (Sinotrack, Coban, Teltonika, etc.).
Top-level architectural containers
• Browser (Web UI)
• Laravel HTTP App (Laravel MVC & API)
• Device Data Ingestion Services
• Job Queue / Scheduler
• MySQL Database
• Redis (caching & queue backend)
• External Services (Telegram Bot API, Translation Providers – DeepL, Microsoft, OpenAI)
Main components & relationships
A. Browser
• Uses Blade‐rendered HTML, CSS and JavaScript (public/build) to present dashboards, device maps, trip reports, config screens.
• Invokes Laravel HTTP controllers via standard web routes or AJAX/JSON endpoints.
B. Laravel HTTP App
• Routes → Controllers (app/Domains/**/Controller) → Service/Action layers → Models → Database
• Domain modules (Alarm, Device, Trip, Maintenance, User, etc.) follow a consistent structure:
– Validate (input rules)
– Controller (HTTP request handling / routing)
– Service/Action (business logic)
– Model/Builder/Collection (Eloquent ORM + query builders)
– Fractal (transformers for JSON/API responses)
• Console Commands (app/Console) & Scheduled tasks (app/Domains/**/Schedule) orchestrate periodic jobs.
• Middleware (app/Http/Middleware & domain‐specific) manage auth, logging, rate‐limiting, IP locks.
C. Device Data Ingestion Services
• Socket & HTTP Servers (app/Services/Server) listen for incoming GPS device connections on TCP/UDP or HTTP.
• ProtocolFactory selects the correct Protocol Parser (GPS103, GT06, Teltonika, Aquila, OsmAnd, TK102).
• Parsed raw data is mapped to Domain Actions (e.g., PositionCreate, AlarmCheck) and persisted via Eloquent Models.
• Enqueues follow-up Jobs (app/Domains/**/Job) for notifications, analytics, geofence checks.
D. Job Queue & Scheduler
• Redis queue backend processes Jobs (alarms, notifications, data cleanup, statistics updates).
• Laravel Scheduler (cron) triggers recurring tasks (e.g., trip stats, city/country updates).
E. Data Storage
• MySQL 8 with GIS support for geographic queries (latitude/longitude, geofences).
• Schema is versioned with migrations (database/migrations).
• Seeders provide initial data (languages, timezones, configurations).
F. External Integrations
• Telegram Bot API for alarm notifications.
• Translation Providers (DeepL, Microsoft, OpenAI) for UI localization.
Architectural patterns & design principles
• MVC for HTTP side
• Domain-Driven module structure (each Domain has its own subfolders: Action, Controller, Service, Validate, Test, Fractal, Model, Job)
• Dependency Injection via Laravel service providers (app/Providers)
• Factory patterns for Actions, Commands, Protocols
• Queued Jobs for asynchronous processing
• Fractal transformer layer for clean JSON APIs
• Single‐responsibility classes (small controllers, isolated validation, dedicated service controllers)