Skip to content

Aman-singh98/nagar-field-tracking

Repository files navigation

Nagar 🗺️

Field workforce management — GPS-tracked routes, live employee map, and automated visit verification.

Nagar is a production-grade field operations system built for businesses that deploy employees to multiple locations daily — sales teams, delivery agents, medical reps, and survey workers.

Managers assign routes with GPS-fenced stops. Employees navigate their route on the Android app — visits are verified automatically when they enter the geofence. Managers see live location and real-time completion status on the web dashboard.

Built as a production MVP in 20 weeks by a solo developer.


Screenshots

Add screenshots here after first deploy (Pending)


Features

Mobile App (React Native + Expo)

Feature Description
🔐 Secure Login JWT auth with auto-login and token refresh
📋 Route View Today's assignment with all centers and visit status badges
📍 GPS Tracking Background location tracking every 25 seconds with offline queue
✅ Auto Visit Detection Geofence entry automatically marks center as Visited
🗺️ My Route Map Interactive map with center pins, geofence circles, and directions
🔔 Live Visit Toasts Real-time socket notification when a center is marked visited
⏹️ Session Summary Animated end-of-duty summary — hours worked, distance, centers visited
🕐 Attendance History Last 30 days of duty sessions with center-by-center breakdown
🟢 Tracking Indicator Green/red dot showing live GPS tracking status
🔋 Battery Optimization Android battery whitelist prompt for reliable background tracking
📄 Consent Screen GDPR-compliant data consent shown once before first tracking session
🚫 Permission Handling Clear guidance screen when location permission is denied or blocked

Admin Dashboard (React + Vite)

Feature Description
👥 Employee Management Create, edit, deactivate employees with role-based access
🛣️ Route Builder Create routes with named centers, GPS coordinates, and geofence radius
📅 Assignment Manager Assign routes to employees by date
🗺️ Live Map Real-time employee location pins, polling every 30 seconds
📊 Visit Status View Per-assignment center status with colored badges
📈 Daily Reports Hours, distance, centers visited per employee with date filter
📥 CSV Export One-click export of daily report data

Backend (Node.js + Express + MongoDB)

Feature Description
🔑 Auth System JWT access tokens (1hr) + refresh tokens (30d), bcrypt passwords
📡 GPS Ingestion POST /locations accepts GPS points, validates, stores to DB
🔵 Geofence Engine Haversine formula distance check — auto-marks visits on entry
🔄 Socket.IO Real-time visit:updated events pushed to mobile app
📊 Reports API Daily summary per employee with computed stats
🛡️ Security Helmet.js, rate limiting on auth routes, role middleware on all routes
📶 Offline Queue SQLite local queue on device — syncs on reconnect

Tech Stack

Layer Technology
Mobile React Native, Expo, Zustand, Socket.IO client
Admin Dashboard React, Vite, Axios, Leaflet.js
Backend Node.js, Express.js, MongoDB, Mongoose
Auth JWT, bcrypt, expo-secure-store
Maps (Mobile) react-native-maps, Google Maps SDK
Maps (Web) Leaflet.js + OpenStreetMap
Background GPS expo-location, expo-task-manager
Offline Sync expo-sqlite, custom queue service
Push Notifications Firebase Cloud Messaging (FCM)
Deployment Render (backend), Vercel (dashboard), EAS Build (APK)

Project Structure

nagar/
├── backend/              # Node.js + Express API
│   ├── controllers/
│   ├── models/
│   ├── routes/
│   ├── middleware/
│   └── services/
│
├── AdminDashboard/       # React web dashboard (Vite)
│   ├── src/
│   │   ├── components/
│   │   ├── pages/
│   │   ├── hooks/
│   │   └── store/
│
└── mobile/               # React Native app (Expo)
    ├── app/              # Expo Router file-based routing
    ├── components/
    ├── hooks/
    ├── services/
    ├── store/
    ├── tasks/
    └── types/

Getting Started

Prerequisites

  • Node.js 18+
  • MongoDB Atlas account (free tier)
  • Expo account + EAS CLI
  • Google Maps API key (Android)
  • Firebase project (FCM)

Backend Setup

cd backend
npm install
cp .env.example .env
# Fill in MONGO_URI, JWT_SECRET, etc.
npm run dev

Admin Dashboard Setup

cd AdminDashboard
npm install
cp .env.example .env
# Set VITE_API_BASE_URL
npm run dev

Mobile App Setup

cd mobile
npm install
cp .env.example .env
# Set EXPO_PUBLIC_API_BASE_URL
npx expo start

Build Android APK

eas build -p android --profile preview

Environment Variables

Backend .env

MONGO_URI= use own keys..
JWT_SECRET= use own keys..
JWT_REFRESH_SECRET= use own keys..
PORT=5000

Mobile .env

EXPO_PUBLIC_API_BASE_URL=https://your-backend.onrender.com

Dashboard .env

VITE_API_BASE_URL=https://your-backend.onrender.com

Deployment

Service Platform Cost
Backend API Render (free tier) ₹0
Database MongoDB Atlas M0 ₹0
Admin Dashboard Vercel ₹0
Android APK Expo EAS (free tier) ₹0

Total monthly cost for MVP: ₹0


Development Timeline

Built in 20 weeks as a solo developer working 2–4 hours/day.

Phase Weeks Focus
Phase 1 — MVP Weeks 1–10 Core backend, web dashboard, basic mobile app
Phase 2 — Advanced Weeks 11–20 Background tracking, sockets, offline sync, alerts, FCM

License

MIT


Built with ☕ by Aman Singh

About

Field workforce management system — GPS-tracked routes, live employee map, and automated visit verification. Built with React Native, Node.js, and MongoDB.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors