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.

Every monitored site in AgroPulse is represented as a greenhouse. A greenhouse acts as the top-level container for sensors, actuators, automation rules, and alert recipients. Once a greenhouse exists, sensors can be attached to it and users can be granted access to view or manage it.
Only the greenhouse owner (ownerId) or a user with the ADMIN role can update or delete a greenhouse, or modify its user membership. Regular users who have been assigned access can read data but cannot change greenhouse settings.

Greenhouse fields

FieldTypeRequiredDescription
namestringyesHuman-readable greenhouse name
locationstringnoPhysical address or site description
descriptionstringnoFree-text notes about the greenhouse
ownerIdintegernoUser ID of the greenhouse owner
activebooleannoWhether the greenhouse is currently operational (default true)
latitudenumbernoGPS latitude for map display
longitudenumbernoGPS longitude for map display
photoUrlstringnoURL to a representative photo

Full setup workflow

1

Create the greenhouse

Send a POST to /api/greenhouses with at minimum a name. Include ownerId to assign ownership immediately.
curl -s -X POST http://localhost:8080/api/greenhouses \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Greenhouse Alpha",
    "location": "Farm North, Block 3",
    "description": "Primary tomato cultivation greenhouse",
    "ownerId": 1,
    "active": true,
    "latitude": 40.7128,
    "longitude": -74.0060,
    "photoUrl": "https://example.com/photos/gh-alpha.jpg"
  }'
The response returns the created greenhouse object including its assigned id (e.g. 3). Use this ID in all subsequent requests.
2

Register sensors

Add sensors to the greenhouse by posting to /api/sensors. Each sensor must reference the greenhouseId returned in the previous step.
curl -s -X POST http://localhost:8080/api/sensors \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Canopy Temperature",
    "type": "TEMPERATURE_INTERNAL",
    "greenhouseId": 3,
    "gpioPin": 4,
    "protocol": "DHT22",
    "location": "Roof center",
    "deviceSource": "esp32-abc123",
    "active": true
  }'
List all sensors for the greenhouse at any time:
curl "http://localhost:8080/api/greenhouses"
curl "http://localhost:8080/api/sensors?greenhouseId=3"
3

Assign users

Grant a user access to the greenhouse by posting their userId to the greenhouse’s users sub-resource.
curl -s -X POST http://localhost:8080/api/greenhouses/3/users \
  -H "Content-Type: application/json" \
  -d '{"userId": 12}'
A successful response returns {"assigned": true}. The user is now listed when you GET /api/greenhouses/3/users.
4

Verify the setup

Fetch the complete user list for the greenhouse to confirm the assignment:
curl "http://localhost:8080/api/greenhouses/3/users"
The response includes full user objects: id, username, email, role, and active state.

Updating a greenhouse

Send a PUT to /api/greenhouses/{id} with only the fields you want to change. Fields not included in the request body are left unchanged.
curl -s -X PUT http://localhost:8080/api/greenhouses/3 \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Switched to pepper cultivation",
    "active": true
  }'

Removing user access

# Remove user 12 from greenhouse 3
curl -s -X DELETE http://localhost:8080/api/greenhouses/3/users/12
Response: {"removed": true}

Deleting a greenhouse

curl -s -X DELETE http://localhost:8080/api/greenhouses/3
Deleting a greenhouse removes the greenhouse record. Ensure you remove or reassign dependent sensors, actuators, and rules beforehand to avoid orphaned records.

Build docs developers (and LLMs) love