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 ships as a self-contained JAR and a multi-stage Dockerfile, so it runs anywhere Java or Docker is available. For development, it uses SQLite with no additional setup. For production, swap in a PostgreSQL connection string and set your secrets as environment variables — no code changes required.
SQLite is the default database. No installation or configuration is needed — AgroPulse creates agropulse.db in the working directory on first startup.Requirements: Java 17, Maven 3.9+ (or use the included ./mvnw wrapper).
# Build
./mvnw clean package -DskipTests

# Run
JWT_SECRET=local-dev-secret ./mvnw spring-boot:run
The server starts on port 8080. The full base URL is http://localhost:8080/api.To override the port:
PORT=9090 JWT_SECRET=local-dev-secret ./mvnw spring-boot:run

Dockerfile

The included Dockerfile uses a two-stage build to keep the final image small. The build stage compiles with Maven; the runtime stage uses only the JRE.
# Stage 1: Build
FROM maven:3.9.6-eclipse-temurin-17 AS build
WORKDIR /app
COPY pom.xml .
RUN mvn dependency:go-offline -B
COPY src ./src
RUN mvn clean package -DskipTests -B

# Stage 2: Run
FROM eclipse-temurin:17-jre-jammy
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]

Docker deployment

1

Build the image

docker build -t agropulse-backend:latest .
2

Run the container

Pass secrets as environment variables with -e. Never bake them into the image.
docker run -d \
  --name agropulse \
  -p 8080:8080 \
  -e PORT=8080 \
  -e JWT_SECRET=replace-me-with-a-long-random-string \
  -e JWT_EXPIRATION_MS=86400000 \
  -e CORS_ALLOWED_ORIGINS=https://your-frontend.vercel.app \
  -e SPRING_DATASOURCE_URL=jdbc:postgresql://host:5432/agropulse?user=postgres&password=secret&sslmode=require \
  -e SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver \
  -e SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect \
  -e SENDGRID_API_KEY=SG.xxxxxxxxxxxx \
  -e SENDGRID_FROM_EMAIL=alerts@your-domain.com \
  -e AGROPULSE_ADMIN_EMAIL=admin@your-domain.com \
  agropulse-backend:latest
3

Verify the container is running

docker logs agropulse --tail 20
curl http://localhost:8080/api/auth/me
# {"error":"No autenticado"}  ← server is up
4

Tag and push to a registry (optional)

To deploy to Render, AWS ECS, Fly.io, or any Docker-compatible platform, push the image to a registry first:
docker tag agropulse-backend:latest ghcr.io/your-org/agropulse-backend:latest
docker push ghcr.io/your-org/agropulse-backend:latest
Then point your hosting platform at the registry image.

Environment variable reference

All variables are read at startup. Variables with defaults are optional; variables without a default are required in production.
VariableDefaultDescription
PORT8080Port the HTTP server listens on.
CORS_ALLOWED_ORIGINShttp://localhost:5173, http://localhost:3000, http://localhost:4173Comma-separated list of origins allowed by CORS. Set to your frontend URL in production.
JWT_SECRETagropulse-default-secret-change-in-productionSecret used to sign JWT tokens. Must be overridden in production.
JWT_EXPIRATION_MS86400000JWT token lifetime in milliseconds. Default is 24 hours.
SPRING_DATASOURCE_URLjdbc:sqlite:agropulse.dbJDBC connection URL. Override with a PostgreSQL URL for production.
SPRING_DATASOURCE_DRIVER_CLASS_NAMEorg.sqlite.JDBCJDBC driver class. Set to org.postgresql.Driver for PostgreSQL.
SPRING_JPA_DATABASE_PLATFORMorg.hibernate.community.dialect.SQLiteDialectHibernate dialect. Set to org.hibernate.dialect.PostgreSQLDialect for PostgreSQL.
SENDGRID_API_KEY(none)SendGrid API key for email alert delivery. Anomaly email notifications are disabled if unset.
SENDGRID_FROM_EMAIL(none)Sender address used in outgoing SendGrid emails.
AGROPULSE_ADMIN_EMAIL(none)Email address granted admin privileges. Requests pass this value in the X-Admin-Email header to access admin-only endpoints.
JWT_SECRET, SENDGRID_API_KEY, and your database password are sensitive secrets. Never hardcode them in source files or commit them to version control. Use your platform’s secret management — Render Environment, Docker secrets, or a .env file that is listed in .gitignore.

PostgreSQL notes

When connecting to Supabase or PgBouncer in transaction-pooling mode, prepared statement caching must be disabled to avoid prepared statement S_XX already exists errors. AgroPulse handles this automatically via:
spring.datasource.hikari.data-source-properties.prepareThreshold=0
No additional configuration is required on your end.

Build docs developers (and LLMs) love