feat: Integrate Andhra Pradesh and telangana data and implement unified dual-state architecture
Here is a professional and detailed Merge Request (MR) description for your changes in the agri_hack branch:
MR: Unified Dual-State Agri-Intelligence Dashboard (TS & AP)
🚀 Overview
This Merge Request transforms CropNest into a multi-state market intelligence platform. It integrates real-time procurement data from the Andhra Pradesh Government API alongside market price intelligence for Telangana. The architecture has been redesigned to be context-aware, allowing users to toggle between states while maintaining a unified, premium user experience.
🛠 ️ Key Changes
1. Dual-State Architecture
-
Global State Switcher: Implemented a
StateProviderusing React Context to manage the selected state (TelanganaorAndhra Pradesh) across the entire application. - Dynamic Context: All pages (Home, Analytics, Nearby) now reactively update their headings, metrics, and data sources based on the selected state.
2. Multi-Source Data Integration
-
Telangana: Sourced from the local
commodity_price.csvdataset (Market Prices). -
Andhra Pradesh: Sourced directly from the official
data.gov.inAPI (District-wise Procurement Details). -
Unified API Route: Refactored
/api/mandito handle state-based filtering and data normalization, ensuring a seamless frontend experience.
3. Unified Branding & UI
- Branding Unification: Standardized all platform terminology. Removed "Procurement" specific labels in favor of a unified "Market Intelligence" branding for both states.
- Premium Design: Maintained high-fidelity aesthetics using Framer Motion for smooth state transitions and Glassmorphism for the UI components.
-
Context-Aware Cards:
- TS Mode: Focuses on Min/Max/Modal prices.
- AP Mode: Focuses on Procurement Volume (MTs), Farmer Support, and Seasonal Insights.
4. Technical Fixes
- Build Optimization: Resolved a critical Turbopack syntax error in the API route.
-
Data Fetching: Created a robust
scripts/fetch-all-data.jsscript to automate the merging of CSV and API data.
🧪 Verification Plan
Automated Tests
-
Production Build: Verified via npm run build(Exit code 0). -
API Integrity: Tested /api/mandi?state=Telanganaand/api/mandi?state=Andhra Pradeshfor correct data filtering.
Manual Verification
-
Toggled between TS and AP in the Navbar. -
Verified chart updates in the Analytics page for both states. -
Confirmed responsive search and filtering in the Nearby Markets page.
📸 Screenshots / Demos
(Describe the visual flow here: "The user clicks the state toggle in the Navbar, and the entire dashboard transitions smoothly from Telangana market prices to Andhra Pradesh procurement stats.")
