ASAgriSense/Docs/Surveys

Module 6

Survey System

Purpose#

Provides a configurable form builder for collecting structured field data — from farmer baseline profiles to environmental audits. Surveys work offline on mobile; data syncs when connectivity is restored.

Completion of a Farmer Baseline survey is one of the five EUDR compliance conditions — making the survey module a direct dependency of the EUDR Compliance module.

Survey types#

  • Farmer Baseline (required for EUDR compliance condition)
  • Annual Household Survey
  • Farm Environmental Audit
  • Spot Check
  • Training Needs Assessment
  • Custom (any user-defined purpose)

Question types#

TypeDescription
short_textSingle-line text input.
long_textMulti-line text area.
numberNumeric input with optional min/max validation.
dateDate picker.
single_selectRadio group — pick one option.
multi_selectCheckbox group — pick multiple options.
yes_noBoolean toggle.
gps_locationCapture GPS coordinates.
photoCamera or gallery photo upload.
signatureCaptured on mobile touchscreen.
section_headerVisual divider — groups questions into sections.

Conditional logic#

Questions can have show/hide rules: "show this question only if question X equals Y". Conditional logic is evaluated client-side (in the form renderer) and works fully offline.

Rules are stored as a typed ConditionalLogic object in the question definition. The form renderer evaluates all rules on every field change.

Form versioning#

Surveys follow a draft → published lifecycle. Once published, a form version is immutable — responses can no longer be modified and the question set cannot change. Any edits require creating a new draft version.

StateBehaviour
draftEditable. Can add, remove, and reorder questions. Cannot receive responses.
publishedImmutable. Responses can be submitted. Cannot be edited — create a new draft instead.
archivedNo new responses. Historical data preserved.

Survey assignments#

A published form version is linked to a community or specific farmers via an assignment. Assignments have an optional due date and are visible to Sustainability Officers in their work queue.

Offline capability#

Offline-first on mobile
The Flutter mobile app stores the published form definition in SQLite. Officers can collect responses with zero connectivity. Responses are synced to the API in the next sync batch. Photo answers are compressed before upload to reduce data usage.

Packages#

PackageTypeKey exports
@repo/feature-surveysBackendServices: survey-form, survey-version, survey-question, survey-assignment, survey-response, survey-analytics, survey-export, survey-photo
@repo/feature-surveys-webFrontendSurvey builder, form renderer, analytics view, assignment manager

API routes#

RouteNotes
/api/surveysCRUD for survey forms.
/api/survey-versionsManage versions (draft → publish → archive).
/api/survey-questionsCRUD for questions within a draft version.
/api/survey-assignmentsAssign forms to communities or farmers.
/api/survey-responsesSubmit and retrieve responses.
/api/survey-analyticsAggregate response statistics.
/api/survey-exportExport responses as CSV.
/api/survey-photosPresigned R2 URL for photo upload.