Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/diarpicu2022-commits/backend-AgroPulse/llms.txt

Use this file to discover all available pages before exploring further.

The Crops API lets you define and track the crops cultivated in AgroPulse greenhouses. Each crop record captures the species, variety, optimal temperature and humidity ranges, soil moisture thresholds, planting date, and the crop’s current lifecycle stage. Lifecycle progression is modelled as an ordered state machine (SEEDING → GROWING → FLOWERING → HARVESTING → DORMANT), and the API exposes dedicated endpoints to advance a crop to the next stage and to clone an existing crop into a new cycle.
Crops are intended to be associated with a greenhouse in your application logic. While the crops table does not enforce a foreign key to greenhouses at the API level, sensor alert thresholds and IoT monitoring rules in AgroPulse are evaluated relative to the crop’s tempMin/tempMax, humidityMin/humidityMax, and soilMoistureMin/soilMoistureMax fields.

Crop lifecycle stages

The currentStage field is an enum with the following ordered values:
StageDescription
SEEDINGGermination / initial sowing — the default stage for a new crop.
GROWINGVegetative growth phase.
FLOWERINGFlowering and pollination phase.
HARVESTINGActive harvest phase.
DORMANTOff-season rest or dormancy period.
Use POST /api/crops/{id}/advance to move a crop forward to the next stage in this sequence.
Returns every crop in the system, regardless of active status.Response — array of crop objects.
id
integer
Unique crop identifier.
name
string
Crop name (e.g. "Tomate").
variety
string
Cultivar or variety (e.g. "Cherry").
tempMin
number
Minimum optimal temperature in °C.
tempMax
number
Maximum optimal temperature in °C.
humidityMin
number
Minimum optimal relative humidity in %.
humidityMax
number
Maximum optimal relative humidity in %.
soilMoistureMin
number
Minimum optimal soil moisture in %.
soilMoistureMax
number
Maximum optimal soil moisture in %.
plantingDate
string
ISO-8601 date of sowing (e.g. "2024-03-01"). Defaults to today.
currentStage
string
Current lifecycle stage enum value. Defaults to SEEDING.
active
boolean
Whether this crop is currently active. Defaults to true.
curl http://localhost:8080/api/crops
[
  {
    "id": 1,
    "name": "Tomate",
    "variety": "Cherry",
    "tempMin": 18.0,
    "tempMax": 28.0,
    "humidityMin": 60.0,
    "humidityMax": 80.0,
    "soilMoistureMin": 40.0,
    "soilMoistureMax": 70.0,
    "plantingDate": "2024-03-01",
    "currentStage": "GROWING",
    "active": true
  }
]
Returns only crops where active is true.
curl http://localhost:8080/api/crops/active
[
  {
    "id": 1,
    "name": "Tomate",
    "variety": "Cherry",
    "tempMin": 18.0,
    "tempMax": 28.0,
    "humidityMin": 60.0,
    "humidityMax": 80.0,
    "soilMoistureMin": 40.0,
    "soilMoistureMax": 70.0,
    "plantingDate": "2024-03-01",
    "currentStage": "GROWING",
    "active": true
  }
]
Returns a single crop by its numeric ID.Path parameters
id
integer
required
The crop ID.
Returns 404 Not Found when no crop with that ID exists.
curl http://localhost:8080/api/crops/1
{
  "id": 1,
  "name": "Tomate",
  "variety": "Cherry",
  "tempMin": 18.0,
  "tempMax": 28.0,
  "humidityMin": 60.0,
  "humidityMax": 80.0,
  "soilMoistureMin": 40.0,
  "soilMoistureMax": 70.0,
  "plantingDate": "2024-03-01",
  "currentStage": "GROWING",
  "active": true
}
Creates a new crop record. The currentStage defaults to SEEDING and plantingDate defaults to today when omitted.Request body
name
string
required
Crop name (e.g. "Pepino", "Lechuga").
variety
string
Cultivar or variety name (e.g. "Romana", "Hothouse").
tempMin
number
Minimum optimal temperature in °C.
tempMax
number
Maximum optimal temperature in °C.
humidityMin
number
Minimum optimal relative air humidity in %.
humidityMax
number
Maximum optimal relative air humidity in %.
soilMoistureMin
number
Minimum optimal soil moisture in %.
soilMoistureMax
number
Maximum optimal soil moisture in %.
plantingDate
string
ISO-8601 date of sowing (e.g. "2024-04-15"). Defaults to the current date.
currentStage
string
Initial lifecycle stage. One of SEEDING, GROWING, FLOWERING, HARVESTING, DORMANT. Defaults to SEEDING.
active
boolean
Whether the crop is active. Defaults to true.
Response — the created crop object.
curl -X POST http://localhost:8080/api/crops \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pepino",
    "variety": "Hothouse",
    "tempMin": 20.0,
    "tempMax": 30.0,
    "humidityMin": 65.0,
    "humidityMax": 85.0,
    "soilMoistureMin": 50.0,
    "soilMoistureMax": 75.0
  }'
{
  "id": 4,
  "name": "Pepino",
  "variety": "Hothouse",
  "tempMin": 20.0,
  "tempMax": 30.0,
  "humidityMin": 65.0,
  "humidityMax": 85.0,
  "soilMoistureMin": 50.0,
  "soilMoistureMax": 75.0,
  "plantingDate": "2024-05-20",
  "currentStage": "SEEDING",
  "active": true
}
Replaces a crop record with the provided body. The id from the path takes precedence — any id in the request body is overwritten.Path parameters
id
integer
required
The crop ID to update.
Request body — same fields as POST /api/crops. All fields are optional; omitted fields retain their existing values as managed by the service layer.Response — the updated crop object.
curl -X PUT http://localhost:8080/api/crops/4 \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pepino",
    "variety": "Hothouse",
    "tempMin": 20.0,
    "tempMax": 30.0,
    "humidityMin": 65.0,
    "humidityMax": 85.0,
    "soilMoistureMin": 50.0,
    "soilMoistureMax": 75.0,
    "currentStage": "GROWING",
    "active": true
  }'
{
  "id": 4,
  "name": "Pepino",
  "variety": "Hothouse",
  "tempMin": 20.0,
  "tempMax": 30.0,
  "humidityMin": 65.0,
  "humidityMax": 85.0,
  "soilMoistureMin": 50.0,
  "soilMoistureMax": 75.0,
  "plantingDate": "2024-05-20",
  "currentStage": "GROWING",
  "active": true
}
Permanently deletes a crop record.Path parameters
id
integer
required
The crop ID to delete.
Returns 204 No Content on success with an empty body.
curl -X DELETE http://localhost:8080/api/crops/4
Advances the crop’s currentStage to the next value in the sequence: SEEDING → GROWING → FLOWERING → HARVESTING → DORMANT.Path parameters
id
integer
required
The crop ID to advance.
Response — the updated crop object with the new currentStage.
If the crop is already in the final stage (DORMANT), the behavior is determined by the CropService implementation. Inspect the service for the exact boundary condition handling.
curl -X POST http://localhost:8080/api/crops/1/advance
{
  "id": 1,
  "name": "Tomate",
  "variety": "Cherry",
  "tempMin": 18.0,
  "tempMax": 28.0,
  "humidityMin": 60.0,
  "humidityMax": 80.0,
  "soilMoistureMin": 40.0,
  "soilMoistureMax": 70.0,
  "plantingDate": "2024-03-01",
  "currentStage": "FLOWERING",
  "active": true
}
Creates a copy of an existing crop using the Prototype pattern. The clone resets the planting date to today and the stage to SEEDING, preserving all environmental threshold settings from the original.Path parameters
id
integer
required
The ID of the crop to clone.
Response — the newly created crop object (new id, plantingDate = today, currentStage = SEEDING).
curl -X POST http://localhost:8080/api/crops/1/clone
{
  "id": 7,
  "name": "Tomate",
  "variety": "Cherry",
  "tempMin": 18.0,
  "tempMax": 28.0,
  "humidityMin": 60.0,
  "humidityMax": 80.0,
  "soilMoistureMin": 40.0,
  "soilMoistureMax": 70.0,
  "plantingDate": "2024-05-20",
  "currentStage": "SEEDING",
  "active": true
}

Build docs developers (and LLMs) love