A comprehensive web application for documenting and tracking reforestation efforts, built with Next.js 14, React 18, and TypeScript.
TreeTracker empowers tree growers to document and share their reforestation efforts by capturing geotagged, time-stamped photos of the trees they plant and care for. These photos (Captures) are uploaded to the cloud, where Greenstand's verification system checks key attributes such as location, species, and authenticity.
Once verified, each Capture is assigned an Impact Token—a digital asset that quantifies the tree's ecological and social value. These tokens can be traded or used to reward contributors, creating a transparent, incentive-driven system that supports sustainable reforestation.
- Geotagged Photo Capture: Automatically capture GPS coordinates and timestamps with each tree photo
- Offline Functionality: Queue captures when offline and auto-sync when connection is restored
- Species Tracking: Document tree species and add custom notes
- Follow-up Captures: Track tree survival with follow-up photos
- Token Tracking: View and manage earned Impact Tokens
- Ecological Value: Track carbon offset, water retention, and biodiversity scores
- Token States: Monitor token lifecycle (Basic → Mature → Traded → Redeemed)
- Blockchain Integration: Ready for Hyperledger Fabric integration
- Geolocation Visualization: View all planted trees on an interactive map
- Status Filtering: Filter trees by verification status
- Detailed Markers: Click markers to view capture details
- Location Validation: Verify planting locations
- Progress Tracking: Monitor monthly and weekly planting progress
- Statistics Overview: View total trees, verified captures, and pending submissions
- Recent Activity: Quick access to recent captures and tokens
- Impact Summary: Track total environmental impact
- Real-time Updates: Get notified about verification status changes
- Token Alerts: Receive notifications when tokens are issued
- Survival Checks: Reminders for follow-up captures
- Action Items: Quick links to required actions
- User Profile: Manage personal information and account details
- Activity Statistics: View comprehensive planting statistics
- Project Tracking: Monitor project code and membership details
- Node.js 20.x or higher
- npm or yarn package manager
- Clone the repository:
git clone <repository-url>
cd treetracker-web- Install dependencies:
npm install- Create environment file:
cp .env.local.example .env.local- Configure environment variables in
.env.local:
NEXT_PUBLIC_API_URL=http://localhost:8000/api
NEXT_PUBLIC_HYPERLEDGER_ENDPOINT=http://localhost:3001
NEXT_PUBLIC_MAP_DEFAULT_LAT=0.0236
NEXT_PUBLIC_MAP_DEFAULT_LNG=37.9062
NEXT_PUBLIC_MAP_DEFAULT_ZOOM=6- Start the development server:
npm run dev- Open http://localhost:3000 in your browser
treetracker-web/
├── app/ # Next.js 14 App Router
│ ├── captures/ # Tree capture pages
│ │ ├── new/ # New capture form
│ │ └── page.tsx # Captures list
│ ├── tokens/ # Impact tokens pages
│ ├── map/ # Map view
│ ├── notifications/ # Notifications page
│ ├── profile/ # User profile
│ ├── layout.tsx # Root layout
│ ├── page.tsx # Dashboard
│ └── globals.css # Global styles
├── components/ # Reusable React components
│ ├── Header.tsx # Navigation header
│ ├── StatsCard.tsx # Statistics card
│ ├── CaptureCard.tsx # Tree capture card
│ ├── TokenCard.tsx # Impact token card
│ ├── NotificationItem.tsx # Notification item
│ └── MapView.tsx # Map component
├── lib/ # Utility functions and services
│ ├── api.ts # API service layer
│ ├── mockData.ts # Mock data for development
│ ├── offlineQueue.ts # Offline queue manager
│ ├── geolocation.ts # Geolocation service
│ └── utils.ts # Utility functions
├── types/ # TypeScript type definitions
│ └── index.ts # All type definitions
├── public/ # Static assets
├── package.json # Dependencies
├── tsconfig.json # TypeScript configuration
├── tailwind.config.ts # Tailwind CSS configuration
└── next.config.mjs # Next.js configuration
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- UI Library: React 18
- Styling: Tailwind CSS
- Maps: Leaflet & React-Leaflet
- Icons: Lucide React
- Date Handling: date-fns
The application includes a complete API service layer (lib/api.ts) with mock data for development. To integrate with a real backend:
- Update the
NEXT_PUBLIC_API_URLin.env.local - Replace mock API calls in
lib/api.tswith actual HTTP requests - Implement authentication token management
- Add error handling and retry logic
The application expects the following API endpoints:
POST /auth/login- User authenticationPOST /auth/register- User registrationGET /profile/:userId- Get user profilePUT /profile/:userId- Update user profileGET /captures- Get tree captures (paginated)POST /captures- Submit new captureGET /captures/:id- Get capture detailsGET /tokens- Get impact tokens (paginated)GET /tokens/:id- Get token detailsGET /notifications- Get user notificationsPOST /notifications/:id/read- Mark notification as readGET /dashboard/stats- Get dashboard statistics
The application is designed to integrate with Hyperledger Fabric for blockchain-based token management:
- Token Issuance: When a capture is verified, trigger chaincode to mint Impact Token
- Token Verification: Query blockchain to verify token authenticity
- Transaction History: Retrieve token transaction history from ledger
- Token Transfer: Execute chaincode for token trading/transfer
- Set up Hyperledger Fabric network
- Deploy TreeTracker chaincode
- Configure Fabric SDK in backend
- Update API endpoints to interact with chaincode
- Implement wallet management for users
// Example chaincode functions
- CreateToken(captureId, planterId, value)
- TransferToken(tokenId, fromUser, toUser)
- QueryToken(tokenId)
- QueryTokensByOwner(planterId)
- UpdateTokenState(tokenId, newState)The application includes robust offline support:
- Offline Queue: Automatically queues captures when offline
- Auto-Sync: Syncs queued items when connection is restored
- Status Indicators: Shows online/offline status
- Retry Logic: Automatically retries failed uploads
The offline queue is managed by lib/offlineQueue.ts and uses localStorage for persistence.
The application uses the browser's Geolocation API:
- High Accuracy Mode: Requests precise GPS coordinates
- Error Handling: Graceful handling of permission denials
- Distance Calculation: Haversine formula for distance between points
- Coordinate Validation: Ensures valid latitude/longitude values
Modify colors in tailwind.config.ts:
colors: {
primary: {
50: '#f0fdf4',
// ... other shades
900: '#14532d',
},
}Update map settings in .env.local:
NEXT_PUBLIC_MAP_DEFAULT_LAT=0.0236
NEXT_PUBLIC_MAP_DEFAULT_LNG=37.9062
NEXT_PUBLIC_MAP_DEFAULT_ZOOM=6- Create new tree capture with photo and GPS
- Test offline queue functionality
- Verify map markers display correctly
- Check token history and details
- Test notification system
- Verify profile editing
- Test responsive design on mobile
- Check all navigation links
- Add unit tests with Jest
- Add integration tests with React Testing Library
- Add E2E tests with Playwright
npm run buildnpm startThe easiest way to deploy is using Vercel:
npm install -g vercel
vercelEnsure all environment variables are set in your deployment platform:
NEXT_PUBLIC_API_URLNEXT_PUBLIC_HYPERLEDGER_ENDPOINTNEXT_PUBLIC_MAP_DEFAULT_LATNEXT_PUBLIC_MAP_DEFAULT_LNGNEXT_PUBLIC_MAP_DEFAULT_ZOOM
- Implement proper authentication and authorization
- Validate all user inputs on both client and server
- Use HTTPS for all API communications
- Implement rate limiting for API endpoints
- Secure storage of sensitive data
- Regular security audits and updates
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is part of the Greenstand TreeTracker ecosystem.
- Greenstand for the TreeTracker concept and mission
- OpenStreetMap for map tiles
- All contributors to the open-source libraries used
For support and questions:
- Create an issue in the repository
- Contact the Greenstand team
- Join the community discussions
- ✅ Core capture functionality
- ✅ Token tracking
- ✅ Map visualization
- ✅ Offline support
- Real backend integration
- Hyperledger Fabric integration
- Mobile app synchronization
- Advanced analytics
- Token marketplace
- Social features
- Gamification
- Multi-language support
Built with 🌳 by the TreeTracker team