link:https://v0-hack-drill.vercel.app/dashboard
graph LR
A[Farmer] --> B[React Frontend]
B --> C[Express.js Backend]
C --> D[PL/SQL Database]
C --> E[OpenWeather API]
C --> F[OpenAI API]
C --> G[Finnhub API]
D --> C
E --> C
F --> C
G --> C
C --> B
-
User Profile Manager
- Collects soil type, region, and crop history via form
- Stores preferences in local storage
- Syncs with backend via REST API
-
Dashboard Layout
- Responsive grid with Tailwind CSS
- Modular widgets for different data types
- Dark/light mode support
-
Data Visualization
- Market price charts (Finnhub data)
- Weather forecast cards (OpenWeather data)
- Interactive crop recommendation cards
-
Alert System
- Real-time notification center
- Color-coded urgency indicators
- Historical alert browser
- State Management: React Context API + useReducer
- Routing: React Router v6 with protected routes
- Data Fetching: Axios with interceptors for API calls
- Styling: Tailwind CSS with custom theme configuration
- Type Safety: TypeScript interfaces for all API responses
-
Farmer Profile Service
POST /api/farmers: Create new farmer profileGET /api/farmers/:id: Retrieve farmer dataPUT /api/farmers/:id: Update profile information
-
Weather Service
GET /api/weather/:region: Fetch current weather and forecastsPOST /api/weather/alerts: Setup weather alert subscriptions
-
Market Data Service
GET /api/market/prices: Retrieve commodity pricesGET /api/market/trends: Get historical price trends
-
Advisory Service
POST /api/advisory/recommend: Generate crop suggestionsGET /api/advisory/pests: Get pest alerts for region
- Farmers Table: Stores farmer profiles and preferences
- Crop History Table: Tracks planting/harvest records
- Weather Alerts Table: Manages subscription settings
- Market Data Cache: Stores recent price information
-
OpenWeather API
- Hourly weather data fetching via cron jobs
- Severe weather detection algorithm
- Alert triggering mechanism
-
OpenAI API
- Prompt engineering for crop recommendations
- Response validation and sanitization
- Caching frequent queries
-
Finnhub API
- Daily commodity price updates
- Trend analysis for major crops
- Regional price comparison
sequenceDiagram
Farmer->>Frontend: Enters profile data
Frontend->>Backend: POST /api/farmers
Backend->>PL/SQL: Save profile
Backend->>OpenAI: Get crop recommendations
OpenAI-->>Backend: Crop suggestions
Backend->>PL/SQL: Store recommendations
Backend-->>Frontend: Response with suggestions
Frontend->>Farmer: Display dashboard
loop Hourly Updates
Backend->>OpenWeather: Request weather data
OpenWeather-->>Backend: Current conditions
Backend->>PL/SQL: Store weather data
Backend->>Frontend: Push alerts (if needed)
end
- Node.js v18+ (both frontend and backend)
- Oracle Database 19c+
- API keys for:
- OpenWeather (free tier available)
- OpenAI (GPT-4 access required)
- Finnhub (free tier available)
-
Backend (.env)
- Database credentials
- API keys for external services
- Server port configuration
-
Frontend (.env)
- Backend API base URL
- Mapbox access token (optional)
- Analytics tracking ID (optional)
-
Frontend
npm run build: Creates production-ready React app- Output: Static files in
/builddirectory
-
Backend
npm run build: Compiles TypeScript to JavaScript- Output: JavaScript in
/distdirectory
- Start backend service:
npm startin backend directory - Serve frontend: Use NGINX or serve static build files
- Configure reverse proxy for API access
- API Key Protection: Environment variables only
- Data Encryption: HTTPS mandatory, database encryption
- Input Validation: All user input sanitized
- Rate Limiting: Express-rate-limit middleware
- CORS: Strict origin restrictions
- Database Caching: Frequent queries cached
- API Response Caching: Redis for external API data
- Lazy Loading: Frontend components load on demand
- Image Optimization: Compressed assets
- Code Splitting: React dynamic imports
- Logging: Winston logger with daily rotation
- Health Checks:
/statusendpoint monitoring - Error Tracking: Sentry integration
- Alerting: Slack notifications for critical errors
- Scheduled Tasks: Cron jobs for data updates
