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.

AgroPulse is a Spring Boot 3 REST API that accepts sensor data over HTTP, detects anomalies automatically, and fires alerts via email and WhatsApp. This guide walks you through everything from cloning the repository to posting your first reading against a running local instance.
All endpoints are served under the /api context path. The default local base URL is http://localhost:8080/api.
1

Clone and build

Clone the repository and build a runnable JAR. You can use Maven directly or build a Docker image — both produce the same artifact.
git clone https://github.com/your-org/backend-AgroPulse.git
cd backend-AgroPulse
./mvnw clean package -DskipTests
The Maven build produces a JAR in target/. The Docker build uses a two-stage process: it compiles with maven:3.9.6-eclipse-temurin-17 and packages the result into a minimal eclipse-temurin:17-jre-jammy runtime image.
2

Set environment variables

Copy .env.example to .env and fill in the required values. For local development the only mandatory variable is JWT_SECRET — all others have safe defaults.
cp .env.example .env
Edit .env:
# Origins your frontend runs on (comma-separated)
CORS_ALLOWED_ORIGINS=http://localhost:5173

# Long, random string — used to sign JWT tokens
JWT_SECRET=replace-me-with-a-long-random-string

# Token lifetime in milliseconds (default: 86400000 = 24 h)
JWT_EXPIRATION_MS=86400000
The database defaults to SQLite (agropulse.db in the working directory). No database setup is required for local development.
3

Run the application

Start the server with Maven or Docker:
./mvnw spring-boot:run
Once the application starts you should see Spring Boot’s startup banner. The API is ready when the log shows Started on port 8080.Verify the server is up:
curl http://localhost:8080/api/auth/me
# {"error":"No autenticado"}  ← 401 is expected here
4

Register a user

Create an account by posting to /api/auth/register. The username field must be unique.
curl -s -X POST http://localhost:8080/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "alice",
    "password": "s3cr3t!",
    "fullName": "Alice Grower",
    "email": "alice@example.com"
  }'
A successful response returns the new user object (password is never included):
{
  "id": 1,
  "username": "alice",
  "fullName": "Alice Grower",
  "email": "alice@example.com",
  "role": "OPERATOR",
  "active": true,
  "createdAt": "2026-05-20T10:00:00",
  "greenhouseIds": []
}
5

Create a greenhouse

Post to /api/greenhouses with at least a name. Optional fields include location, description, latitude, and longitude.
curl -s -X POST http://localhost:8080/api/greenhouses \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Greenhouse Alpha",
    "location": "Block A, North Farm",
    "description": "Main tomato greenhouse",
    "ownerId": 1
  }'
The response includes the auto-assigned id you will use in the next step:
{
  "id": 1,
  "name": "Greenhouse Alpha",
  "location": "Block A, North Farm",
  "description": "Main tomato greenhouse",
  "ownerId": 1,
  "active": true
}
6

Post a sensor reading

Send a reading to /api/readings. If you omit sensorId (or set it to 0) and supply greenhouseId and sensorType, AgroPulse auto-registers the sensor for you.
curl -s -X POST http://localhost:8080/api/readings \
  -H "Content-Type: application/json" \
  -d '{
    "greenhouseId": 1,
    "sensorType": "TEMPERATURE",
    "value": 24.5,
    "source": "esp32-node-01"
  }'
The API returns the persisted reading and immediately runs it through anomaly detection:
{
  "id": 1,
  "sensorId": 1,
  "greenhouseId": 1,
  "sensorType": "TEMPERATURE",
  "value": 24.5,
  "source": "esp32-node-01",
  "timestamp": "2026-05-20T10:01:00"
}
Valid sensorType values include TEMPERATURE, HUMIDITY, SOIL_MOISTURE, CO2, PH, LIGHT, and WIND_SPEED.

Next steps

Deploy to production

Switch from SQLite to PostgreSQL and run AgroPulse on Render or any Docker host.

API reference

Explore every endpoint — sensors, greenhouses, readings, alerts, and automation rules.

Connecting devices

Send readings from ESP32 or any HTTP-capable device.

Anomaly detection

Understand how AgroPulse flags out-of-range values and stuck sensors.

Build docs developers (and LLMs) love