Skip to content

feat: Add guest mode authentication and fix dashboard telemetry display#11

Merged
gagan-devv merged 4 commits into
mainfrom
feature/guest-mode-and-telemetry-fix
Apr 2, 2026
Merged

feat: Add guest mode authentication and fix dashboard telemetry display#11
gagan-devv merged 4 commits into
mainfrom
feature/guest-mode-and-telemetry-fix

Conversation

@gagan-devv

Copy link
Copy Markdown
Owner

🎯 Overview

This PR introduces guest mode functionality for anonymous users and fixes critical dashboard telemetry issues. Users can now try predictions without registration, and the dashboard correctly displays real-time sensor data.

✨ Features

Guest Mode Authentication

  • 🎭 Anonymous access with 30-minute JWT tokens
  • 🔓 Guest-specific prediction endpoints (no registration required)
  • 🚫 Middleware protection for user-only routes
  • 📱 Seamless guest UI flow in mobile app

Dashboard Telemetry Fix

  • 📊 Real-time sensor data now displays correctly
  • 🔄 Fixed API response field name normalization (n/p/k → N/P/K)
  • 🐛 Resolved "Choose from History" button not showing results
  • ✅ Fixed zero value rendering in StatCard components

🔧 Technical Changes

Backend (Go)

  • Added /api/v1/auth/guest endpoint for guest token generation
  • Created RequireUser() middleware to block guest access to protected routes
  • Implemented guest prediction endpoints: /api/v1/guest/predict/{crop,fertilizer,suitability}
  • Fixed ONNX inference to handle int64 output tensors
  • Updated fertilizer model labels to match actual outputs

Mobile App (React Native)

  • Implemented guest authentication flow with isGuest flag in authStore
  • Added guest API methods (guestPredictCrop, guestPredictFertilizer, etc.)
  • Fixed dashboard to normalize nested API response structure
  • Enhanced console logging for debugging sensor data flow
  • Added guest badge indicator and restricted navigation
  • Fixed StatCard value rendering for zero/null values

ML Models

  • Re-exported ONNX models with int64 outputs (ArgMax + Identity nodes)
  • Crop model: 23 classes with correct tensor names
  • Fertilizer model: 7 classes with updated labels
  • Added validation and conversion scripts

🐛 Bug Fixes

  • Fixed dashboard telemetry showing -- instead of actual sensor values
  • Fixed "Choose from History" button not displaying prediction results
  • Fixed "Predict Again" button to properly clear results and reset state
  • Resolved race condition in guest login flow
  • Fixed nested API response handling from backend

📚 Documentation

  • Updated README.md with new architecture and v2.0 features
  • Documented guest mode functionality and API endpoints
  • Added comprehensive API endpoint documentation
  • Updated tech stack and project structure

🧪 Testing

  • ✅ All mobile tests pass
  • ✅ Backend endpoints tested and verified
  • ✅ Guest mode fully functional end-to-end
  • ✅ Dashboard telemetry displays real sensor data

📸 Screenshots

Before

  • Dashboard showing -- for all telemetry values
  • No guest mode option

After

  • Dashboard displaying real sensor data (Temperature: 28.1°C, Humidity: 19%, etc.)
  • Guest mode accessible from landing page
  • Predictions work without registration

🔄 Migration Notes

No breaking changes. Existing users are unaffected. Guest tokens are separate from user tokens.

📝 Checklist

  • Code follows project style guidelines
  • Tests pass successfully
  • Documentation updated
  • No breaking changes
  • Commit messages follow conventional commits
  • Branch is up to date with base branch

Files Changed: 28 files (+2511, -623)
Commit: 6c76926

Major Features:
- Add guest mode authentication with 30-minute tokens
- Implement guest prediction endpoints (crop, fertilizer, suitability)
- Fix dashboard real-time telemetry to display actual sensor data
- Add offline support with request queuing for mobile app

Backend Changes:
- Add /api/v1/auth/guest endpoint for guest token generation
- Create RequireUser() middleware to block guest access to user-only routes
- Add guest-specific prediction endpoints: /api/v1/guest/predict/*
- Fix ONNX inference to handle int64 output tensors
- Update fertilizer labels to match actual model outputs

Mobile App Changes:
- Add guest mode UI flow with landing page integration
- Implement guest authentication in authStore with isGuest flag
- Add guest API methods (guestPredictCrop, guestPredictFertilizer, etc.)
- Fix dashboard to normalize API response field names (n/p/k -> N/P/K)
- Add detailed console logging for debugging sensor data flow
- Fix StatCard value rendering to handle zero values correctly
- Add guest badge indicator in predict page
- Restrict guest access to predict/output pages only
- Hide bottom navigation for guest users

ML Model Fixes:
- Re-export ONNX models with int64 outputs (ArgMax + Identity nodes)
- Fix crop model: 23 classes with correct output tensor names
- Fix fertilizer model: 7 classes with updated labels
- Add model validation and conversion scripts

Documentation:
- Update README.md with new architecture and features
- Document guest mode functionality
- Add comprehensive API endpoint documentation
- Update tech stack and project structure

Bug Fixes:
- Fix dashboard telemetry showing '--' instead of actual values
- Fix 'Choose from History' button not displaying results
- Fix 'Predict Again' button to clear results properly
- Handle nested API response structure from backend
- Fix race condition in guest login flow

Testing:
- All mobile tests pass
- Backend endpoints tested and verified
- Guest mode fully functional end-to-end

Signed-off-by: Gagan Ahlawat <gagan.devvv@gmail.com>
- Remove stitch design files from repository
- Keep stitch/ in .gitignore to prevent future commits
- Files remain available locally for reference
- Add non-null assertions for accessToken in API calls
- Remove email property from profile.tsx (not in AuthState)
- Fix CI/CD typecheck failures

Changes:
- predict.tsx: Add ! operator for accessToken in guest mode checks
- output.tsx: Add ! operator for accessToken in prediction calls
- dashboard.tsx: Add ! operator for accessToken after guard check
- profile.tsx: Remove email references (not stored in backend)
@gagan-devv gagan-devv merged commit 4a8b856 into main Apr 2, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant