Skip to content
OnlyProjects
BCA · AI & Machine LearningFor educational purposes only
Code included

Soil-Test-Based Crop Advisory System for Small Farmers (Python, scikit-learn, MySQL)

Turn a Soil Health Card into an explained, district-specific crop recommendation a small farmer can act on

Mapped to your syllabusIGNOU BCA (revised) — BCSP-064 guidelines · BCSP-064 Project · Semester 6

Overview

1 min read

Soil-Test-Based Crop Advisory System is an individual BCA project that converts the numbers on a farmer's Soil Health Card into a specific, explained crop recommendation for the farmer's own district.

Under the Soil Health Card scheme (launched February 2015), every farm holding in India is tested for twelve parameters — available nitrogen, phosphorus and potassium, sulphur, five micronutrients, plus pH, electrical conductivity and organic carbon. The card tells a farmer the status of the soil, but turning that status into "what should I sow this kharif?" still depends on a rushed conversation at the extension centre. This system closes that loop: an extension officer enters the card's readings along with the farmer's village, land size and preferred season, and a decision-tree classifier trained on published crop-suitability ranges (as followed by ICAR's Krishi Vigyan Kendra network) recommends crops for the district — in this build, Tumakuru, Karnataka — ranked with a confidence score.

The differentiator is explainability. The system does not stop at "groundnut, 87%"; it shows the matched conditions — "pH 6.4, medium phosphorus, 640 mm normal rainfall" — as plain IF-THEN rules extracted from the trained tree, so the officer can read the reasoning aloud and a farmer can accept or reject it.

The application is built with Python, Flask and MySQL — all within the IGNOU BCA (revised) permitted stack — with scikit-learn for the model. It deliberately stays at beginner scope: one district, one classifier, one clean web workflow, but every part is complete and defensible.

Relevant for
All India
Level
Beginner · 12 weeks · solo
Common at
Indira Gandhi National Open University, University of Madras, University of Kerala
Updated
Nov 2026

Syllabus alignment

IGNOU · BCA (revised) — BCSP-064 guidelines

BCSP-064 · Project · Semester 6 · 8 credits · 200 = report 150 + viva 50 (≥40% each)

Subjects this project applies
  • Python Programming
  • Database Management with MySQL
  • Web Technologies (HTML/CSS/JavaScript)
  • Statistics and Data Analysis fundamentals
How it is evaluated

Team: individual only

synopsis with DFD (≥ level 2), ER/class diagrams; 50–80-page hardbound report (±10%); test cases; security section. Prohibited: C/C++ for DB projects, VB + MS-Access, dBase/FoxPro. Plagiarism → Exam Discipline Committee

Also fits: BCU SEP 2024, University of Madras CBCS 2023-24, Kerala University FYUGP 2024.

What's in the box

11 parts · 5 free · 2 previewed · 4 unlock for ₹2,000

Problem & synopsis

5 min read

Problem statement

A farmer's Soil Health Card reports twelve soil parameters, but crop choice is still decided by habit, neighbours or fertiliser-shop salesmen. KVK extension officers can give scientifically grounded crop advice, but they are few, the reasoning is unrecorded, and the same question must be answered one farmer at a time. Generic crop-advisory apps apply national-scale rules that ignore district soil and rainfall reality and give no reason for their suggestions, so farmers rightly distrust them.

What is needed is a small, auditable system for a single extension centre that (a) records the card's readings and the farmer's context, (b) recommends crops consistent with the district's published suitability ranges, (c) shows why each crop was suggested in IF-THEN language the officer can verify, and (d) keeps a history so follow-up is possible. The design must not collect government ID numbers — farmers are referenced by registration number only.

Synopsis

Abstract

This project designs and implements a crop-advisory web application that maps Soil Health Card readings to district-specific crop recommendations with human-readable justification. A decision-tree classifier is trained on a suitability dataset constructed from published ICAR/KVK crop-suitability ranges for Tumakuru district (ragi, groundnut, pigeonpea, maize, sunflower and allied crops), using soil pH, organic carbon, N-P-K ratings, normal rainfall and season as inputs. The trained tree is exported as IF-THEN rules that the advisory screen displays next to every recommendation, and the system records each advisory for follow-up by the extension centre. The stack is Python, Flask, MySQL and scikit-learn.

Introduction

A small farmer holding one to two hectares makes a sowing decision every season with little information. The Soil Health Card scheme has tested most holdings in the country and returns a card of twelve soil parameters with fertiliser dosages — but the card does not answer the question the farmer actually asks: "given my soil, what crop should I grow this season?" Krishi Vigyan Kendras, ICAR's district-level farm science centres, answer it with field experience and published suitability tables. This project digitises that reasoning so a single extension officer can serve more farmers in less time, without inventing advice.

Existing System

  • The official Soil Health Card portal delivers test results and fertiliser recommendations, not crop choice.
  • KVK officers give crop advisories verbally or on notice boards; the reasoning lives in experienced heads and printed tables.
  • Generic mobile apps recommend crops nationally, often ignoring district reality — a crop unsuitable for 600 mm red-soil Tumakuru can appear next to a canal-irrigated suggestion with no explanation.
  • Limitations: advice is unrecorded, non-reproducible, cannot be audited, and is unavailable when the officer is not present.

Proposed System

  • Structured entry of Soil Health Card values (N, P, K, pH, organic carbon), village, holding size and season, with range validation at the form level.
  • A decision-tree advisory model trained on the district suitability dataset, compared against k-NN and naive Bayes baselines with k-fold cross-validation.
  • Rule extraction — the chosen tree is exported as IF-THEN conditions shown beside every recommendation, keeping the officer in charge of the decision.
  • A district crop knowledge base in MySQL holding each crop's suitable pH band, nutrient class, rainfall band and sowing window, editable by the admin as new varieties are released.
  • Advisory history per farmer with a follow-up flag, so the centre can call back and record what was actually sown.

Feasibility Study

  • Technical: every component is free and documented — Flask, MySQL and scikit-learn; the model is a decision tree, trainable on a laptop in seconds; the app works on a low-end phone browser.
  • Economic: zero licence cost; hosting on a ₹200/month VPS or entirely offline within the centre's LAN.
  • Operational: the workflow mirrors what officers already do (read card → check tables → advise), so training takes minutes; explanations in local-language-ready text build the trust that a black-box score never would.

Objectives

  1. 01Model the Soil Health Card workflow: register a farmer, enter the card's soil parameters with validation, and store the test against the farmer's holding.
  2. 02Build a district crop knowledge base in MySQL capturing suitable pH band, nutrient class, rainfall band and sowing window for each crop in the chosen district.
  3. 03Construct and document a training dataset from published ICAR/KVK suitability ranges, and train a decision-tree classifier on it.
  4. 04Evaluate the model with k-fold cross-validation and compare it against k-NN and naive Bayes baselines using accuracy, per-class precision and recall.
  5. 05Extract the trained tree as human-readable IF-THEN rules and display them beside every recommendation for officer verification.
  6. 06Record every advisory issued, with a follow-up flag, so the centre can audit advice quality season after season.
  7. 07Implement the security measures IGNOU's guidelines expect: hashed passwords, parameterised queries, session protection and an audit log.

Scope

In scope

  • One extension centre, one district (Tumakuru as the bundled example), one admin/officer role pair.
  • Entry of the Soil Health Card's farmer-relevant parameters: N, P, K, pH, organic carbon; plus village, holding size and season.
  • Decision-tree crop recommendation with k-NN and naive Bayes baselines, cross-validated.
  • Rule display, printable advisory card, farmer-wise advisory history and follow-up flags.
  • Admin screens to edit the crop knowledge base and manage officer accounts.

Out of scope (v1)

  • Fertiliser dosage calculation (the SHC portal already provides it) and pesticide advisories.
  • Weather-based dynamic advisories, market-price integration and yield prediction.
  • Multi-district or multi-language deployment (the text layer is kept translation-ready, but only English ships).
  • Mobile apps, SMS gateways and offline-first sync.
  • Any collection of Aadhaar or other government ID numbers — by design, never stored.

Methodology

The project follows the Incremental SDLC model over twelve weeks, chosen so that a working vertical slice (enter soil test → see an advisory) exists from week 4 and every later increment only deepens it. Each increment closes with a tested, demonstrable build, which matches how a single student can keep the project always presentable.

PhaseWeeksActivitiesDeliverable
Requirement analysis1–2Study the Soil Health Card format and KVK advisory practice; list functional and non-functional requirementsSRS with use cases
Design3ER diagram, DFDs to level 2, schema, wireframes, class structureDesign document
Data construction4–5Compile district suitability ranges from published ICAR/KVK tables; build and document the training dataset; exploratory checksDocumented dataset
Increment 16–7Flask app skeleton, farmer and soil-test modules, MySQL schema liveWorking data entry
Increment 28–9Train tree + baselines, cross-validate, extract rules, wire the advisory engine into the appAdvisory engine
Increment 310Advisory history, printable card, admin screens, security hardeningComplete system
Testing11Unit and integration tests, UAT with two sample farmers' cards, security checklistTest report
Documentation12Report (50–80 pages per BCSP-064), diagrams, screenshots, viva rehearsalFinal submission

Architecture & tech stack

3 diagrams · 5 technologies · 2 min read

  • Python
  • Flask
  • MySQL
  • scikit-learn
  • HTML/CSS/JavaScript

The application is a classic three-tier web architecture, deliberately conventional so every layer can be explained in the viva:

  1. Presentation tier — server-rendered Jinja templates with a thin JavaScript layer for form validation; pages are mobile-friendly because officers work from phones.
  2. Application tier — Flask blueprints (farmers, soil tests, advisory, admin); the advisory engine calls the persisted scikit-learn model, then maps the prediction to the knowledge base and extracts matching rules.
  3. Data tier — MySQL holds users, farmers, soil tests, crops, advisories and the audit log; all model input is validated before it touches SQL, and every query uses parameterised statements.
flowchart TD
  O(["Extension officer"]) -->|"HTTPS login"| A["Flask app"]
  A --> F["Farmer & soil-test forms"]
  F -->|"validated values"| E["Advisory engine"]
  E -->|"feature vector"| M["scikit-learn decision tree"]
  M -->|"crop + confidence"| R["Rule extractor"]
  E --> KB[("MySQL: crops knowledge base")]
  R --> OUT["Advisory card with IF-THEN reasons"]
  F --> DB[("MySQL: farmers, tests, advisories")]
  A --> L["Audit log"]
  OUT --> O

ER diagram

erDiagram
  USER ||--o{ ADVISORY : issues
  FARMER ||--o{ SOIL_TEST : "provides samples for"
  SOIL_TEST ||--o{ ADVISORY : "generates"
  CROP ||--o{ ADVISORY : "is recommended in"
  USER ||--o{ AUDIT_LOG : "is recorded in"

  USER {
    int user_id PK
    string username UK
    string password_hash
    string role
  }
  FARMER {
    int farmer_id PK
    string reg_no UK
    string name
    string village
    decimal holding_ha
    string phone
  }
  SOIL_TEST {
    int test_id PK
    int farmer_id FK
    date card_date
    decimal n_kg_ha
    decimal p_kg_ha
    decimal k_kg_ha
    decimal ph
    decimal oc_percent
    string season
  }
  CROP {
    int crop_id PK
    string crop_name
    decimal ph_min
    decimal ph_max
    string rainfall_band
    string sowing_window
  }
  ADVISORY {
    int advisory_id PK
    int test_id FK
    int crop_id FK
    int user_id FK
    decimal confidence
    string rules_shown
    boolean follow_up_needed
    datetime issued_at
  }
  AUDIT_LOG {
    int log_id PK
    int user_id FK
    string action
    datetime at_time
  }

DFD to level 2 (as required in the BCSP-064 synopsis)

flowchart TB
  O(["Extension officer"]) --> P1["1.0 Manage farmer records"]
  P1 <--> D1[("D1 Farmers")]
  O --> P2["2.0 Record soil test"]
  P2 <--> D1
  P2 <--> D2[("D2 Soil tests")]
  P2 --> P3["3.0 Generate advisory"]
  P3 --> P31["3.1 Rate nutrients & pH"]
  P31 --> P32["3.2 Match crops from knowledge base"]
  P32 <--> D3[("D3 Crops")]
  P32 --> P33["3.3 Rank, extract rules, format"]
  P33 <--> D4[("D4 Advisories")]
  P33 -->|"card + reasons"| O

Key design decisions: the advisory is stored with the exact rule text shown to the officer, so any past advice can be replayed and audited; nutrient rating (low/medium/high) is computed once and stored to keep the model input and the human explanation consistent; and the crops table, not the model, is the source of agronomic truth — the model only ranks candidates the knowledge base already considers possible.

Modules

5 modules

  1. Module 01

    Farmer Registration & Soil Test Entry

    Registers a farmer with a centre-issued registration number (no government IDs by design), village and holding size, then records Soil Health Card parameters — N, P, K, pH, organic carbon, season — with client-side and server-side range validation against the card's official units.

  2. Module 02

    District Crop Knowledge Base

    MySQL-backed catalogue of the district's crops with suitable pH band, nutrient classes, normal rainfall band and sowing window, seeded from published ICAR/KVK suitability tables for Tumakuru and editable through admin screens as new varieties or recommendations are released.

  3. Module 03

    Advisory Engine (Decision Tree + Rule Extraction)

    Loads the persisted scikit-learn decision tree, converts the soil test into a feature vector, ranks candidate crops with confidence scores, and walks the tree to emit the IF-THEN conditions actually used — for example 'pH 5.5–6.5 AND medium K AND rainfall 500–700 mm' — displayed beside each recommendation.

  4. Module 04

    Advisory Output & History

    Renders a printable advisory card (recommended crops, matched conditions, sowing window), stores every advisory with the rules shown and a follow-up flag, and provides a farmer-wise history view so the centre can record what was actually sown and compare it with the recommendation.

  5. Module 05

    Administration & Security

    Role-based accounts (admin, officer) with Werkzeug-hashed passwords, server-side session checks on every route, parameterised SQL throughout, CSRF-protected forms and an audit log of logins and advisories — forming the explicit security section the BCSP-064 report requires.

Slides

12 slides · titles free · bullets, notes and the .pptx unlock

  1. Slide 1

    Soil-Test-Based Crop Advisory System

  2. Slide 2

    Introduction

  3. Slide 3

    Problem Statement

  4. Slide 4

    Existing vs Proposed System

  5. Slide 5

    Objectives

  6. Slide 6

    Dataset & District Context

  7. Slide 7

    Technology Stack

  8. Slide 8

    System Architecture & ER

  9. Slide 9

    DFD to Level 2

  10. Slide 10

    Demo

  11. Slide 11

    Testing & Security

  12. Slide 12

    Conclusion & Future Scope

Bullets, speaker notes and the .pptx · ₹2,000

The titles above are the real outline. The rest is what you present from.

Unlock for ₹2,000

Viva questions & answers

3 of 15 answered free · 12 unlock

Read each answer, close it, and say it in your own words. Your viva will ask. Now you'll know.

  1. 01Concept

    Why did you choose a decision tree over other classifiers for crop advice?

    Because the output must be explainable to an extension officer and ultimately a farmer. A decision tree translates directly into IF-THEN conditions on soil parameters, which I extract and display with every recommendation. A random forest would score better but averages away a single readable rule path, and naive Bayes or k-NN give no sentence a human can verify against the suitability tables.

  2. 02Concept

    Your training data is derived from published tables, not field measurements. Is that valid?

    Yes, and it is a deliberate design decision. The knowledge base encodes ICAR and KVK-published suitability ranges for the district's crops, so the model learns agronomically vetted relationships rather than possibly noisy field samples. The tree's job is to recover those ranges as executable, ranked rules; field outcomes recorded later become the retraining data that improves it season by season.

  3. 03Concept

    Explain k-fold cross-validation and why you used it on a small dataset.

    K-fold splits the data into k parts, trains on k−1 and validates on the remaining part, rotating so every row is validated exactly once, and averages the scores. With a small derived dataset, a single train-test split would make accuracy depend on which rows landed in the test set. Cross-validation gives a more stable estimate and uses every row for both training and validation.

+12 more questions, with answers

Try the free ones out loud first. Your examiner will not accept “it's in the PPT”.

Source code & how to run

8 steps · complete source code · unlocks with the project

Unlocks with the project · ₹2,000

8 steps · source code zip

Prerequisites, install, seed data and tests, written for demo day. Plus the complete source.

Unlock for ₹2,000

READMEFIRST

272 words · unlocks with the project

What to change before it goes anywhere near a submission. Skipping it is how the demo fails live.

Unlocks with the project · ₹2,000

272 words · ~1 min read

The checklist of things to rename, re-seed and re-think so the project reads as yours.

Unlock for ₹2,000

Instructions

370 words · unlocks with the project

How to study it, adapt it and walk your examiner through it, step by step.

Unlocks with the project · ₹2,000

370 words · ~2 min read

Report structure, formatting rules and the submission checklist your department will grade.

Unlock for ₹2,000

References

8 sources

  1. Soil Health Card Scheme — official portal, Department of Agriculture & Farmers Welfare
  2. ICAR — Krishi Vigyan Kendras (district-level farm science centres)
  3. IGNOU BCSP-064 Project Guidelines (official PDF)
  4. scikit-learn Documentation — Decision Trees and model evaluation
  5. MySQL 8.0 Reference Manual
  6. Flask Documentation
  7. OWASP Password Storage Cheat Sheet
  8. Gareth James, Daniela Witten, Trevor Hastie, Robert Tibshirani, An Introduction to Statistical Learning, Springer

Cite this bundle

OnlyProjects. (2026). Soil-Test-Based Crop Advisory System for Small Farmers (Python, scikit-learn, MySQL): BCA AI & Machine Learning project bundle [Educational resource]. https://onlyprojects.online/projects/bca-aiml-soil-test-crop-advisory

Future scope

1 min read

  • Multi-district and multi-language deployment with translated advisory text and per-district knowledge bases.
  • Yield and fertiliser additions — extend the knowledge base from crop choice to expected yield bands and SHC-linked fertiliser verification.
  • SMS/IVR advisory so farmers without smartphones receive the recommendation and can query it by voice in their language.
  • Seasonal learning loop — record actual sowing and harvest outcomes to retrain the tree on real field results instead of published ranges alone.
  • Price-aware ranking — blend suitability with Minimum Support Price and local mandi trends so the top recommendation is also economically sensible.

Keep browsing

Same degree, same syllabus slot, different idea. Pick the one your guide will actually approve.

BCACode included

Web Development

Smart Hostel Management System

Room allocation, complaints and mess billing without the register

  • Next.js
  • TypeScript
  • Node.js
  • +3

intermediate8 wk2 students