- Overview
- System Architecture
- Access Methods
- Technology Stack
- Setup and Installation
- API Reference
- Python Integration
- License
WHISP is a comprehensive geospatial analysis tool that provides detailed risk assessment for zero-deforestation claims. The system ingests geometries in various formats (WKT, GeoJSON, or Asset Registry GeoIDs) and performs analysis using Google Earth Engine data through the openforis-whisp Python library.
Live Application: https://whisp.openforis.org/
graph TB
subgraph "User Interfaces"
A[Web Application]
B[API Access]
C[Python Package]
D[Whisp in Earthmap]
N[QGIS Whisp Plugin]
end
subgraph "Application Layer"
E[Next.js Frontend]
F[API Routes]
G[Authentication Middleware]
end
subgraph "Processing Layer"
H[Python Analysis Engine]
I[openforis-whisp Library]
J[Google Earth Engine]
end
subgraph "Data Layer"
K[PostgreSQL Database]
L[Temporary Storage]
M[GEE Credentials]
end
A --> E
B --> F
E --> F
F --> G
G --> H
H --> I
I --> J
F --> K
H --> L
J --> M
sequenceDiagram
participant U as User
participant FE as Frontend
participant API as API Routes
participant AUTH as Auth Middleware
participant PY as Python Engine
participant GEE as Google Earth Engine
participant DB as Database
U->>FE: Upload Geometry
FE->>API: POST /api/submit/*
API->>AUTH: Validate API Key
AUTH->>DB: Check API Key
DB-->>AUTH: Key Valid
AUTH-->>API: Authorized
API->>PY: Execute Analysis
PY->>GEE: Process Geometry
GEE-->>PY: Analysis Results
PY-->>API: Results Data
API->>DB: Store Results
API-->>FE: Return Token
FE->>U: Display Results
WHISP offers multiple access methods to accommodate different user needs:
| Access Method | Description | Geometry Limit | Best For |
|---|---|---|---|
| Web App | User-friendly interface with interactive map | Currently 500 | Non-technical users, quick assessments |
| API | Programmatic access with authentication | Currently 500 | Integration with other systems |
| Python Package | Direct access via openforis-whisp |
No limit (depends on GEE quotas) | Data scientists, large datasets |
| Whisp in Earthmap | Visualization-focused interface | Limited (visualization tool) | Visual exploration of specific plots |
| QGIS Whisp Plugin | Analyze geometries within QGIS through the Whisp API | Currently 500 | GIS analysts, desktop workflows |
- Framework: Next.js 14.2.26 with React 18
- Language: TypeScript 5.8.2
- Styling: Tailwind CSS with custom components
- UI Components: Radix UI component library
- Mapping: Leaflet 1.9.4 with react-leaflet 4.2.1
- State Management: Zustand 4.4.7
- Data Tables: TanStack Table 8.20.1
- File Handling: react-dropzone 14.2.3
- Runtime: Node.js with Next.js API routes
- Database: PostgreSQL with pg driver 8.14.1
- Authentication: JWT tokens via jose 6.0.10
- Email: Nodemailer 6.10.0 for verification/reset
- Python Integration: Subprocess execution
- API Documentation: Swagger UI React 5.21.0
- Logging: Winston 3.15.0
- Core Library:
openforis-whispfor risk assessment - Data Processing:
pandas,numpyfor data manipulation - Geospatial: Google Earth Engine API
- Output Formats: JSON, CSV, GeoJSON
- Node.js (v18 or higher)
- PostgreSQL (v12 or higher)
- Python 3.11+
- Google Earth Engine service account
-
Clone the Repository
git clone https://github.com/openforis/whisp-app.git cd whisp-app -
Install Dependencies
-
Install the whisp Python package and other requirements
pip install -r requirements.txt
-
Install project dependencies
npm install
-
-
Set Up PostgreSQL Database
- Create a new PostgreSQL database for the application
- Run the database schema scripts located in
src/db/* - Create a database user with appropriate permissions
-
Environment Configuration
- Create
.env.localfile:
# Python Configuration PYTHON_PATH=/path/to/your/python # Database Configuration DB_USER=postgres DB_HOST=localhost DB_NAME=whisp DB_PASSWORD=your_password DB_PORT=5432 # Authentication JWT_SECRET=your_jwt_secret # Asset Registry ASSET_REGISTRY_BASE=https://api-ar.agstack.org AR_API_KEY=your_ar_api_key AR_CLIENT_SECRET=your_ar_client_secret # Email Configuration EMAIL_SERVICE=smtp.example.com EMAIL_USER=user@example.com EMAIL_PASS=your_email_password # Google Maps API Key (for satellite view - with referrer restrictions) NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=your_google_maps_api_key_here
- Create
-
Google Earth Engine Setup
- Place your service Google Earth engine account credentials in
credentials.jsonat the root directory.
- Place your service Google Earth engine account credentials in
-
Create Temp Directory
mkdir temp
-
Run the Application
npm run dev
-
Create an API Key (optional for direct API calls)
- After setting up, register a user account on the application
- Generate an API key from your user profile
- Use this API key for authenticated requests to the API endpoints
The Whisp API provides endpoints for user management, data submission, and analysis. The API is protected by authentication middleware. A full, interactive API documentation is available via Swagger UI at the /documentation/api-guide endpoint.
The main API endpoints are located in src/app/api/.
/api/auth: Handles user authentication, including login, registration, password reset, and email verification./api/user: Manages user profiles and API keys./api/submit: Accepts geospatial data in various formats (WKT, GeoJSON) for analysis. This endpoint initiates the Python processing script./api/temp-key: Manages temporary keys for unauthenticated analysis./api/generate-geojson: Generates GeoJSON output from analysis results./api/report: Creates and serves analysis reports./api/download-csv: Allows downloading analysis results as a CSV file.
The Python analysis is handled by src/python/analysis.py:
import openforis_whisp as whisp
import pandas as pd
# Initialize Google Earth Engine
whisp.initialize_ee(CREDENTIAL_PATH)
def main(file_path, legacy_mode=False):
# Process geometry data
whisp_df = whisp.whisp_formatted_stats_geojson_to_df(
file_path,
national_codes=['co', 'ci', 'br']
)
# Perform risk assessment
whisp_df_risk = whisp.whisp_risk(
whisp_df,
national_codes=['co', 'ci', 'br']
)
# Export results
whisp_df_risk.to_csv(csv_file_path, index=False)
whisp.convert_df_to_geojson(whisp_df_risk, json_file_path)- User submits geometry via web interface
- Next.js API validates input and authentication
- Geometry is saved to temporary file
- Python script is executed via subprocess
- Results are processed and stored
- User receives analysis results
Built with ❤️ for forests and biodiversity.