51 Commits

Author SHA1 Message Date
notkshitij e1a47b0af4 Added warning in readme. Do not push to backend branch from now on. 2025-06-20 23:56:15 +05:30
notkshitij 23f9a25184 Added a single line description to readme and updated heading. 2025-06-20 22:16:22 +05:30
notkshitij da96ae89a2 Removed package.json from root dir. 2025-06-20 22:15:03 +05:30
notkshitij f201486b8f Removed package lock from Backend directory and added the file to gitignore to avoid future commits of that file since it's not req. 2025-06-20 22:14:32 +05:30
notkshitij 01e8845328 Merged Salvi's changes made to Backend/ from the frontend branch. dk why he pushed them to frontend branch in the first place -_- 2025-06-20 22:13:21 +05:30
KaranSalvi 0f8aa521a9 feat:Create Ai model routes for prediction 2025-02-23 09:12:00 +05:30
notkshitij bd0daf45bd Removed unused folders such as node_modules, frontend, and files package-lock. Also modified readme. 2025-02-23 09:00:01 +05:30
KaranSalvi ddbf340af7 feat: Add Ai for prediction 2025-02-23 08:21:00 +05:30
notkshitij b84468441c Merged Salvi's backend changes in this branch first for testing so that Salvi can go and sleep. 2025-02-23 02:52:03 +05:30
notkshitij f92534f814 Merged Bhakti's changes with Omabase's changes. 2025-02-23 02:50:37 +05:30
notkshitij a6b604f04f Merging Salvi's backend with frontend branch for testing. 2025-02-23 02:01:36 +05:30
atharvaombase cbff64906b Fix:Replaced 'class' with 'className' in many files 2025-02-23 00:52:53 +05:30
atharvaombase 27955fc264 Feat:Added a form for new crops 2025-02-23 00:52:19 +05:30
atharvaombase ee59400d76 Feat:Created AddCrop component for adding more crops in a perticular Farm 2025-02-23 00:29:13 +05:30
atharvaombase 88d229cb2d Fix:Implemented AddCrop component 2025-02-23 00:28:20 +05:30
atharvaombase 79a29ad982 Fix:Added the well structured table 2025-02-23 00:27:11 +05:30
atharvaombase e98b39a9da Feat:Added loading text to be replaced with animation after 2025-02-23 00:26:27 +05:30
Bhakti f41d33625f Added animations to Landing page 2025-02-22 23:58:22 +05:30
atharvaombase ae9108769c Feat:Added the page to display the data of the farm using dynamic routing 2025-02-22 23:56:05 +05:30
atharvaombase 6d0813c8db Fix:Added new Field content Size of land 2025-02-22 23:54:56 +05:30
atharvaombase 1c7c9425bc Feat:Added a table for farm data on FarmPage 2025-02-22 23:54:14 +05:30
atharvaombase 341a3a127b Feat:Added new input Field for Size of Land 2025-02-22 23:53:13 +05:30
atharvaombase 66a6ac22d0 Fix: Added dynamic Routing For OnClick 2025-02-22 23:52:21 +05:30
atharvaombase 466d0b7abe Fix:Removed uneccesary useNavigate 2025-02-22 23:50:58 +05:30
atharvaombase 07d691ad4e Feat:Added new rout for the FarmPage.jsx(Dynamic routing) 2025-02-22 23:49:48 +05:30
atharvaombase 89af132577 Added Dynamic routing on the table name 2025-02-22 23:49:05 +05:30
atharvaombase 762e246ccd Fix:Corrected files structure 2025-02-22 22:41:24 +05:30
atharvaombase ddf28d9a46 Fix: Moved to Farm Folder 2025-02-22 22:38:33 +05:30
atharvaombase 586fd41133 Fix:Corrected the imports for the Farm Folder 2025-02-22 22:37:36 +05:30
atharvaombase 982fbba413 Fix:Made fully functional by fetching the data from backend 2025-02-22 22:36:01 +05:30
atharvaombase b805b8e34e Fix:Kept the original Navbar 2025-02-22 20:57:30 +05:30
Bhakti 956fb5604a added type writer effect and resolved visibility issue 2025-02-22 20:30:28 +05:30
atharvaombase 6dc57b28b1 Merged backend from Salvi 2025-02-22 20:19:36 +05:30
atharvaombase fdee1beb05 Added add farm option in dashboard and created add farm model. 2025-02-22 20:01:52 +05:30
Bhakti 58cd02b3a5 Glassmorphism added to all parts of landing page 2025-02-22 19:25:24 +05:30
atharvaombase bf03fa12f6 feat:Added forms to add,update,delete the farm 2025-02-22 19:16:35 +05:30
atharvaombase c41d788328 feat:Added glass navbar and Dashboard components 2025-02-22 18:48:07 +05:30
Bhakti d5086e21ae converting all parts to glassmorphism 2025-02-22 18:42:03 +05:30
Bhakti 355f13b33d glassmorphism Navbar, bg photo for glassmorphism 2025-02-22 18:41:11 +05:30
Bhakti 68f3efc128 changed website's name in index.html, working on landing page 2025-02-22 17:34:21 +05:30
Bhakti 8db0eeba9a Added images/ logos 2025-02-22 17:33:04 +05:30
atharvaombase 439dbe51b6 fix:Chagned the navbar to default 2025-02-22 17:07:49 +05:30
atharvaombase 8ad01a5c50 feat:1.Added logo 2.changed color palet 2025-02-22 16:47:37 +05:30
atharvaombase d9c299a58f feat:Added total spent card and Removed some typos 2025-02-22 16:01:56 +05:30
atharvaombase f7cb1af2c4 feat:Added piechart in Dashboard 2025-02-22 15:35:48 +05:30
notkshitij 8438a9a2b7 Fix: Merged main.jsx changes from ombase's branch to bhakti's branch. 2025-02-22 13:29:49 +05:30
atharvaombase 357071b967 fix:main.jsx routing structure changed 2025-02-22 13:21:41 +05:30
notkshitij 75f31b5b93 Added frontend folder structure in Ombase's branch 2025-02-22 13:00:33 +05:30
KaranSalvi 15593af2a9 Added frontend folder structure. 2025-02-22 12:54:00 +05:30
notkshitij 33b5c9ccc8 Added Ombase's name in README file for his branch. 2025-02-22 12:52:15 +05:30
notkshitij 8f13ac6d4b Added Bhakti's name in README for her branch. 2025-02-22 12:50:21 +05:30
8 changed files with 184 additions and 4841 deletions
+1
View File
@@ -0,0 +1 @@
Backend/package-lock.json
+60
View File
@@ -1,6 +1,7 @@
const Crop = require("../Models/crop.model.js");
const Farm = require("../Models/farm.model.js");
const { uploadOnCloudinary } = require("../Utils/cloudinary.js");
const { run } = require("../Utils/model.js");
// Create a new crop
const createCrop = async (req, res) => {
@@ -145,6 +146,61 @@ const updateHealthStatus = async (req, res) => {
}
};
const cropHarvest = async (req, res) => {
try {
const crop = await Crop.findById(req.params.cropId).populate("farm");
console.log(crop);
const message = `My crop is ${crop.name}, given that I have planted it on ${crop.plantedDate}, suggest me a date as to when it will be harvested. Give output in the form: ${crop.name} will take .. months to harvest around (give month name and year).`; // for harvest expectation
const result = await run(message);
res.status(200).json({ message: result });
} catch (error) {
res.status(500).json({ message: error.message });
}
};
const suggestNextCrop = async (req, res) => {
try {
const crop = await Crop.findById(req.params.cropId).populate("farm");
console.log(crop);
const message = `Currently I have ${crop.name} in my field. Considering the best optimal time for its harvestation give my location, ${crop.farm.location} and water content of my field is ${crop.farm.waterContent}. Suggest next crop I should grow and give more suggestions around it. Don't tell me when to harvest ${crop.name}, only tell me next best crop to plant in my field and give suggestions around it.`; // for next sowing suggestion
const result = await run(message);
res.status(200).json({ message: result });
} catch (error) {
res.status(500).json({ message: error.message });
}
};
const suggestPesticides = async (req, res) => {
try {
const crop = await Crop.findById(req.params.cropId).populate("farm");
console.log(crop);
const message = `Considering I have grown ${crop.name} in my field located in ${crop.farm.location} and has water content of ${crop.farm.waterContent}. Suggest pesticides I should use on the crop and when to use it considering my sow date is ${crop.sowDate}. Give precautionary measures and suggestions around it.`; // for pesticides
const result = await run(message);
res.status(200).json({ message: result });
} catch (error) {
res.status(500).json({ message: error.message });
}
};
const suggestFertilizers = async (req, res) => {
try {
const crop = await Crop.findById(req.params.cropId).populate("farm");
console.log(crop);
const message = `Considering I have grown ${crop.name} in my field located in ${crop.farm.location} and has water content of ${crop.farm.waterContent}. Suggest fertilizers I should use on the crop and when to use it, i.e. after how many months after sowing considering sowing date is ${crop.sowDate} considering my sow date is ${crop.sowDate}. Give me precautionary measures.`; // for fertilizers
const result = await run(message);
res.status(200).json({ message: result });
} catch (error) {
res.status(500).json({ message: error.message });
}
};
module.exports = {
createCrop,
@@ -154,4 +210,8 @@ module.exports = {
deleteCrop,
updateGrowthStage,
updateHealthStatus,
cropHarvest,
suggestNextCrop,
suggestPesticides,
suggestFertilizers,
};
+1 -1
View File
@@ -2,7 +2,7 @@ const multer = require("multer");
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, "./public/images");
cb(null, "./uploads");
},
filename: function (req, file, cb) {
+9
View File
@@ -7,6 +7,10 @@ const {
deleteCrop,
updateHealthStatus,
updateGrowthStage,
cropHarvest,
suggestNextCrop,
suggestPesticides,
suggestFertilizers,
} = require("../Controllers/crop.controller.js");
const { checkAuthenticated } = require("../Middlewares/authentication.js");
const upload = require("../Middlewares/multer.js");
@@ -22,4 +26,9 @@ router.delete("/:cropId", checkAuthenticated, deleteCrop); // Delete a crop
router.put("/health/:cropId", checkAuthenticated, updateHealthStatus);
router.put("/growth/:cropId", checkAuthenticated, updateGrowthStage);
router.get("/harvest/:cropId", checkAuthenticated, cropHarvest);
router.get("/nextCrop/:cropId", checkAuthenticated, suggestNextCrop);
router.get("/pesticides/:cropId", checkAuthenticated, suggestPesticides);
router.get("/fertilizers/:cropId", checkAuthenticated, suggestFertilizers);
module.exports = router;
+99
View File
@@ -272,6 +272,88 @@
// console.log(result.response.text());
// }
// const {
// GoogleGenerativeAI,
// HarmCategory,
// HarmBlockThreshold,
// } = require("@google/generative-ai");
// const apiKey = "AIzaSyDsXug23r4umgcJpj77KeqNyYW0hQnYDgg";
// const genAI = new GoogleGenerativeAI(apiKey);
// const model = genAI.getGenerativeModel({
// model: "gemini-2.0-flash",
// });
// const generationConfig = {
// temperature: 1,
// topP: 0.95,
// topK: 40,
// maxOutputTokens: 8192,
// responseMimeType: "text/plain",
// };
// async function run(message) {
// const chatSession = model.startChat({
// generationConfig,
// history: [
// {
// role: "user",
// parts: [
// {
// text: "AI Guidelines:\n- The AI must only provide answers related to farming, including crops, sowing, irrigation, harvesting, fertilizers, pesticides, soil health, and climate conditions. \n- The AI must not answer anything outside farming. \n- If asked an unrelated question, the AI must not respond. \n- If the query is unclear, the AI must default to farming-related guidance. \n- The AI must provide only one-line responses without extra details. \n- No harmful, hurtful, or controversial responses. \n- No advice on illegal, unsafe, or unethical farming practices.\n",
// },
// ],
// },
// {
// role: "model",
// parts: [
// {
// text: "Understood. I will only provide one-line responses directly related to farming.\n",
// },
// ],
// },
// {
// role: "user",
// parts: [
// {
// text: "you can also receive json or javascript object as an input ",
// },
// ],
// },
// {
// role: "model",
// parts: [
// {
// text: "Understood. I will process the JSON or JavaScript object only if it pertains to farming and respond with a single line.\n",
// },
// ],
// },
// {
// role: "user",
// parts: [
// {
// text: "Answer everything which falls under the farming and agriculture even if the prompt does not include any farm or agriculture word in it",
// },
// ],
// },
// {
// role: "model",
// parts: [
// {
// text: "Understood. I will assume all queries are related to farming and provide a one-line farming-related response.\n",
// },
// ],
// },
// ],
// });
// const result = await chatSession.sendMessage(message);
// console.log(result.response.text());
// return result.response.text();
// }
const {
GoogleGenerativeAI,
HarmCategory,
@@ -345,11 +427,28 @@ async function run(message) {
},
],
},
{
role: "user",
parts: [
{
text: "Give me a percise answer no matter what, dont give useless or incomplete answer \n",
},
],
},
{
role: "model",
parts: [
{
text: "Understood. I will strive to provide precise and complete one-line farming-related answers.\n",
},
],
},
],
});
const result = await chatSession.sendMessage(message);
console.log(result.response.text());
return result.response.text();
}
module.exports = { run };
-4823
View File
File diff suppressed because it is too large Load Diff
+11 -14
View File
@@ -10,23 +10,20 @@
"license": "ISC",
"description": "",
"dependencies": {
"@google/generative-ai": "^0.22.0",
"@huggingface/transformers": "^3.3.3",
"@xenova/transformers": "^2.17.2",
"bcrypt": "^5.1.1",
"cloudinary": "^2.5.1",
"cookie-parser": "^1.4.6",
"@google/generative-ai": "^0.24.1",
"bcrypt": "^6.0.0",
"cloudinary": "^2.7.0",
"cookie-parser": "^1.4.7",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"jimp": "^1.6.0",
"dotenv": "^16.5.0",
"express": "^5.1.0",
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.6.1",
"multer": "^1.4.5-lts.1",
"nodemailer": "^6.9.15",
"socket.io": "^4.7.5"
"mongoose": "^8.16.0",
"multer": "^2.0.1",
"nodemailer": "^7.0.3",
"socket.io": "^4.8.1"
},
"devDependencies": {
"nodemon": "^3.1.4"
"nodemon": "^3.1.10"
}
}
+3 -3
View File
@@ -1,7 +1,7 @@
# Status200
# CropCompass
Karan's branch for backend developement.
This branch houses backend code developed and maintained by Karan Salvi for this project.
---
⚠️⚠️ DO NOT PUSH TO THIS BRANCH, IT HAS BEEN LOCKED. IT WAS DIFFICULT TO KEEP A TRACK OF ALL THE CHANGES BEING MADE TO DIFFERENT BRANCHES. TO SIMPLIFY THINGS, CREATE A NEW FEATURE BRANCH DERIVED FROM `main` BRANCH AND CREATE A PULL REQUEST. ⚠️⚠️