PROGRAMMING · TYPESCRIPT · NPM

Smart Agriculture

A TypeScript software foundation for precision farming: sensors, smart irrigation, drones and disease detection, published as an npm package.

smartAgriculture.ts
class IrrigationController {
    constructor(
        private sensor: Sensor,
        private weatherForecast: WeatherForecast,
        private irrigationSystem: IrrigationSystem
    ) {}

    decideIrrigation(sensorData: number): void {
        if (this.weatherForecast.checkWeatherForecast()) {
            console.log("Weather conditions are suitable for irrigation.");
            this.startIrrigation();
        } else {
            console.log("Irrigation not needed based on weather forecast.");
        }
    }
}
Program
Computer Programmer program · Lambton College
Year
2024
Team
With Julián Casilimas
Delivery
Public npm package · v1.0.1

// 01 · THE MISSION

The mission

Smart Agriculture proposes a software foundation to optimize farm production through technology and data. The system models the components of a smart farm—environmental sensors, weather forecasting, irrigation, surveillance drones and disease detection—plus a controller that combines sensor and weather data to decide when to irrigate. I built it with Julián Casilimas: we planned the work, documented the design decisions and published the result as an npm package so it can be installed and reused in other projects. Developed within the Computer Programmer program at Lambton College in Ontario, Canada, following professional standards for development, documentation and version control.

// WHAT WAS BUILT

Design principles

  • Encapsulation: each class exposes a clear interface
  • Abstraction of real-world field elements
  • Dependency injection in the irrigation controller
  • Decoupled components that are easy to extend

Teamwork

  • Task planning in Trello
  • Documentation of the object-oriented design decisions
  • README with installation and a usage example
  • Version control on GitHub

// ARCHITECTURE

The components of a smart farm

Each element of the field is a class with a single responsibility, so new sensors or technologies can be added without changing the rest of the system.

01

Sensor

Provides a standard interface to read the type, location and value of each measurement, such as soil moisture.

02

Weather forecast

Supplies the weather information that determines whether conditions are right for irrigation.

03

Irrigation controller

Combines sensor and weather data to decide whether to start the irrigation system.

04

Irrigation system

Runs irrigation when the controller says so.

05

Drones

Fly to areas of the field for surveillance and data collection.

06

Disease detector

Scans crops for possible plant diseases.

// RUN

The system in action

bash
$ npm install smart-agriculture
$ npm start

Sensor ID 2: Moisture at Field 5 reads value: 50
Checking weather forecast...
Weather conditions are suitable for irrigation.
Irrigation system started.
Drone Model X flying to Field 5
Disease Detector Detector Y is scanning for diseases...

Output of the sample program included in the package.

// PROCESS

How I did it

  1. 01

    Analysis

    Which elements make up a smart farm.

  2. 02

    Design

    One class per component and its relationships.

  3. 03

    Development

    Implementation in TypeScript.

  4. 04

    Documentation

    Design decisions and usage guide.

  5. 05

    Publishing

    Compiled and published on npm.

MISSION ACCOMPLISHED

Results and impact

Need a system tailored to your operation?

I design modular, documented, easy-to-maintain software that grows with your business.