PortPlateAI is a comprehensive data analytics dashboard and AI assistant for analyzing California's top agricultural commodities. Built with React, this production-quality application provides interactive visualizations, AI-powered insights, and spoilage simulation tools.
- Features
- Tech Stack
- Project Structure
- Installation
- Usage
- Backend Integration Guide
- Available Scripts
- Data Sources
- Future Enhancements
- Commodity selector with 8 major California crops
- Real-time metric cards (Total Value, Production, Export Value, etc.)
- Multiple chart types (Bar, Pie) using Recharts
- Comprehensive data table with all attributes
- Responsive design with TailwindCSS
- Natural language query interface
- Mock AI responses (ready for LangGraph/LLM integration)
- Conversation history tracking
- Example queries for user guidance
- Transportation delay modeling
- Temperature impact calculation
- Cold storage factor analysis
- Risk categorization (Low, Medium, High, Critical)
- Economic loss estimation
- Actionable recommendations
- Project mission and problem statement
- Technology stack overview
- Data source documentation
- Roadmap for future features
| Technology | Purpose |
|---|---|
| React 18 | Frontend framework |
| Vite | Build tool and dev server |
| React Router | Client-side routing |
| TailwindCSS | Utility-first styling |
| Recharts | Data visualization |
| PapaParse | CSV parsing |
| Axios | HTTP client (for future API calls) |
portplateai/
├── public/
├── src/
│ ├── components/
│ │ ├── Navbar.jsx # Navigation bar
│ │ ├── Footer.jsx # Footer component
│ │ ├── CommodityDropdown.jsx # Commodity selector
│ │ ├── SummaryCards.jsx # Metric cards display
│ │ ├── CommodityCharts.jsx # Recharts visualizations
│ │ ├── CommodityTable.jsx # Detailed data table
│ │ ├── AIInputBox.jsx # AI query interface
│ │ └── SimulationForm.jsx # Simulation input form
│ ├── pages/
│ │ ├── Dashboard.jsx # Main analytics page
│ │ ├── AIInsights.jsx # AI query page
│ │ ├── Simulation.jsx # Spoilage simulation page
│ │ └── About.jsx # About/info page
│ ├── data/
│ │ └── commodities.csv # Agricultural data (2023)
│ ├── App.jsx # Main app component with routing
│ ├── main.jsx # React entry point
│ └── index.css # Global styles with Tailwind
├── index.html
├── package.json
├── vite.config.js
├── tailwind.config.js
├── postcss.config.js
└── README.md
- Node.js (v16 or higher)
- npm or yarn
- Navigate to project directory:
cd portplateai- Install dependencies:
npm install- Start the development server:
npm run dev- Open in browser:
Navigate to
http://localhost:3000
- Select a commodity from the dropdown
- View key metrics in the summary cards
- Explore interactive charts
- Review detailed data in the table
- Type a question in the input box (or select an example)
- Click "Ask AI" to get insights
- View conversation history below
- Note: Currently shows mock responses
- Select a commodity
- Enter transportation delay (hours)
- Set average temperature (°F)
- Choose cold storage availability
- Click "Run Simulation" to see results
- Review spoilage %, economic loss, and risk category
- Note: Uses mock formulas
Location: src/pages/AIInsights.jsx
Current Code:
const handleAIQuery = async (query) => {
// TODO: Replace this with actual backend API call
const mockResponse = generateMockResponse(query, commodityData);
// ...
};Replace with:
import axios from 'axios';
const handleAIQuery = async (query) => {
try {
const response = await axios.post('YOUR_BACKEND_URL/api/ai/query', {
query: query,
data: commodityData
});
const aiResponse = response.data.response;
const newEntry = {
query,
response: aiResponse,
timestamp: new Date().toISOString(),
};
setResponse(aiResponse);
setConversationHistory(prev => [...prev, newEntry]);
} catch (error) {
console.error('AI Query Error:', error);
setResponse('Sorry, there was an error processing your request.');
}
};Location: src/pages/Simulation.jsx
Current Code:
const runSimulation = (formData) => {
// TODO: Replace with actual backend API call
const baselineSpoilage = calculateSpoilage(...);
// ...
};Replace with:
import axios from 'axios';
const runSimulation = async (formData) => {
try {
const response = await axios.post('YOUR_BACKEND_URL/api/simulate', formData);
setResults({
spoilagePercent: response.data.spoilagePercent,
economicLoss: response.data.economicLoss,
riskCategory: response.data.riskCategory,
...formData,
});
} catch (error) {
console.error('Simulation Error:', error);
// Handle error appropriately
}
};Create a .env file in the root directory:
VITE_API_BASE_URL=http://localhost:5000
VITE_AI_ENDPOINT=/api/ai/query
VITE_SIMULATION_ENDPOINT=/api/simulateUpdate your code to use:
const API_URL = import.meta.env.VITE_API_BASE_URL;# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run previewThe application uses data from:
-
California Department of Food & Agriculture (CDFA)
- Production statistics
- Organic certification data
-
USDA National Agricultural Statistics Service (NASS)
- Crop reports
- Yield data
-
USDA Economic Research Service
- Export values
- Market analysis
The commodities.csv file includes:
- Commodity name
- Year
- Planted/Harvested Acres
- Yield (with units)
- Production (with units)
- Price (with units)
- Total Value (USD)
- U.S. Rank
- CA Share percentages
- Export data
- Organic statistics
- Notes
- Multi-year trend analysis
- LangGraph-powered AI integration
- Real-time price feeds
- Weather impact analysis
- Expanded commodity coverage
- User authentication
- Custom report generation
- Mobile app version
- LangGraph/LLM API for AI insights
- Predictive modeling API for simulations
- Data pipeline for real-time updates
- User management system
This project is designed to be extensible. To add new features:
- New Commodity: Add data to
commodities.csv - New Page: Create in
src/pages/and add toApp.jsxroutes - New Component: Create in
src/components/and import where needed - New Chart: Use Recharts components in
CommodityCharts.jsx
- CSV is loaded on app mount via PapaParse
- All currency values use USD formatting
- Charts are responsive and mobile-friendly
- Mock responses clearly labeled for future replacement
- TailwindCSS provides consistent styling
- Component-based architecture for easy maintenance
For questions, suggestions, or issues:
- Review the code comments for implementation details
- Check the console for any error messages
- Ensure
commodities.csvis properly formatted
This project is for educational and demonstration purposes.
Built with ❤️ for agricultural innovation
🌾 PortPlateAI - Empowering agriculture through data-driven insights