Skip to content

pperetecnocampus/farm-s3-pperetecnocampus-propi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Farm Management System

Overview

Welcome to the Farm Management System project! This application is a Spring Boot REST API designed to manage fields and crops on a farm. It allows planting, watering, and harvesting crops while tracking their growth stages to maximize productivity.

This project follows a Layered Architecture, where each layer has a specific responsibility:

  • API Layer – Manages HTTP requests and responses.
  • Application Layer – Implements business logic.
  • Persistence Layer – Handles database access via JDBC.
  • DTOs – Transfers data between layers.
  • Domain Layer – Contains core business logic.

Crop Lifecycle

Crops go through growth stages depending on how often they are watered. Each crop category has its own optimal watering range.

Crop Type Ideal Watering NOT_READY MATURE EXPIRED
Vegetables 5 waterCount < 4 4 <= waterCount <= 6 waterCount > 6
Fruits 7 waterCount < 6 6 <= waterCount <= 8 waterCount > 8
Grains 9 waterCount < 8 8 <= waterCount <= 10 waterCount > 10

API Endpoints

Add Field

Method: POST
Endpoint: /fields

Request Body:

{
  "name": "Greenfield",
  "maxCrops": 10,
  "dimensions": 1500
}

Validation Rules: name must be at least 3 characters

maxCrops must be between 1 and 10

dimensions must be between 100 and 2000

Get All Fields

Method: GET
Endpoint: /fields

Query Parameters:

  • min_dimensions (optional)
  • max_dimensions (optional)

Returns a list of all fields with their associated crops.


Add Crop to Field

Method: POST
Endpoint: /fields/{fieldId}/crops

Request Body:

{
  "type": "vegetable"
}

Water Crops in Field

Method: POST Endpoint: /fields/{fieldId}/crops/waters

Waters all crops in the specified field by increasing their waterCount by 1. Returns the list of crops with updated status.

Get Crop Details

Method: GET Endpoint: /fields/{fieldId}/crops/{cropId}

Retrieves details of a specific crop, including:

Crop type

Planting date

Water count

Crop status (NOT_READY, MATURE, or EXPIRED)

###Harvest Crops Method: POST Endpoint: /fields/{fieldId}/crops/harvest

Harvests all crops that are in MATURE status.

Removes crops that are EXPIRED from the field.

Returns a list of harvested crops.

Rules: If no crops are mature, the system returns a 422 Unprocessable Entity error with a message indicating that no crops were harvested.

Get Field by ID

Method: GET
Endpoint: /fields/{fieldId}

Retrieves details of a specific field, including:

  • Field name
  • Dimensions
  • Maximum crop capacity
  • List of associated crops (with their IDs and types)

###Get All Crops in a Field Method: GET Endpoint: /fields/{fieldId}/crops

Retrieves a list of all crops planted in a specific field, including:

Crop ID

Type

Water count

Current status (NOT_READY, MATURE, EXPIRED)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages