A newer version of the Gradio SDK is available:
6.2.0
Gradio 6 UI for Disaster Risk Construction Planner
This is the web-based user interface for the Disaster Risk Construction Planner system, built with Gradio 6.
Features
- Interactive Input Form: Select building type, enter coordinates, and specify building area
- Tabbed Results Display:
- Executive Summary
- Risk Assessment
- Detailed Hazards
- Construction Recommendations
- Material Costs
- Critical Facilities Map
- Export Functionality: Export construction plans as JSON or PDF/HTML
- Progress Indicators: Real-time progress updates during plan generation
- Responsive Design: Clean, modern interface with color-coded risk levels
Requirements
- Python 3.8+
- Gradio 6.0+
Installation
- Install dependencies:
pip install -r requirements.txt
Note: This application requires Gradio 6.0 or higher. weasyprint is optional for PDF export. If not installed, exports will be saved as HTML files.
- Set environment variables (optional):
export ORCHESTRATOR_AGENT_URL=http://localhost:8000
Running the Application
Local Development
python app.py
The application will be available at http://localhost:7860
Production Deployment
For production deployment, configure the ORCHESTRATOR_AGENT_URL environment variable to point to your deployed Orchestrator Agent endpoint.
Project Structure
gradio-ui/
βββ app.py # Main application entry point
βββ orchestrator_client.py # Client for Orchestrator Agent communication
βββ export_utils.py # Export functionality (JSON/PDF)
βββ models.py # Data models (symlink to shared/models.py)
βββ requirements.txt # Python dependencies
βββ components/ # UI components
β βββ __init__.py
β βββ risk_display.py # Risk assessment display
β βββ recommendations_display.py # Recommendations display
β βββ costs_display.py # Material costs display
β βββ facilities_map.py # Facilities map display
βββ README.md # This file
Components
Risk Display Component
Displays risk assessment results with:
- Color-coded overall risk level
- Hazard statistics
- Critical hazards highlighting
- Detailed seismic, volcanic, and hydrometeorological hazards
Recommendations Display Component
Shows construction recommendations with:
- General guidelines
- Priority actions
- Hazard-specific recommendations
- Building code references
Costs Display Component
Presents material cost analysis with:
- Total cost estimates (low/mid/high)
- Itemized materials by category
- Market conditions and timestamps
Facilities Map Component
Displays critical facilities information:
- Nearby schools and hospitals
- Emergency services
- Utilities
- Road networks
- Distances and travel times
- Directions to each facility
Usage
- Select Building Type: Choose from residential, commercial, industrial, institutional, or mixed-use
- Enter Coordinates: Provide latitude and longitude within Philippine bounds (4Β°N-21Β°N, 116Β°E-127Β°E)
- Specify Building Area (optional): Enter estimated building area in square meters
- Generate Plan: Click "Generate Construction Plan" button
- Review Results: Navigate through tabs to view different aspects of the plan
- Export: Use export buttons to save the plan as JSON or PDF
Example Locations
- Manila: 14.5995Β°N, 120.9842Β°E
- Cebu: 10.3157Β°N, 123.8854Β°E
- Davao: 7.1907Β°N, 125.4553Β°E
Notes
- The UI connects to the Orchestrator Agent which coordinates all specialized agents
- For local development, the orchestrator is called directly
- For production, HTTP requests are made to the deployed agent endpoint
- All coordinates must be within the Philippines
- Export functionality requires write permissions in the current directory
Quick Start
See QUICKSTART.md for a quick start guide.
Troubleshooting
Import Errors
If you see import errors, ensure all dependencies are installed:
pip install -r requirements.txt
python test_app.py # Verify installation
Connection Errors
If the orchestrator agent connection fails:
- Verify the
ORCHESTRATOR_AGENT_URLis correct - Ensure the orchestrator agent is running and accessible
- Check network connectivity
Export Errors
If PDF export fails:
- Install weasyprint:
pip install weasyprint - Or use the HTML fallback (automatically used if weasyprint is not available)
Development
To modify the UI:
- Edit component files in
components/directory - Update
app.pyfor layout changes - Modify
orchestrator_client.pyfor agent communication changes - Update
export_utils.pyfor export format changes
License
Part of the Disaster Risk Construction Planner system.