Skip to main content

Documentation Index

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

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

The AgroPulse frontend communicates exclusively with the REST backend configured via VITE_API_URL (default http://localhost:8080). Every request is made through BaseRepository in src/core/ApiService.ts, which automatically injects authentication headers and handles JSON serialisation. This page lists every endpoint used by the frontend, grouped by resource.

Authentication

All requests include the following headers when a user context is set via setUserContext():
HeaderTypeDescription
X-User-IdstringID of the currently authenticated user. Present on all requests after login.
X-Admin-EmailstringEmail of the user, included only when the user holds an admin role. Required by admin-only endpoints.
Headers are injected automatically by ApiService.ts. You do not set them manually in application code unless you need a one-off override via options.headers.

Base URL

http://localhost:8080
Override at build time or runtime by setting VITE_API_URL in your environment. See Environment variables.

Endpoints by resource

GET /api/greenhousesReturns all greenhouses the authenticated user has access to.
greenhouses
GreenhouseDto[]
required
List of greenhouse objects.

GET /api/greenhouses/:idReturns a single greenhouse by ID.
path.id
number
required
Greenhouse ID.
(root)
GreenhouseDto
required
The greenhouse object.

POST /api/greenhousesCreates a new greenhouse.
body.name
string
required
Display name.
body.location
string
Human-readable location.
body.description
string
Optional description.
body.deviceId
string
ESP32 device identifier to link.
body.latitude
number
GPS latitude.
body.longitude
number
GPS longitude.
body.photoUrl
string
Supabase photo URL.
(root)
GreenhouseDto
required
The created greenhouse.

PUT /api/greenhouses/:idUpdates an existing greenhouse (full or partial fields).
path.id
number
required
Greenhouse ID.
Body accepts any subset of GreenhouseDto fields.
(root)
GreenhouseDto
required
The updated greenhouse.

DELETE /api/greenhouses/:idDeletes a greenhouse.
path.id
number
required
Greenhouse ID.
Returns 204 No Content.
GET /api/greenhouses/:id/usersLists users assigned to a greenhouse.
path.id
number
required
Greenhouse ID.
users
UserDto[]
required
List of user objects.

POST /api/greenhouses/:id/usersAssigns a user to a greenhouse.
path.id
number
required
Greenhouse ID.
body.userId
number
required
ID of the user to assign.
Returns 204 No Content.
DELETE /api/greenhouses/:id/users/:userIdRemoves a user from a greenhouse.
path.id
number
required
Greenhouse ID.
path.userId
number
required
User ID to remove.
Returns 204 No Content.
GET /api/greenhouses/:id/alert-recipientsLists alert recipients for a greenhouse.
path.id
number
required
Greenhouse ID.
recipients
AlertRecipient[]
required
List of recipient objects.

POST /api/greenhouses/:id/alert-recipientsAdds an alert recipient to a greenhouse.
path.id
number
required
Greenhouse ID.
body.name
string
required
Recipient display name.
body.email
string
Email address for notifications.
body.phone
string
Phone number for SMS.
body.callmebotApikey
string
CallMeBot API key for WhatsApp/Telegram.
(root)
AlertRecipient
required
The created recipient.

DELETE /api/greenhouses/:id/alert-recipients/:recipientIdRemoves an alert recipient.
path.id
number
required
Greenhouse ID.
path.recipientId
number
required
Recipient ID to remove.
Returns 204 No Content.
GET /api/sensorsReturns all sensors, optionally filtered by greenhouse.
query.greenhouseId
number
Filter sensors belonging to this greenhouse.
sensors
SensorDto[]
required
List of sensor objects.

GET /api/sensors/:idReturns a single sensor by ID.
path.id
number
required
Sensor ID.
(root)
SensorDto
required
The sensor object.

POST /api/sensorsCreates a sensor.
body.name
string
required
Sensor display name.
body.type
SensorType
required
Measurement type.
body.protocol
Protocol
Hardware protocol.
body.gpioPin
number
GPIO pin on the ESP32.
body.greenhouseId
number
Parent greenhouse.
(root)
SensorDto
required
The created sensor.

PUT /api/sensors/:idUpdates a sensor.
path.id
number
required
Sensor ID.
Body accepts any subset of SensorDto fields.
DELETE /api/sensors/:idDeletes a sensor.
path.id
number
required
Sensor ID.
Returns 204 No Content.
GET /api/sensors/:id/thresholdReturns the anomaly threshold configuration for a sensor.
path.id
number
required
Sensor ID.
(root)
SensorThresholdDto
required
Threshold configuration object.

PUT /api/sensors/:id/thresholdCreates or updates the threshold for a sensor.
path.id
number
required
Sensor ID.
body.minValue
number
Minimum acceptable value.
body.maxValue
number
Maximum acceptable value.
body.noDataMinutes
number
required
No-data alert window in minutes.
body.stuckMinutes
number
required
Stuck-sensor alert window in minutes.
body.spikePercent
number
required
Spike detection threshold percentage.
(root)
SensorThresholdDto
required
Updated threshold object.

DELETE /api/sensors/:id/thresholdRemoves the threshold configuration for a sensor.
path.id
number
required
Sensor ID.
Returns 204 No Content.
GET /api/actuatorsReturns all actuators, optionally filtered by greenhouse.
query.greenhouseId
number
Filter actuators belonging to this greenhouse.
actuators
ActuatorDto[]
required
List of actuator objects.

GET /api/actuators/:idReturns a single actuator by ID.
path.id
number
required
Actuator ID.
(root)
ActuatorDto
required
The actuator object.

POST /api/actuatorsCreates an actuator.
body.name
string
required
Display name.
body.type
ActuatorType
Actuator category.
body.gpioPin
number
GPIO pin on the ESP32.
body.activeLow
boolean
Set to true for active-low relays.
body.greenhouseId
number
Parent greenhouse.
(root)
ActuatorDto
required
The created actuator.

PUT /api/actuators/:idUpdates an actuator.
path.id
number
required
Actuator ID.
Body accepts any subset of ActuatorDto fields.
DELETE /api/actuators/:idDeletes an actuator.
path.id
number
required
Actuator ID.
Returns 204 No Content.
GET /api/readingsReturns sensor readings. Exactly one of sensor or greenhouseId is typically supplied to scope the results.
query.sensor
number
Return readings for this sensor ID only.
query.greenhouseId
number
Return readings for all sensors in this greenhouse.
query.limit
number
default:"100"
Maximum number of readings to return.
readings
SensorReadingDto[]
required
List of reading objects ordered by timestamp descending.

POST /api/readingsCreates a sensor reading (used by device proxies or manual entry).
body.sensorId
number
required
Sensor that produced the reading.
body.value
number
required
Measured value.
body.timestamp
string
ISO 8601 timestamp. Defaults to server time if omitted.
(root)
SensorReadingDto
required
The created reading.
GET /api/cropsReturns all crop profiles.
crops
CropDto[]
required
List of crop objects.

GET /api/crops/:idReturns a single crop profile.
path.id
number
required
Crop ID.
(root)
CropDto
required
The crop object.

POST /api/cropsCreates a crop profile.
body.name
string
required
Crop name.
body.greenhouseId
number
Greenhouse to assign the crop to.
body.temp_min
number
Minimum temperature (°C).
body.temp_max
number
Maximum temperature (°C).
Body accepts any additional CropDto range fields.
(root)
CropDto
required
The created crop.

PUT /api/crops/:idUpdates a crop profile.
path.id
number
required
Crop ID.

DELETE /api/crops/:idDeletes a crop profile.
path.id
number
required
Crop ID.
Returns 204 No Content.
GET /api/alertsReturns all alerts for the authenticated user’s accessible greenhouses.
alerts
AlertDto[]
required
List of alert objects.

POST /api/alertsCreates an alert manually.
body.type
string
required
Sensor type or custom category.
body.level
AlertLevel
required
Severity: INFO, WARNING, or CRITICAL.
body.message
string
required
Alert message body.
body.title
string
Short title.
body.greenhouseId
number
Associated greenhouse.
(root)
AlertDto
required
The created alert.

PUT /api/alerts/:id/readMarks an alert as read.
path.id
number
required
Alert ID.
Returns 204 No Content.
DELETE /api/alerts/:idDeletes an alert.
path.id
number
required
Alert ID.
Returns 204 No Content.
GET /api/rulesReturns all automation rules.
rules
RuleDto[]
required
List of rule objects.

POST /api/rulesCreates a rule.
body.name
string
required
Rule name.
body.sensorType
SensorType
required
Sensor type to monitor.
body.conditionType
RuleConditionType
required
Comparison operator.
body.threshold
number
required
Trigger value.
body.actuatorId
number
required
Actuator to control.
body.actionType
RuleActionType
required
Action to perform.
(root)
RuleDto
required
The created rule.

PUT /api/rules/:idUpdates a rule.
path.id
number
required
Rule ID.

DELETE /api/rules/:idDeletes a rule.
path.id
number
required
Rule ID.
Returns 204 No Content.
GET /api/logsReturns audit log entries.
query.limit
number
default:"100"
Maximum number of entries to return.
logs
LogDto[]
required
List of log entries ordered by timestamp descending.
GET /api/reports/daily-csvReturns or initiates a daily CSV report download.
GET /api/reports/weekly-statsReturns weekly aggregated statistics.
POST /api/reports/send-emailSends a report via email.
body.(varies)
object
Report payload — recipient, date range, and format fields.

POST /api/reports/scheduleSchedules a recurring report.
GET /api/reports/historyReturns report generation history.
query.limit
number
default:"10"
Maximum number of history entries.
POST /api/auth/loginAuthenticates a user with username/password or Google OAuth.
body.username
string
required
Login username.
body.password
string
required
User password.
(root)
UserDto
required
The authenticated user object.

POST /api/auth/registerRegisters a new user account.
body.username
string
required
Desired username.
body.password
string
required
Password.
body.fullName
string
required
Full display name.
body.email
string
Optional email address.
(root)
UserDto
required
The created user object.

GET /api/auth/meReturns the profile of the currently authenticated user (uses X-User-Id header).
(root)
UserDto
required
Current user object.

GET /api/auth/users (admin only)Returns all user accounts. Requires X-Admin-Email header.
users
UserDto[]
required
List of all users.

PUT /api/auth/users/:userId/role (admin only)Changes a user’s role.
path.userId
number
required
Target user ID.
body.role
string
required
New role: ADMIN or USER.
Returns 204 No Content.
GET /api/usersReturns all users (non-admin variant).
users
UserDto[]
required
List of user objects.

POST /api/usersCreates a user.
PUT /api/users/:idUpdates a user.
path.id
number
required
User ID.

DELETE /api/users/:idDeletes a user.
path.id
number
required
User ID.
Returns 204 No Content.
GET /api/users/:id/greenhousesReturns the greenhouse IDs a user has access to.
path.id
number
required
User ID.
ids
number[]
required
List of greenhouse IDs.

PUT /api/auth/users/:userId/greenhouses (admin only)Sets the greenhouse access list for a user.
path.userId
number
required
User ID.
body.ids
number[]
required
Array of greenhouse IDs to assign.
ids
number[]
required
Updated list of assigned greenhouse IDs.
POST /api/device/registerRegisters a new ESP32 device.
body.(varies)
object
Device registration payload (device ID, firmware version, etc.).

GET /api/device/config/:idReturns the full sensor and actuator configuration for a greenhouse’s device.
path.id
number
required
Greenhouse ID.
deviceId
string
ESP32 device identifier.
sensors
SensorDto[]
required
Sensors registered to this device.
actuators
ActuatorDto[]
required
Actuators registered to this device.

GET /api/device/gpios/:idReturns available and used GPIO pins for a greenhouse’s device.
path.id
number
required
Greenhouse ID.
usedGpios
number[]
required
Pins already assigned.
availableForSensors
number[]
required
Pins available for sensor assignment.
availableForActuators
number[]
required
Pins available for actuator assignment.
GET /api/ticketsReturns all support tickets.
tickets
TicketDto[]
required
List of ticket objects.

GET /api/tickets/:idReturns a single ticket.
path.id
number
required
Ticket ID.

POST /api/ticketsCreates a support ticket.
body.subject
string
required
Ticket subject.
body.description
string
required
Full description of the issue.
(root)
TicketDto
required
The created ticket.

PUT /api/tickets/:idUpdates a ticket (e.g. change status).
path.id
number
required
Ticket ID.

DELETE /api/tickets/:idDeletes a ticket.
path.id
number
required
Ticket ID.
Returns 204 No Content.

Build docs developers (and LLMs) love