Skip to content

Farm2City #3

Open
kaustubh-2007 wants to merge 16 commits into
Sky-walkerX:mainfrom
kaustubh-2007:main
Open

Farm2City #3
kaustubh-2007 wants to merge 16 commits into
Sky-walkerX:mainfrom
kaustubh-2007:main

Conversation

@kaustubh-2007
Copy link
Copy Markdown

This PR enhances the Farm2City – Direct Farmer Marketplace by integrating Machine Learning features and improving overall functionality using FastAPI and React.

The goal is to transform the platform from a basic marketplace into an AI-powered intelligent system that provides data-driven insights and better user experience.

@kaustubh-2007 kaustubh-2007 marked this pull request as ready for review April 9, 2026 19:17
Copilot AI review requested due to automatic review settings April 9, 2026 19:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR turns the repository into a Vite + React application with a FastAPI backend that exposes ML-powered endpoints for price prediction, crop recommendations, and a simple chatbot, and wires those features into the farmer dashboard and a floating AI chatbot UI.

Changes:

  • Added a React (Vite) frontend with marketplace, product details, cart, login, profile, farmer dashboard, and chat pages.
  • Added a FastAPI backend exposing /predict-price, /recommend-crop, and /chat, plus utilities/training code for sklearn models.
  • Added mock data, styling, and static assets to support the UI.

Reviewed changes

Copilot reviewed 30 out of 52 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
vite.config.js Adds Vite configuration with React plugin.
teams/.gitkeep Keeps teams/ directory in git.
SUB.md Removes the prior submission guide documentation.
.gitignore Adds ignores for Node/Vite artifacts (missing Python/ML artifacts ignores).
package.json Defines frontend dependencies (React, router, axios, lucide) and scripts.
eslint.config.js Adds ESLint flat config for React + hooks + refresh.
index.html Adds Vite entry HTML for the React app.
public/icons.svg Adds SVG symbol sprite used by the app/site.
public/favicon.svg Adds favicon asset.
src/main.jsx Boots the React app with BrowserRouter.
src/App.jsx Defines routes, top-level cart/user state, and mounts AIChatbot.
src/index.css Adds global styling, glassmorphism utilities, and animations.
src/data/mockData.js Provides mock product catalog and hero image used by UI pages.
src/components/Navbar.jsx Adds primary navigation with role-aware dashboard link and cart badge.
src/components/ProductCard.jsx Adds product card component used by the marketplace grid.
src/components/AIChatbot.jsx Adds floating chatbot UI that calls backend /chat.
src/pages/Home.jsx Adds landing page hero + feature cards.
src/pages/Login.jsx Adds mock role-based login flow (buyer vs farmer) and redirects.
src/pages/Marketplace.jsx Adds marketplace search/filter UI over mock product data.
src/pages/ProductDetails.jsx Adds product detail view and add-to-cart interaction.
src/pages/Cart.jsx Adds cart UI, quantity updates, and mock checkout success state.
src/pages/Profile.jsx Adds profile page with mock order history.
src/pages/Chat.jsx Adds mock buyer–farmer negotiation chat UI.
src/pages/Dashboard.jsx Adds farmer dashboard with AI price prediction + crop recommendation calls.
backend/requirements.txt Adds Python dependencies for FastAPI + sklearn pipeline (has a leading blank line).
backend/main.py Implements FastAPI app with CORS, ML endpoints, and chatbot endpoint.
backend/pycache/main.cpython-314.pyc Adds compiled Python bytecode (should not be committed).
backend/ml/init.py Declares the ml package.
backend/ml/model.py Implements singleton model loader + prediction/recommendation + chatbot intent logic.
backend/ml/utils.py Generates synthetic datasets for training (price + recommendation).
backend/ml/train.py Trains and writes sklearn models/encoders to disk via joblib.
backend/ml/price_data.csv Adds generated synthetic training dataset (large).
backend/ml/rec_data.csv Adds generated synthetic training dataset.
backend/ml/models/rec_model.joblib Adds serialized sklearn model artifact.
backend/ml/models/le_crop.joblib Adds serialized label encoder artifact.
backend/ml/models/le_rec.joblib Adds serialized label encoder artifact.
backend/ml/models/le_season.joblib Adds serialized label encoder artifact.
backend/ml/models/le_soil.joblib Adds serialized label encoder artifact.
backend/ml/pycache/init.cpython-314.pyc Adds compiled Python bytecode (should not be committed).
backend/ml/pycache/model.cpython-314.pyc Adds compiled Python bytecode (should not be committed).
backend/ml/pycache/train.cpython-314.pyc Adds compiled Python bytecode (should not be committed).
backend/ml/pycache/utils.cpython-314.pyc Adds compiled Python bytecode (should not be committed).
README.md Replaces repository README with the default Vite template content.
readme2.md Adds a project README-style document for Farm2City (currently mismatched with repo layout/endpoints).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/main.py
Comment on lines +19 to +25
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CORS is configured with allow_origins=["*"] while allow_credentials=true. This effectively allows any origin to send credentialed requests and is unsafe for anything beyond local dev (and can also cause CORS header issues). Consider restricting allow_origins to the known frontend origin(s) (e.g., from an env var) and/or setting allow_credentials=false for wildcard origins.

