Shamba Fleet Dashboard
Fleet management and trip-tracking dashboard for agricultural logistics.
Overview
Shamba Fleet Dashboard is a fleet management and operations monitoring system built for agricultural logistics in Kenya. Farm operators managing multiple vehicles, tractors, and trailers use it to track trips, monitor driver performance, and get real-time visibility into their fleet without phone calls.
The Problem
Agribusinesses coordinating farm deliveries had no centralised view of their fleet. Fleet managers were tracking vehicles via WhatsApp messages and manual logs. Trip assignments were made verbally, and there was no way to identify underutilised vehicles or spot patterns in delivery delays.
Technical Decisions
React Query for server state
All data fetching goes through React Query with a 5-minute stale time and garbage collection at 10 minutes. Refetch-on-focus is disabled — the dashboard is often left open on a monitor, and constant background refetches created noisy network traffic. Explicit refresh actions keep things predictable.
Dashboard transformers
Raw API responses for vehicles, employees, farms, and trips are normalised in a dedicated dashboardTransformers layer before reaching components. This decouples the component tree from the API schema — when the backend changes a field name, there's one place to fix it.
BaseEntityPage pattern
Employees, vehicles, trips, and farms all share the same CRUD layout: a header with filters, a data table, and an action menu. A BaseEntityPage wrapper component handles the shared shell so each page only defines its columns, filters, and form fields.
Auth interceptor
A single Axios instance injects Bearer tokens on every request and clears them on 401, routing back to login. Components never touch auth headers.
Key Features
- Dashboard — active vehicle count, employee count, trip count, and recent activity in a single view
- Trip management — create trips with driver, vehicle, trailer, and destination farm assignments
- Fleet inventory — vehicles and tractors with registration details and status tracking
- Analytics — trip performance trends, vehicle utilisation, driver performance rankings, tractor status distribution
- Employee directory — staff with employment groups and status
- Farm registry — farm locations and codes
Tradeoffs
React Query's caching strategy means the dashboard can show data up to 5 minutes stale. For a fleet context where trips are logged infrequently, this is fine. A live-tracking use case would need shorter stale times or WebSocket updates.
Retrospective
The transformer layer was worth the upfront cost. API schema changes happened several times during development and only ever touched one file. The thing to add next would be push notifications for trip status changes — currently managers have to check the dashboard proactively.