Field Marketing System adalah aplikasi internal untuk mengelola rencana penagihan, laporan kunjungan, bukti foto, dan pemantauan lokasi tim lapangan. Project ini menggunakan monorepo npm workspaces dengan dua aplikasi utama: mobile app untuk field collector dan web dashboard untuk admin/superadmin.
- Mobile app: Expo React Native app untuk user lapangan membuat rencana, mengirim laporan kunjungan, upload foto bukti, dan mengirim lokasi.
- Web dashboard: Next.js dashboard untuk admin dan superadmin melihat KPI, laporan, peta lokasi, dan manajemen user.
- Backend: Supabase PostgreSQL, Row Level Security, Storage, dan Edge Functions.
- Shared package: tipe, konstanta, dan schema validasi yang dapat digunakan lintas app.
| Area | Technology |
|---|---|
| Monorepo | npm workspaces |
| Mobile | Expo SDK 54, React Native 0.81, Expo Router |
| Web | Next.js 14 App Router, React 18, Tailwind CSS |
| State | Zustand |
| Forms | React Hook Form, Zod |
| Backend | Supabase PostgreSQL, Storage, Edge Functions |
| Maps | Google Maps / react-native-maps |
| Shared code | @field-marketing/shared |
.
├── apps
│ ├── mobile # Expo React Native app
│ └── web # Next.js dashboard
├── packages
│ └── shared # Shared types, constants, validations
├── supabase
│ ├── functions # Supabase Edge Functions
│ └── migrations # Database migrations
├── package.json # Workspace scripts
├── package-lock.json
└── tsconfig.base.json
Located in apps/mobile.
Primary responsibilities:
- Login using employee ID.
- Create and view collection plans.
- Submit visit reports with amount, status, GPS location, and photo evidence.
- View report history, calendar, and map-based visit data.
- Send current location for admin monitoring.
Located in apps/web.
Primary responsibilities:
- Admin and superadmin dashboard.
- KPI, performance, status, and revenue visualization.
- Report table, filters, and export flow.
- User management for superadmin.
- Delete request approval workflow for plans submitted from mobile.
| Role | Access |
|---|---|
user |
Mobile app only |
admin |
Web dashboard, report monitoring, delete request review |
superadmin |
Full web dashboard access, user management, import flow |
The mobile app blocks admin/superadmin accounts. The web dashboard blocks field user accounts.
- Node.js 20 LTS or newer. Node 20 is recommended for Expo development.
- npm 10 or newer.
- Expo Go for mobile development.
- Supabase project.
- Google Maps API key for mobile maps.
Use npm only. This project is configured for npm workspaces.
Create apps/mobile/.env.local:
EXPO_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
EXPO_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
EXPO_PUBLIC_GOOGLE_MAPS_API_KEY=your-google-maps-api-key
EXPO_PUBLIC_APP_URL=http://localhost:8081Create apps/web/.env.local:
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-keyDo not expose SUPABASE_SERVICE_ROLE_KEY to client-side code.
Install dependencies from the repository root:
npm installAvoid installing dependencies independently inside workspace folders unless you understand the lockfile impact.
Run the web dashboard:
npm run dev:webRun the mobile app:
npm run dev:mobileOr from the mobile workspace:
cd apps/mobile
npx expo start -cUse tunnel mode only when LAN connection is not available:
cd apps/mobile
npx expo start --tunnel -cType-check mobile:
npx tsc --noEmit -p apps/mobile/tsconfig.jsonType-check web:
npx tsc --noEmit -p apps/web/tsconfig.jsonLint web:
npm run lint --workspace=apps/webFormat check:
npm run format:checkDatabase migrations are stored in supabase/migrations.
Edge Functions are stored in supabase/functions:
| Function | Purpose |
|---|---|
validate-nomor-induk |
Validates employee ID and returns a custom JWT |
process-laporan-submit |
Validates ownership, GPS bounds, and inserts reports |
bulk-import-users |
Imports users from parsed Excel rows |
Apply migrations in order before testing production-like flows. Storage buckets and policies must be configured in Supabase for report photo uploads.
Preview Android build:
cd apps/mobile
npx eas build --platform android --profile previewProduction build configuration is maintained in apps/mobile/eas.json.
- Web and mobile use different React major versions.
apps/mobile/metro.config.jsforces Metro to resolve React fromapps/mobile/node_modulesto avoid duplicate React runtime issues.- Run dependency installation from the root so
package-lock.jsonremains authoritative. - Keep app-specific environment files inside their respective workspace folders.
SUPABASE_DEPLOYMENT.mdMIGRATIONS_VERIFICATION.mdMOBILE_ADMIN_INTEGRATION_GUIDE.mdCHANGELOG.md
Private internal project.