Copilot uses AI. Check for mistakes.
Comment thread src/pages/Profile.jsx
@@ -0,0 +1,96 @@
import { User, MapPin, Phone, Package, Calendar, LogOut } from 'lucide-react'
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogOut is imported but never used, which will fail the configured ESLint no-unused-vars rule. Remove the unused import (or use it in the UI).

Copilot uses AI. Check for mistakes.
Comment thread src/pages/Chat.jsx
Comment on lines +35 to +39
<div style={{ padding: '1rem', borderBottom: '1px solid var(--glass-border)', background: 'rgba(255,255,255,0.05)', cursor: 'pointer' }}>
<div style={{ fontWeight: 600, marginBottom: '0.25rem' }}>Green Valley Farm</div>
<div style={{ fontSize: '0.85rem', color: 'var(--text-secondary)', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
Sure, I can do $22 for 10 lbs...
</div>
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contact preview text uses "$" and "lbs" while the rest of the chat uses "₹" and "kg". This inconsistency will look like a pricing/unit bug in the UI—use the same currency and units throughout (or derive them from locale settings).

Copilot uses AI. Check for mistakes.
Comment thread src/pages/Dashboard.jsx
import axios from 'axios'
import { products } from '../data/mockData'

const API = 'http://localhost:8000'
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend base URL is hardcoded to http://localhost:8000, which will break in preview/production deployments. Use a Vite env var (e.g., import.meta.env.VITE_API_URL) with a sensible default and document it.

Copilot uses AI. Check for mistakes.
import { MessageCircle, X, Send, Bot } from 'lucide-react'
import axios from 'axios'

const API = 'http://localhost:8000'
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend base URL is hardcoded to http://localhost:8000, which will break in preview/production deployments. Use a Vite env var (e.g., import.meta.env.VITE_API_URL) with a sensible default and document it.

Copilot uses AI. Check for mistakes.
Comment thread backend/ml/rec_data.csv
Comment on lines +1 to +3
soil,season,recommended_crop
laterite,summer,Cashew
laterite,monsoon,Rubber
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like generated synthetic training data. Since generate_rec_data() can recreate it, consider removing this file from version control and generating it during training/build (or store it externally if it must be versioned).

Copilot uses AI. Check for mistakes.
Comment thread backend/requirements.txt
Comment on lines +1 to +2

fastapi
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a leading blank line in requirements.txt which can confuse tooling and makes diffs noisy. Remove the empty first line so the file starts with the first dependency.

Copilot uses AI. Check for mistakes.
Comment thread README.md
Comment on lines +1 to 6
# React + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

**[Register Here →](https://forms.gle/yrQVjSU84b2Wk47Q8)**
Currently, two official plugins are available:

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md still contains the default Vite template text and doesn't describe Farm2City or how to run the frontend/backend together. Consider replacing it with the project documentation (or moving the current readme2.md content into README.md and linking to the ML API setup/env vars).

Copilot uses AI. Check for mistakes.
Comment thread readme2.md
Comment on lines +128 to +171
## 📁 Project Structure

```
farm2city/
├── frontend/ (React)
│ ├── src/
│ ├── components/
│ ├── pages/
│ └── App.js
├── backend/ (FastAPI)
│ ├── main.py
│ ├── routes/
│ ├── models/
│ ├── ml/
│ │ ├── train.py
│ │ ├── model.pkl
│ │ └── utils.py
└── README.md
```

---

## ⚙️ Installation & Setup

### 🔹 Backend (FastAPI)

```bash
cd backend
pip install -r requirements.txt
uvicorn main:app --reload
```

---

### 🔹 Frontend (React)

```bash
cd frontend
npm install
npm start
```
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documented project structure and frontend run steps don't match the current repo layout: there is no frontend/ directory, and the scripts are Vite-based (npm run dev, npm run build, etc.). Update this section to reflect the actual paths and commands.

Copilot uses AI. Check for mistakes.
Comment thread readme2.md
Comment on lines +175 to +202
## 🔗 API Endpoints

### Auth

* `POST /signup`
* `POST /login`

### Products

* `GET /products`
* `POST /products`
* `PUT /products/{id}`
* `DELETE /products/{id}`

### ML APIs

* `GET /predict-price`
* `GET /recommend-crop`

### Orders

* `POST /orders`
* `GET /orders`

### Chatbot

* `POST /chat`

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API endpoint list documents auth/products/orders routes that aren't implemented in backend/main.py (currently only /, /predict-price, /recommend-crop, /chat). Please remove or update the endpoints section to avoid misleading users.

Copilot uses AI. Check for mistakes.
Abhishek-Dige pushed a commit to Abhishek-Dige/DevStakesComp that referenced this pull request Apr 9, 2026
Added Routing, Functionality to Create Story button, Redesigned Footer
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.

4 participants