# Shamba Records
Shamba Records is a full-stack field monitoring platform for coordinators and field agents.
It supports role-based access, field assignment, live map monitoring, stage progression updates, photo evidence uploads, and update history review.
---
## What is currently implemented
### Roles
- `admin` (Coordinator)
- `field_agent` (Field Agent)
- `user` (treated like assignable field user where applicable)
### Field workflow
- Create fields with geolocation and optional image
- Assign fields to agents
- Update stages (`Planted`, `Growing`, `Ready`, `Harvested`)
- Add notes on each update
- Attach photo evidence on field updates
- View latest update + full history (including images)
### Dashboards
- **Coordinator (`/coordinator`)**
- Field records table
- Field map view
- Agent management (promote/demote admin, delete user)
- Update history modal with image preview
- **Field Agent (`/field-agent`)**
- Assigned fields list
- Dedicated update modal (stage, notes, photo upload)
- History modal + full-screen image preview
### Backend/data
- Firestore-backed persistence (`users`, `fields`, `fieldUpdates`, plus legacy collections)
- JWT-based auth middleware
- Role-aware route protection
- Computed field status logic (`Active`, `At Risk`, `Completed`)
---
## Tech stack
- **Frontend:** Next.js (App Router), React, TypeScript, Tailwind
- **Backend:** Node.js, Express
- **Database:** Firebase Firestore (Firebase Admin SDK)
- **Auth:** JWT + Firebase login support
- **Map:** Leaflet / React-Leaflet
- **Uploads:** UploadThing
---
## Repository structure
- `frontend/` — Next.js app
- `backend/` — Express API server
- `README.md` — project documentation
---
## Quick start
## 1) Install dependencies
In two terminals:
```bash
# Terminal 1
cd backend
npm install
# Terminal 2
cd frontend
npm install
```
## 2) Configure environment variables
### Backend (`backend/.env`)
Required:
```env
PORT=5001
JWT_SECRET=replace_with_strong_secret
FIREBASE_PR …