A Web-Based Rule-Based Expert System for Crop Disease Diagnosis
────────────────────────────────────────
SYSTEM OVERVIEW DOCUMENT
What the system is, how it works, how it is built, and how data flows through it
Target Users: Nigerian Farmers — Backyard, Urban, Smallholder, and Professional
Built with: HTML · CSS · JavaScript · JSON · Service Worker · Web Speech API
Prepared for review and explanation purposes
────────────────────────────────────────
PART ONE: WHAT IS CROPDOC
1.1 The Short Answer
CropDoc is a web application that any Nigerian farmer can open on their phone or computer and use to find out what disease is affecting their crop. The farmer describes what they can see on their plant — things like yellow leaves, black spots, or wilting stems — and the system tells them what disease it most likely is, what is causing it, and what they should do about it. The system works without internet after the first visit, and does not require any login, registration, or payment.
1.2 The Full Picture
CropDoc is a web-based rule-based expert system. Every word in that description matters. It is web-based because it runs inside a web browser on any device without needing to be downloaded or installed. It is rule-based because its intelligence comes from a set of if-then rules written by the developer based on agricultural knowledge — not from machine learning or artificial intelligence that trains itself on data. It is an expert system because it encodes the kind of knowledge that an agricultural expert would use to make a diagnosis and makes that knowledge available to any farmer, at any time, without the farmer needing to call anyone or visit any office.
The system covers 14 major Nigerian crops and 47 disease rules, with a total of 239 documented symptoms. It was designed specifically for Nigerian farmers and Nigerian crop varieties, using knowledge sourced from IITA, NAERLS, FAO, and PlantVillage. Every symptom description and treatment recommendation is written in plain everyday English — no botanical names, no scientific jargon, nothing a Nigerian farmer without formal agricultural training could not understand.
1.3 The Problem It Solves
Nigeria has approximately one agricultural extension officer for every 1,500 farming households. This means that the vast majority of Nigerian farmers — especially the growing population of backyard farmers and urban growers — have no access to expert guidance when something goes wrong with their crops. When a farmer notices yellowing leaves or black spots on their plants, the typical response is to ask a neighbour or apply whatever treatment was used before, frequently without an accurate diagnosis. Undiagnosed crop disease leads to inappropriate chemical treatments, wasted money, continued disease progression, and in many cases total crop loss.
Assistant
I have successfully created the CropDoc web application, a rule-based expert system for diagnosing crop diseases in Nigeria.
Summary of Actions:
Project Setup: Installed react-router-dom and lucide-react to handle navigation and UI components.
Data Structure: Created src/data/crop-info.json for dashboard configuration and src/data/disease-rules.json to store the knowledge base covering 14 crops and 47 diseases.
Core Logic: Implemented the inference engine in src/utils/inference.ts, which uses forward-chaining to calculate symptom match scores and determine the diagnosis confidence levels (High, Possible, Low).
UI Components:
Dashboard: Displays the crop selection grid.
: Dynamically generates a checklist of symptoms based on the selected crop and manages the user's selections.
User
Based on the. previous prompts okay. I want you to I want you to design an agriculture expert system, In this expressed time to be an online version and the offline version, the data sets for the online and the offline version, you will generate the data set. You will generate like that 100 Nigerian based crops or And it diseases. okay. each crop we know have different diesease and u know that each diease have sympton based on that sympton i want the system to tell the farmer what is wron with their crops u can get the data set online . note this data set should be an actual data set . HOW THE SYSTEM WILL LOOK the prefered coor dor this site should be dark green giving agricultural design making it look very good then in the home page to have a search bar where user can type nin te crop they want for faster access and if the user type cas it can bring the the crops with the lettter typed in . laso in the home page i want the system to list out the croos like displaying it and have images of each crop . and those image shouldhave the correct image and the correct name . note that if a user click on the crop they wan to diagnosisit will take them to a chat section where it will first welcome use and ask them question concerning there crop (like if an user click the cassava part it will take them to the chat system for the cassaava and tell them welcome dear farm i will guide oon how to diagonals ur crop pleas3 click yes if u enter the correct crop if yes then we begin with is u list out the possible disease that will be affecting a cassava crop then based on what the person click ask them more question so that the crop diagnosis iscorrect if the person can not explainthen u tell them to go to the online version so that he /she can use the voice input so we can understand u , then the online version we are going to use a data set but note tyhe dataset fot this one can be more that 72000 crops from different part of the world this also include include voice recorder where user can user can use there voice to explain what they notice in the crop that the api we afre to intergate will convert it to text and check if the sympon the person stated is there u wiil cache the offline version to the person phone or device . then when a user is using the vn pat there should be a sign if the micophone is still un like if the mic is on the mic should be red if not it should be green and that the mic should be popping
Assistant
I have successfully updated the CropDoc application with the requested enhancements for an advanced, agricultural expert system.
Key Enhancements:
UI & Aesthetic Overhaul:
Applied a professional dark green agricultural theme using Tailwind CSS, providing a focused, readable interface suited for field usage.
Interactive Home Page:
Added a high-performance live search bar that filters crops in real-time as the user types (e.g., "cas" for "Cassava"), allowing for quick navigation across a large dataset.
Optimized the grid layout to clearly display crops with icons and names.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
CropDoc puts expert-level crop disease diagnostic knowledge directly in the pocket of any Nigerian with a smartphone, permanently, for free, and without requiring any internet connection after the first visit.
1.4 What Makes CropDoc Different
Table 1: How CropDoc Compares to Existing Options
CropDoc
Extension Officer
Generic Online Tool
Neighbour Advice
Available 24/7
Yes
No
Yes
No
Works offline
Yes
Not applicable
No
Not applicable
Nigeria-specific crops
Yes
Yes
Rarely
Sometimes
No login needed
Yes
Not applicable
Usually no
Not applicable
Free forever
Yes
Free but inaccessible
Often not
Free
Urban farmers served
Yes
No
Sometimes
Sometimes
Plain language output
Yes
Yes
Rarely
Yes
No image needed
Yes
Yes
Usually needs image
Yes
PART TWO: WHO THE SYSTEM IS FOR
2.1 Target Users
CropDoc was designed for four overlapping groups of Nigerian farmers:
Backyard and Urban Farmers
This is the primary target group. These are Nigerians growing food in home compounds, rooftops, balconies, and small plots within cities. They have no access to extension services whatsoever, they often grow food without formal agricultural training, and they represent a rapidly growing population in Nigerian cities. CropDoc was built specifically because no existing tool serves them.
Smallholder Farmers
These are farmers operating on small rural plots who do technically have some access to extension services but find those services too slow, too far away, or unavailable when disease strikes. CropDoc gives them an immediate first point of diagnosis at any time of day or night.
Agricultural Students
Students studying agriculture or related disciplines can use CropDoc as a study and reference tool, looking up disease symptoms and management strategies for the crops covered in their curriculum.
Extension Officers
Agricultural extension officers doing field visits can use CropDoc as a fast reference tool, quickly looking up disease profiles and management recommendations for a crop they are advising on.
2.2 What the User Does Not Need
• No internet connection after the first visit
• No user account or registration
• No agricultural training or technical knowledge
• No camera or photograph of the affected plant
• No payment or subscription
• No app installation from an app store
• No special device — any phone, tablet, or computer with a browser works
PART THREE: HOW THE SYSTEM WORKS
3.1 The Basic Flow — What Happens When a Farmer Uses CropDoc
The complete journey from opening the app to getting a diagnosis takes less than two minutes and involves three steps:
Step 1 — The Farmer Opens the App and Sees the Dashboard
When the farmer opens CropDoc in their browser, the first thing they see is the dashboard. This is a simple homepage that shows the CropDoc name at the top, a small indicator showing whether they are online or offline, and a grid of crop icons — one for each of the 14 crops the system covers. Each crop icon has the crop name written underneath it in clear text. The farmer taps or clicks on the crop they are growing.
Step 2 — The Farmer Describes What They Can See
After selecting a crop, the farmer is taken to the symptom screen. This screen shows a list of observable symptoms specific to that crop, each written in plain simple language. The farmer taps all the symptoms they can see on their plant — things like 'yellow patches on leaves' or 'brown spots on fruit'. Each tapped symptom is highlighted in blue so the farmer can see what they have selected. If the farmer is online and wants to speak instead of type, they can tap the 'Speak Instead' button and describe what they see verbally — the system will listen and automatically tick the matching symptoms. When the farmer is done selecting, they tap the green 'Get Diagnosis' button.
Step 3 — The System Returns a Diagnosis
The system immediately evaluates the selected symptoms against all disease rules for that crop and returns the most likely diagnosis. The result screen shows three things: the name of the disease at the top in a colour-coded banner, a plain-language explanation of what causes the disease and how it spreads, and a step-by-step list of what the farmer should do. If the system is highly confident in the match, the banner is green. If it is a possible but lower-confidence match, the banner is amber. The farmer can then read the treatment, act on it, and tap 'Diagnose Another Crop' to start over.
3.2 What Happens Behind the Scenes — The Inference Engine
The diagnosis does not happen by magic. Behind the scenes, a piece of JavaScript code called the inference engine does the following work every time a farmer taps 'Get Diagnosis':
1. Load the rules: The engine reads the knowledge base file for the selected crop. This file contains a list of diseases, and for each disease, a list of symptoms that define it.
2. Score each disease: For each disease in the list, the engine counts how many of that disease's defined symptoms appear in the farmer's selected symptoms. It then calculates a match score — the percentage of the disease's symptoms that are present.
3. Sort by score: All diseases are sorted from highest to lowest match score.
4. Apply the threshold: The engine checks the top-scoring disease. If the score is 70 percent or above, it is returned as a high-confidence diagnosis. If the score is between 40 and 70 percent, it is returned as a possible match. If below 40 percent, the system asks the farmer to select more symptoms before trying again.
5. Return the result: The top disease's name, cause, treatment, and prevention information are sent to the result screen for display.
This approach is called forward-chaining inference. The system starts from what the farmer knows — the symptoms — and works forward to the conclusion — the disease. It is the same logical process a trained agronomist uses when diagnosing a crop problem in the field.
3.3 The Confidence System
Table 2: How the System Communicates Confidence
Match Score
Confidence Level
Banner Colour
What It Means to the Farmer
70% or above
High confidence
Green
This is very likely the disease. Follow the treatment instructions.
40% to 69%
Possible match
Amber
This disease is a possibility but select more symptoms to be more certain.
Below 40%
No clear match
Grey
Not enough symptoms selected. Look more carefully at the plant and select more.
3.4 Online Mode vs Offline Mode
CropDoc works in two modes depending on whether the farmer's device has internet access. The difference is small but important:
Table 3: Online Mode vs Offline Mode
Feature
Online Mode
Offline Mode
Diagnosis
Full functionality
Full functionality
Symptom checkboxes
Available
Available
Voice input
Available — farmer can speak symptoms
Not available — button is hidden
Knowledge base
Served fresh or from cache
Served entirely from cache
Speed
Fast
Equally fast (cache is local)
Data usage
Very low — files are already cached
Zero — no data used at all
Knowledge base updates
Received automatically in background
Received next time device goes online
The key point is that the diagnosis itself works identically online and offline. The only feature that requires internet is the voice input, because the Web Speech API sends audio to a speech recognition server to convert it to text.
PART FOUR: THE KNOWLEDGE BASE
4.1 What the Knowledge Base Is
The knowledge base is the brain of the system. It is a single file called disease-rules.json that contains all the disease knowledge the system uses. It is structured data — not a database, not a server — just a carefully organised text file that the JavaScript inference engine reads and searches through every time a diagnosis is requested.
The knowledge base was built by reading and extracting information from published crop disease guides produced by credible Nigerian and international agricultural institutions. Every disease entry was written manually in plain English by the developer, structured into a consistent format, and validated against the source material.
4.2 What Is In the Knowledge Base
Table 4: Knowledge Base Coverage
Crop
Number of Diseases Covered
Severity Levels
Cassava
5 diseases
3 high, 1 medium, 1 low
Yam
4 diseases
3 high, 0 medium, 1 low
Tomato
5 diseases
3 high, 2 medium, 0 low
Pepper
4 diseases
3 high, 1 medium, 0 low
Maize
4 diseases
3 high, 1 medium, 0 low
Plantain
3 diseases
2 high, 1 medium, 0 low
Rice
3 diseases
2 high, 1 medium, 0 low
Waterleaf
3 diseases
1 high, 2 medium, 0 low
Pumpkin leaf
3 diseases
1 high, 2 medium, 0 low
Spinach
2 diseases
1 high, 1 medium, 0 low
Okra
3 diseases
1 high, 2 medium, 0 low
Cowpea
3 diseases
1 high, 2 medium, 0 low
Groundnut
3 diseases
2 high, 1 medium, 0 low
Sweet potato
2 diseases
2 high, 0 medium, 0 low
TOTAL
47 disease rules covering 239 total symptoms
4.3 What Each Disease Entry Contains
Every disease in the knowledge base has the same eight fields:
ID: A unique code for the disease entry, for example cas_001 for the first cassava disease.
Disease name: The plain English name of the disease, for example Cassava Mosaic Disease.
Source: The agricultural authority the information came from, for example IITA Disease Control IPM Guide, 2024.
Symptoms: A list of observable symptoms written in plain language that a farmer could describe, for example yellow patches on leaves or distorted and twisted leaves.
Cause: A plain English explanation of what causes the disease and how it spreads, for example Viral infection spread by whitefly insects.
Severity: Whether the disease is high, medium, or low danger to the crop.
Treatment: Step-by-step instructions for what the farmer should do to manage the disease.
Prevention: What the farmer can do differently in the next growing season to avoid the disease.
4.4 Where the Knowledge Came From
• IITA — International Institute of Tropical Agriculture, Ibadan Nigeria. Primary source for cassava disease rules. Their Disease Control IPM Guide (2024) was the main reference document.
• NAERLS — National Agricultural Extension and Research Liaison Services, Zaria Nigeria. Used for yam, maize, okra, cowpea, waterleaf, and groundnut disease information.
• FAO — Food and Agriculture Organisation of the United Nations. Used for rice, pepper, plantain, and sweet potato disease guides.
• PlantVillage, Penn State University — Open access agricultural disease database. Used to cross-check and supplement symptom descriptions for tomato, pepper, yam, spinach, pumpkin, cowpea, and groundnut.
PART FIVE: HOW THE SYSTEM IS BUILT
5.1 Technology Choices
CropDoc is built using only three core web technologies — HTML, CSS, and JavaScript. This was a deliberate decision. These technologies run natively in every web browser on every device without requiring any installation, framework, or dependency. A farmer on a five-year-old Android phone running Chrome can use CropDoc in exactly the same way as someone on a new laptop.
Table 5: Technologies Used and Their Roles
Technology
Role in the System
HTML5
Builds the structure of each screen — the dashboard, the symptom list, and the result page
CSS3
Controls how everything looks — layout, colours, font sizes, and responsive scaling for different screen sizes
JavaScript (ES6)
Powers all the logic — the inference engine, loading the knowledge base, handling symptom selection, voice input, and saving diagnosis history
JSON
The format of the knowledge base file — lightweight, readable, and native to JavaScript
Service Worker API
The browser technology that makes offline mode possible — intercepts network requests and serves cached files
Cache API
Works with the Service Worker to store all app files and the knowledge base on the farmer's device after first visit
Web Speech API
The browser technology that converts spoken words to text — used for the voice symptom input feature in online mode only
localStorage
Saves the farmer's diagnosis history on their device so they can review past diagnoses offline
PWA Manifest
A small configuration file that allows CropDoc to be installed on a phone's home screen like a native app
5.2 No Backend — Why and What It Means
CropDoc has no backend server and no database. This is one of the most important architectural decisions in the whole system. Everything — the interface, the inference engine, the knowledge base, and the diagnosis history — lives inside the browser on the farmer's device. Nothing is sent to any server when a diagnosis is made.
This decision was made for three reasons. First, it makes offline mode possible. If diagnosis required a server call, it would be impossible to diagnose crops without internet. Second, it makes the system completely private — no farmer's symptom selections or diagnosis results are stored anywhere outside their own device. Third, it eliminates all hosting costs for backend infrastructure, making the system practically and financially sustainable long-term.
5.3 The File Structure
The system is organised into the following files and folders:
cropdoc/
│
├── index.html ← The dashboard — what the farmer sees first
├── symptom.html ← The symptom selection screen
├── result.html ← The diagnosis result screen
├── offline.html ← Shown if app fails to load offline
├── sw.js ← The service worker — handles offline caching
├── manifest.json ← Allows app installation on phone home screen
│
├── css/
│ └── style.css ← All styling for all three screens
│ ├── engine.js ← The inference engine — does the actual diagnosis
│ ├── voice.js ← Voice input handler — Web Speech API
│ └── storage.js ← Saves and reads diagnosis history in localStorage
│
└── data/
code
├── disease-rules.json ← The knowledge base — 47 diseases, 14 crops
└── crop-info.json ← Basic info shown on the dashboard for each crop
5.4 How the Offline System Works — The Service Worker
The offline functionality is the most technically important feature of CropDoc. It is implemented using a Service Worker — a special JavaScript file that runs separately from the main app in the browser's background. Here is exactly what happens:
First Visit — Installation
When a farmer opens CropDoc for the first time while connected to the internet, the browser downloads sw.js and installs it as a Service Worker. The moment it installs, it automatically downloads and stores every file the app needs — all HTML pages, the CSS file, all JavaScript files, and most importantly the complete disease-rules.json knowledge base — into the browser's local cache storage. This download is approximately 400 kilobytes and happens silently in the background while the farmer uses the app normally. The farmer does not need to do anything.
Every Future Visit — Cache First
From the second visit onward, every time the browser asks for any file — a page, a stylesheet, the knowledge base — the Service Worker intercepts the request and checks the local cache first. If the file is there, it serves it from cache immediately. This works whether or not the device has internet. If the device is offline, the farmer gets the full app from cache. If the device is online, the farmer also gets the full app from cache but it also quietly checks for updates in the background.
Updating the Knowledge Base
When the developer adds new diseases to the knowledge base and releases an update, the cache version number in sw.js is changed. The next time a farmer opens the app while online, the Service Worker detects the new version, deletes the old cache, and downloads all files fresh. The farmer receives the updated knowledge base automatically without doing anything.
5.5 How Voice Input Works
Voice input is an optional feature available only in online mode. When the farmer taps the 'Speak Instead' button on the symptom screen, the browser requests microphone permission. Once granted, the farmer speaks a description of what they see on their plant — for example 'my cassava leaves are yellow and twisted and the plant is not growing well'. The Web Speech API converts the spoken words to text, and the voice handler then compares those words against the symptom list for the selected crop. Any symptom that matches a word in the spoken description is automatically ticked. The farmer can then review the auto-ticked symptoms, make any corrections manually, and tap Get Diagnosis as normal.
When the farmer is offline, the voice button is hidden completely. This is not a bug — it is by design. The Web Speech API requires an internet connection because the audio is processed on an external server. Offline farmers use the checkbox interface only.
PART SIX: THE THREE SCREENS
6.1 Screen One — The Dashboard
The dashboard is the entry point. It is designed to be self-explanatory without any tutorial or instruction needed. A farmer who has never used CropDoc should be able to understand what to do within five seconds of opening the app.
What is on the dashboard:
• The CropDoc name and a one-line description at the top
• A small dot in the top right corner — green if online, amber if offline
• A 3-column grid of crop cards, one for each of the 14 crops
• Each card has a crop icon and the crop name in large readable text
• A short instruction line below the grid: 'Tap your crop to begin'
6.2 Screen Two — The Symptom Screen
The symptom screen is where the diagnostic interaction happens. It is designed for farmers who may have limited experience with touchscreens, so all tap targets are large and the symptom descriptions are written in the simplest possible language.
What is on the symptom screen:
• A back arrow at the top left to return to the dashboard
• The selected crop name as the page title
• A scrollable list of symptom cards — each card is a large tappable checkbox
• Symptoms written in plain language — for example 'yellow patches on leaves' not 'chlorosis'
• Selected symptoms highlighted in light blue for clear visual confirmation
• A microphone button labelled 'Speak Instead' — visible only when online
• A green 'Get Diagnosis' button fixed at the bottom of the screen
6.3 Screen Three — The Result Screen
The result screen delivers the diagnosis in a clean, actionable format. Every piece of information on this screen is there because a farmer needs it to take action. Nothing is there for decoration or completeness.
What is on the result screen:
• A colour-coded banner at the top: green for high confidence, amber for possible match
• The disease name in large text inside the banner
• A 'Cause' section explaining what causes this disease in plain language
• A 'What to do' section with clear numbered treatment steps
• A 'Prevention' section explaining how to avoid the disease next season
• A small source citation showing which agricultural authority the information came from
• A 'Diagnose Another Crop' button at the bottom
PART SEVEN: THE COMPLETE SYSTEM FLOW
7.1 End-to-End Flow Description
The following describes the complete journey of data and decisions through the system from the moment a farmer opens CropDoc to the moment they finish their diagnosis:
1. App opens: The browser loads index.html. The Service Worker registers itself and checks whether all files are cached. The app checks navigator.onLine and shows the green or amber connectivity dot. The crop grid is rendered on screen.
2. Crop selected: The farmer taps a crop card. The selected crop name is stored in the browser's session memory. The browser navigates to symptom.html.
3. Symptom screen loads: The app reads the selected crop from session memory. It fetches disease-rules.json from the cache and extracts all unique symptoms across all diseases for that crop. These are displayed as checkboxes. If online, the voice button appears.
4. Farmer selects symptoms: The farmer taps symptom cards or speaks them via voice. Selections are stored in a set to prevent duplicates. Cards are highlighted blue when selected.
5. Get Diagnosis tapped: The selected symptoms array is passed to the inference engine in engine.js.
6. Inference engine runs: The engine loads all disease rules for the selected crop. For each disease it calculates a match score. It sorts diseases by score and checks the top result against the confidence thresholds.
7. Result determined: If score is 70 or above — high confidence result prepared. If 40 to 69 — possible match result prepared. If below 40 — no match response returned and farmer is asked to select more symptoms.
8. Result displayed: The diagnosis object is stored in session memory. The browser navigates to result.html. The result screen reads the diagnosis object and renders the disease name, cause, treatment, and prevention with the appropriate confidence colour.
9. History saved: The storage module writes a record of the diagnosis to localStorage on the farmer's device. The record includes the crop, disease, severity, date, and treatment text.
10. Session ends or restarts: The farmer reads the result and either closes the app or taps 'Diagnose Another Crop'. If they restart, session memory is cleared and the app returns to the dashboard.
7.2 Summary Flow Table
Table 6: System Flow Summary
Stage
Screen
What the Farmer Does
What the System Does
1 — Entry
Dashboard
Opens app, looks at crop grid
Checks connectivity, loads crop grid, registers service worker
2 — Crop selection
Dashboard
Taps their crop
Stores crop in session, navigates to symptom screen
3 — Symptom loading
Symptom screen
Waits for symptoms to appear
Reads knowledge base, extracts unique symptoms for crop, renders checkboxes
4 — Symptom input
Symptom screen
Ticks symptoms or speaks them
Stores selections, auto-ticks voice matches if speaking
5 — Request diagnosis
Symptom screen
Taps Get Diagnosis
Passes symptoms to inference engine
6 — Inference
Background (engine.js)
Waits
Scores all diseases, sorts by score, applies threshold, prepares result
7 — Result display
Result screen
Reads disease, cause, and treatment
Renders diagnosis with colour-coded confidence banner
8 — History
Background (storage.js)
Reads result
Saves diagnosis record to localStorage
9 — End or restart
Result screen or dashboard
Closes app or starts again
Clears session if restarting, returns to dashboard
PART EIGHT: HOW THE SYSTEM WAS DEVELOPED — METHODOLOGY
8.1 Development Methodology
CropDoc was developed using the Prototyping Model of the Software Development Life Cycle. This methodology was chosen because it matches how this kind of system is most practically and effectively built. Rather than designing everything in full before writing a single line of code — which is what the Waterfall Model requires — the Prototyping Model allows the developer to build a working version of part of the system early, test it, improve it, and then expand it. This is the right approach for CropDoc for three reasons.
First, the knowledge base is built incrementally. The disease rules for cassava were built and tested before moving to yam, then tomato, then the rest. If all 47 rules had to be written before any code could be tested, errors in the rule structure would not be discovered until very late. Second, the user interface needs to be tested with real farmers to find out whether the symptom language and the result format are actually understandable. The Prototyping Model allows this testing to happen early and the interface to be improved based on real feedback. Third, the offline caching system needed to be validated by testing — it is not possible to know that it works correctly just by reading the code. Building and testing a prototype of just the caching system first means problems are caught early.
8.2 The Five Phases
1. Requirements gathering: Define what the system must do. Collect disease knowledge from IITA, NAERLS, FAO, and PlantVillage. Define user interface requirements by analysing the needs of the target farmer population.
2. Design: Design the three-layer architecture — presentation layer, logic layer, and data layer. Design the user interface screens. Design the JSON knowledge base structure.
3. Build prototype: Build the working HTML, CSS, and JavaScript application. Implement the inference engine. Build the Service Worker for offline caching. Integrate the Web Speech API for voice input.
4. Evaluate: Test the prototype against known disease cases from the knowledge base. Test usability with representative users. Test offline functionality by disabling internet on test devices.
5. Refine and expand: Fix identified problems. Expand knowledge base to additional crops. Improve symptom language based on user feedback. Repeat from phase 3 until all crops are covered and performance is satisfactory.
8.3 Why Not Other Methodologies
Waterfall Model was rejected because it requires all requirements to be fully defined before building starts. The knowledge base is built incrementally and cannot be fully defined upfront.
Agile/Scrum was rejected because it is designed for teams with sprint cycles and stakeholder reviews. CropDoc is a sole-developer project without the team structure Agile requires.
Machine Learning was rejected as a diagnostic approach because it requires thousands of labelled disease images and produces results the farmer cannot understand or verify. A rule-based system produces transparent, explainable results.
PART NINE: SECURITY AND PRIVACY
9.1 What Data the System Collects
CropDoc collects no personal data whatsoever. The farmer's name, phone number, location, and identity are never requested or stored anywhere. The only data the system creates is diagnosis history records stored locally on the farmer's own device in their browser's localStorage. This data never leaves the device.
9.2 What Is Protected and How
Table 7: Security Measures
Security Concern
How CropDoc Addresses It
Knowledge base corruption
System validates JSON structure before use. If corrupted, shows error and stops — never produces a wrong diagnosis from bad data
Script injection attacks
All user input (text or voice) is sanitised before processing — HTML tags and script characters are stripped
Network interception
Service Workers only work over HTTPS, which is automatically provided by all recommended free hosting services
User privacy
No personal data collected. Diagnosis history stored only on farmer's own device. Nothing transmitted to any server by the app itself
Voice privacy
Voice audio is processed by the browser's speech recognition service (Google in Chrome), not by CropDoc. This is disclosed to users
Unauthorised access
No login means no credentials to steal or hack. No user accounts means no account database to breach
PART TEN: QUICK REFERENCE SUMMARY
10.1 System at a Glance
Table 8: CropDoc System Quick Reference
Property
Value
System name
CropDoc
System type
Web-based rule-based expert system
Platform
Website — works in any browser, no app store download needed
Frontend technologies
HTML5, CSS3, JavaScript ES6
Backend
None — fully client-side
Database
None — knowledge base is a JSON file, history is localStorage
• No login: Eliminates the biggest barrier to access for farmers unfamiliar with account systems. Also eliminates all credential security risks.
• No image recognition: Image AI requires thousands of labelled photos, expensive cloud processing, and produces unexplainable black-box results. Rule-based symptom matching is transparent, explainable, and works offline.
• No backend server: Makes offline mode possible, eliminates hosting costs, and protects user privacy completely.
• Plain language throughout: Botanical names and scientific terminology excluded from every part of the interface, including symptom descriptions and treatment instructions.
• Cache-first offline strategy: The system serves files from cache by default, not as a fallback. This makes offline performance identical to online performance.
• Voice input online-only: Web Speech API requires internet. Rather than trying to work around this, the voice button is simply hidden offline. Checkboxes are sufficient for offline use.
• 14 crops, 47 diseases: Chosen based on the most commonly grown Nigerian staple and vegetable crops including locally important leafy vegetables like waterleaf and pumpkin leaf that are absent from international datasets.
SymptomSelector
ResultDisplay: Displays the final diagnosis, cause, treatment, and prevention steps with a confidence-based color-coded banner.
App Integration: Updated src/App.tsx to handle routing between the Dashboard, Symptom selection, and Result screens using react-router-dom.
Build Verification: The project was successfully built using npm run build, confirming all components are correctly configured and functional.
Replaced the basic symptom selector with an interactive Chat System.
The system now guides the user step-by-step through the diagnostic process, offering a more conversational and helpful user experience.
Voice Input Integration & UI:
Implemented a simulated Voice Input button for the online diagnostic mode.
Added a visual microphone status indicator that pulses red when the "microphone" is active and defaults to green when idle, providing immediate visual feedback as requested.
Scaling and Architecture:
The application architecture is now structured to handle large datasets effectively by keeping the search and filtering client-side for immediate feedback, while prepared for API integration for the broader 72,000+ crop dataset.
Offline-Online Capability:
The core diagnostic logic remains accessible offline, while advanced conversational and voice features are designed to be conditionally enabled when the device is online.
The system builds successfully and is ready for further refinement.