Skip to content

inayatxen/Emptracker

Repository files navigation

EmpTracker MVP

Production-oriented employee/group GPS tracking web app built with Next.js, Supabase, and Leaflet.

Features

  • Auth — Email/password signup, login, forgot password (Supabase Auth + profiles table)
  • Groups — Create group, invite code, join requests, approve/reject members, remove members (admin)
  • Tracking — Foreground GPS sharing with throttled upsert (~20s) to user_locations_latest
  • Live map — Leaflet + OpenStreetMap, member markers, online/last-seen badges
  • Admin — Group admins manage pending members and view all approved members
  • UI — Responsive dashboard, light/dark theme (next-themes), ShadCN + Tailwind

Stack

  • Next.js 15 (App Router) + TypeScript
  • Tailwind CSS + ShadCN UI
  • TanStack Query + Zustand
  • Leaflet + react-leaflet (dynamic import, no SSR)
  • Supabase (@supabase/ssr)

Prerequisites

Setup

1. Clone and install

cd ~/Projects/emptracker
npm install

2. Environment variables

Copy .env.example to .env.local and fill in your Supabase credentials from Project Settings → API:

NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key

3. Run database migrations

Option A — Supabase CLI (recommended)

npx supabase login
npx supabase link --project-ref your-project-ref
npx supabase db push

Option B — SQL Editor

Copy the contents of supabase/migrations/20250531000000_initial_schema.sql into the Supabase SQL Editor and run it.

4. Enable Realtime

In Supabase Dashboard → Database → Replication, ensure user_locations_latest and group_members are enabled for Realtime (the migration adds them to supabase_realtime publication).

5. Start dev server

npm run dev

Open http://localhost:3000.

Project structure

src/
├── app/
│   ├── (auth)/          # login, signup, forgot-password
│   ├── (dashboard)/     # dashboard, groups, map, members, profile, settings
│   └── page.tsx         # landing / splash
├── components/ui/       # ShadCN components
├── features/            # auth, dashboard, map
├── hooks/               # geolocation, group locations, toast
├── lib/supabase/        # browser + server clients, middleware
├── services/            # GroupService, TrackingService
├── store/               # Zustand app store
└── types/               # database types
supabase/migrations/     # SQL schema + RLS

Deploy to Vercel

  1. Push the repo to GitHub.
  2. Import the project in Vercel.
  3. Add environment variables:
    • NEXT_PUBLIC_SUPABASE_URL
    • NEXT_PUBLIC_SUPABASE_ANON_KEY
  4. In Supabase Authentication → URL Configuration, add your Vercel URL to Site URL and Redirect URLs.
  5. Deploy.

Schema notes

  • Uses profiles linked to auth.users (no standalone users table)
  • user_locations_latest — one row per user for realtime map (not append-only history)
  • group_members — unique (group_id, user_id), status enum, role enum
  • RLS scopes location reads to approved co-group members

MVP limitations

Not included: geofencing, SOS/push notifications, route history playback, exports, PWA/offline, Google OAuth, phone auth, analytics charts.

License

MIT

About

employees tracker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors