Skip to content

devsoc-unsw/trainee-bard-24t2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

167 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🍎 FruitFocus

Your guide to seasonal fruits and nutrients

A sophisticated fruit application that tracks seasonality and provides comprehensive nutritional information. FruitFocus estimates when fruits are in season by analyzing price history patterns from major Australian supermarkets (Woolworths and Coles), while offering detailed nutrient analysis to help you make informed dietary choices. Built with React (frontend) and Express.js with TypeScript (backend).

🌟 Core Features

  • Smart Seasonality Tracking: Advanced algorithm that estimates fruit seasonality by analyzing price patterns from Woolworths and Coles
  • Comprehensive Nutrient Database: Detailed nutritional information for all fruits including vitamins, minerals, and macronutrients
  • Nutrient-Based Search: Search fruits by specific nutrients to find the best sources for your dietary needs
  • Real-time Seasonality Updates: Daily automated seasonality calculations using cron jobs
  • Regional Availability: Track seasonal patterns across different Australian states
  • Interactive Map: Visual representation of fruit availability by state
  • Search & Filter: Find fruits by seasonality status, nutrients, or availability
  • Gaming Element: Interactive fruit-related game for engagement

🔬 How Seasonality Works

FruitFocus uses a sophisticated approach to determine fruit seasonality:

  1. Data Collection: Scrapes price history from Woolworths and Coles supermarket websites
  2. Price Analysis: Analyzes historical pricing patterns to identify seasonal price drops
  3. Threshold Calculation: Uses statistical methods to determine price thresholds that indicate "in-season" status
  4. Monthly Patterns: Identifies which months typically have lower prices (indicating peak seasonality)
  5. Cross-Store Validation: Ensures seasonality by checking both Woolworths and Coles to avoid false positives from single-store sales
  6. Real-time Updates: Daily automated updates ensure current seasonality information

Why Price Analysis? Fruit prices naturally decrease when fruits are in season (due to abundance) and increase when out of season (due to scarcity). By analyzing price history patterns, we can accurately estimate the actual growing seasons of fruits.

The seasonality algorithm categorizes fruits as:

  • 🟢 In Season (1): Currently at peak availability and typically lower prices
  • 🟡 Sort of In Season (0): Available but not at peak seasonality
  • 🔴 Not In Season (-1): Out of season, typically higher prices

🏗️ Project Structure

trainee-bard-24t2/
├── frontend/          # React + Vite frontend application
├── backend/           # Express.js + TypeScript API server
│   ├── src/util/
│   │   ├── seasonality.ts    # Main seasonality calculation logic
│   │   └── seasonal_price.py # Python script for price analysis
└── scraping/          # Data collection utilities for Woolworths/Coles
    └── src/
        ├── index.js   # Web scraping for fruit data
        ├── filter.js  # Data processing and filtering
        └── price.js   # Price history collection

🚀 Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • Python 3.x (for seasonality calculations)
  • Firebase (for data storage)

Installation & Setup

Head to backend and frontend folders to see detailed READMEs for specific setup instructions:

Backend Setup

Navigate to the backend/ folder and follow the README.md instructions for:

  • Installing npm dependencies
  • Setting up Python virtual environment for seasonality calculations
  • Configuring Firebase database
  • Running the Express.js server

Frontend Setup

Navigate to the frontend/ folder and follow the README.md instructions for:

  • Installing npm dependencies
  • Running the React development server
  • Accessing the application in your browser

🛠️ Tech Stack

Frontend

  • React 18 with TypeScript
  • Vite for fast development and building
  • React Router for navigation
  • Mantine UI for modern, accessible components
  • Recharts for data visualization
  • Axios for API communication

Backend

  • Express.js with TypeScript
  • Node.js runtime
  • Python for advanced price analysis and seasonality calculations
  • Firebase Firestore for data storage
  • CORS enabled for cross-origin requests
  • Cron jobs for daily seasonality updates
  • Puppeteer for web scraping (in scraping module)

Data Processing

  • Pandas for price history analysis
  • Statistical modeling for seasonality threshold calculation
  • Web scraping for real-time price data collection

📊 API Endpoints

The backend provides several RESTful endpoints:

  • /seasonal-fruits/:state - Get seasonal fruits by Australian state with current seasonality status
  • /nutrient/:name - Search fruits by nutrient content with filtering options
  • /fruit/ - Get detailed fruit nutrition information
  • /valid-search-terms/ - Get searchable fruit and nutrient terms
  • /getAllItems - Retrieve all available fruits

🎯 Use Cases

  • Health-conscious consumers: Find seasonal fruits rich in specific nutrients for optimal nutrition
  • Dietary planning: Search for fruits high in particular vitamins or minerals
  • Seasonal eating: Make informed decisions about fruit purchases based on seasonality
  • Nutritionists: Access detailed nutritional data for seasonal meal planning
  • Researchers: Analyze fruit seasonality patterns and nutritional content across Australia
  • Educators: Teach about seasonal eating, nutrition, and sustainable food choices

🔄 Data Pipeline

  1. Data Collection: Automated scraping of Woolworths and Coles fruit pages
  2. Price Processing: Historical price data analysis using Python statistical models
  3. Seasonality Calculation: Daily automated updates using cron jobs
  4. Nutrient Database: Comprehensive nutritional information for all fruits
  5. API Delivery: Real-time access to seasonality and nutritional data via RESTful endpoints
  6. Frontend Display: Interactive UI showing current seasonality status and nutritional information

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors