-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdisaster_app_spec.txt
More file actions
580 lines (492 loc) · 18.9 KB
/
disaster_app_spec.txt
File metadata and controls
580 lines (492 loc) · 18.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
# Natural Disaster Resource Matching App - Complete Specification
## Executive Summary
A responsive web application designed to efficiently match resources with people in need during natural disasters. Built for a hackathon, this web-based solution addresses the chaos and confusion that occurs when large numbers of people require assistance by providing intelligent matching, real-time inventory management, and safety-aware logistics coordination. Accessible from any device with a web browser.
---
## Core Purpose
Connect resource providers (individuals, organizations, relief agencies) with people in need during natural disasters through an intelligent, easy-to-use platform that optimizes distribution, prevents congestion at staging areas, and ensures safety throughout the supply chain.
---
## Key Features & Functional Requirements
## User Interface & App Flow
### Language Selection (First Visit)
- Initial screen on first app visit
- Language selector: English and Spanish
- Selection stored in browser local storage
- Can be changed later in settings
### Home Screen
- Two primary action buttons:
- **"I have supplies"** (Provider flow)
- **"I need supplies"** (Seeker flow)
- Simple, clear interface
- Button selection determines AI conversation context
### AI Chat Interface
**Full Screen Chat Window**
- Activated after button selection on Home Screen
- Claude API-powered conversational interface
- Guided by context-specific markdown documents:
- **Provider Guide (MD):** Questions and prompts for those offering supplies
- What supplies do you have?
- Quantities and condition
- Location information
- Do you have transportation?
- Delivery preferences
- **Seeker Guide (MD):** Questions and prompts for those needing resources
- What do you need?
- Quantities needed
- Location information
- Do you need transportation?
- Pickup vs delivery preference
- Special requirements (dietary, medical, accessibility)
**AI Query Behavior**
- Based on user chat inputs, AI queries database for:
- Available supplies matching needs
- Nearby distribution locations
- Transportation options
- User location and proximity to resources
- AI provides context-appropriate responses guided by the MD documents
- Real-time inventory checking
- Smart matching between needs and availability
**Geocoding Requirements**
- Geocode all locations in the Locations table (latitude/longitude)
- Geocode seeker addresses/locations during chat
- Geocode provider addresses/locations during chat
- Use geocoded data for:
- Proximity matching
- Route optimization
- Safety-aware routing
- Display on maps
### 1. AI Chat Interface (Primary User Interface)
**Full Screen Chat Window (Powered by Claude API)**
- Primary interaction method for both resource seekers and providers
- Activated after user selects "I have supplies" or "I need supplies" from Home Screen
- Natural language processing via Claude API to understand needs and available supplies
- Conversational flow guided by context-specific markdown documents
- Multi-language support (English and Spanish)
- Accessible design for users of all technical skill levels
- Context-aware responses that understand disaster-specific terminology
- Intelligent follow-up questions to clarify needs
- Suggestions for alternative resources when primary items unavailable
- Real-time database queries based on conversation context
### 2. Resource Management
**Real-Time Inventory System**
- Live tracking of all available resources across distribution points
- Automatic updates as supplies are distributed or replenished
- Category-based organization (food, water, medical supplies, shelter materials, etc.)
- Quantity tracking with low-stock alerts
- Expiration date tracking for perishable items
**Reservation System**
- Allow users to reserve needed resources through AI chat
- Time-limited reservations to prevent hoarding
- Queue management for high-demand items
- Automatic release of unclaimed reservations
- Confirmation notifications
**Distribution Policies**
- Configurable allocation rules based on need priority
- Quota systems to ensure fair distribution
- Household size considerations
- Special needs accommodation (medical, dietary, accessibility)
- Prevention of duplicate claims across multiple distribution points
### 3. Distribution Facility Management
**Facility Enrollment**
- Onboard new distribution centers, warehouses, and staging areas
- Location mapping and capacity information
- Operating hours and staff availability
- Contact information and special instructions
**Staging Area Congestion Management**
- Appointment scheduling system to prevent overcrowding
- Time-slot allocation for pickups
- Real-time crowd monitoring and alerts
- Dynamic routing to less congested locations
- Virtual queue system with estimated wait times
### 4. Logistics & Transportation
**Delivery Options**
- Multiple fulfillment methods: pickup, delivery, mobile distribution
- Delivery zone mapping and scheduling
- Route optimization considering safety and efficiency
**Ride-Sharing Integration**
- Integration with Uber, Lyft, and similar services
- Ad hoc transportation for suppliers bringing donations
- Transport assistance for people unable to reach distribution points
- Volunteer driver coordination
**Safety-Aware Routing**
- Real-time hazard mapping (flooded areas, damaged roads, unsafe zones)
- Integration with emergency services data
- Dynamic route updates as conditions change
- Safety alerts for drivers and recipients
- Weather condition warnings
### 5. Communication & Notifications
**Push Notifications & Text Alerts**
- Supply availability announcements
- Reservation confirmations and reminders
- Pickup appointment notifications
- Safety alerts and evacuation notices
- Delivery status updates
- Facility operating hour changes
**Community News Stream**
- Real-time news alerts relevant to the disaster
- Official announcements from emergency services
- Resource availability updates
- Community support information
- Recovery progress updates
### 6. Offline Functionality
**Local Data Persistence**
- Critical information cached on device
- Offline mode for viewing saved data
- Queue requests made offline for sync when connectivity returns
- Last-known inventory and facility information
- User's reservation and appointment details
- Automatic sync when connection is restored
### 7. Security & Fraud Prevention
**User Verification**
- Identity verification via Privy at registration
- Phone number verification
- Address verification for delivery
- Profile completion through AI chat interaction
**Fraud Prevention Controls**
- Detection of duplicate requests from same household
- Monitoring for unusual claim patterns
- Geolocation verification for pickups
- Transaction logging and audit trails
- Report abuse functionality
- Blacklist management for verified fraud cases
**Resource Tracking**
- QR code or barcode scanning at distribution
- Chain of custody tracking
- Signature or PIN confirmation for pickups
- Photo documentation options
### 8. Display & Dashboard Systems
**Public Display Screens**
- Real-time inventory displays at distribution centers
- Available quantities by category
- Current wait times
- Next appointment slots
- Quota information
- Frequently refreshed via user input and automated updates
**Admin Dashboards**
- Overall system status and metrics
- Distribution center performance
- Supply levels across all locations
- User demand patterns
- Transportation utilization
- Fraud alerts and security events
---
## Technical Architecture
### Responsive Web Application
- Single responsive web application (mobile-first design)
- Works across all devices: phones, tablets, and desktop
- Progressive Web App (PWA) capabilities for installability
- Optimized for low-bandwidth conditions
- Lightweight data transmission
- No app store deployment needed - accessible via URL
### Cloudflare Infrastructure
- **Cloudflare Pages:** Static site hosting for frontend
- **Cloudflare Workers:** Serverless backend logic and API endpoints
- **Cloudflare D1:** SQLite-based database for data storage
- **Cloudflare KV:** Key-value store for caching and session management
- **Cloudflare R2:** Object storage for images and documents (if needed)
- Global CDN for fast content delivery
- Built-in DDoS protection and security
- Zero cold starts with Workers
- Cost-effective scaling
### Backend Requirements
- **Cloudflare Workers:** Serverless functions for all backend logic
- **Cloudflare D1:** SQL database for inventory, users, reservations, and transactions
- **Cloudflare KV:** Fast key-value storage for sessions, cache, and real-time data
- **Cloudflare Durable Objects:** For real-time features and WebSocket connections (optional)
- **Claude API integration for all AI features:**
- Natural language understanding for resource requests
- Conversational interface for both seekers and providers
- Intent classification (requesting vs offering resources)
- Entity extraction (resource types, quantities, locations)
- Smart matching between needs and available supplies
- Contextual responses and guidance
- API calls made from Cloudflare Workers
- API integrations for ride-sharing services (via Workers)
- Geolocation services
- Push notification service (via Workers)
- SMS gateway integration (Twilio or similar via Workers)
### Data Management
- **Cloudflare D1 Database Schema:**
#### Users Table
- `id` (primary key)
- `privy_id` (authentication reference from Privy)
- `email`
- `name`
- `phone`
- `address`
- `has_transportation` (boolean)
- `roles` (JSON array: can include 'seeker', 'provider', 'admin', 'distribution_staff', 'transport_coordinator')
- `created_at`
- `updated_at`
- `verification_status`
#### Locations Table
- `id` (primary key)
- `name`
- `address`
- `latitude`
- `longitude`
- `capacity`
- `instructions` (text field for other details/instructions)
- `operating_hours`
- `contact_info`
- `is_active` (boolean)
- `created_at`
- `updated_at`
#### Supply_Categories Table
- `id` (primary key)
- `name`
- `category` (e.g., 'food', 'water', 'medical', 'shelter', 'clothing')
- `is_perishable` (boolean)
- `unit_of_measure` (e.g., 'lbs', 'gallons', 'units', 'boxes')
- `created_at`
- `updated_at`
#### Supplies Table
- `id` (primary key)
- `name`
- `category_id` (foreign key to Supply_Categories)
- `location_id` (foreign key to Locations)
- `quantity`
- `weight` (numeric, in lbs or kg)
- `dimensions` (text field for length x width x height)
- `expiration_date` (for perishable items)
- `added_by_user_id` (foreign key to Users - the provider)
- `status` (e.g., 'available', 'reserved', 'distributed')
- `created_at`
- `updated_at`
#### Reservations Table
- `id` (primary key)
- `user_id` (foreign key to Users - the seeker)
- `supply_id` (foreign key to Supplies)
- `quantity_reserved`
- `status` (e.g., 'pending', 'confirmed', 'picked_up', 'cancelled', 'expired')
- `reservation_expires_at`
- `pickup_appointment_time`
- `created_at`
- `updated_at`
- `fulfilled_at`
#### Transactions Table
- `id` (primary key)
- `reservation_id` (foreign key to Reservations)
- `user_id` (foreign key to Users)
- `supply_id` (foreign key to Supplies)
- `quantity`
- `transaction_type` (e.g., 'pickup', 'delivery', 'donation')
- `verification_method` (e.g., 'qr_code', 'pin', 'signature')
- `verification_data` (JSON for storing verification details)
- `location_id` (foreign key to Locations)
- `created_at`
#### Safety_Alerts Table
- `id` (primary key)
- `alert_type` (e.g., 'road_closure', 'flood', 'hazard', 'evacuation')
- `severity` (e.g., 'low', 'medium', 'high', 'critical')
- `title`
- `description`
- `affected_area` (JSON with coordinates or address)
- `is_active` (boolean)
- `created_at`
- `expires_at`
- `updated_at`
#### News_Alerts Table
- `id` (primary key)
- `title`
- `content`
- `source`
- `url` (optional link to full article)
- `priority` (numeric)
- `is_active` (boolean)
- `created_at`
- `expires_at`
- **Cloudflare KV Storage:**
- Session management
- Real-time inventory cache
- Frequently accessed data
- Rate limiting counters
- Conversation history for Claude AI chat
- Efficient data caching strategies
- Conflict resolution for offline edits
- Real-time sync protocols via Workers
- Data compression for mobile networks
---
## User Roles
**Note:** Users can have multiple roles simultaneously. A single user can be both a provider and a seeker, and may also have administrative roles.
### Resource Seekers (People in Need)
- Select "I need supplies" on Home Screen
- Request resources through AI chat guided by Seeker MD document
- View available inventory through chat responses
- Make reservations through conversation
- Schedule pickups or deliveries via chat
- Indicate transportation needs
- Receive notifications
- Access offline information
### Resource Providers (Suppliers/Donors)
- Select "I have supplies" on Home Screen
- Offer available resources through AI chat guided by Provider MD document
- Specify quantities, types, condition, weight, and dimensions via conversation
- Choose delivery or drop-off options through chat
- Indicate if they have transportation
- Request transportation assistance if needed
- Track donation status
- Single users (no multi-user organization accounts)
### Distribution Center Staff
- Manage local inventory
- Process reservations and pickups
- Update availability in real-time
- Monitor congestion
- Handle special requests
### System Administrators
- Manage distribution facilities
- Configure distribution policies
- Monitor system health
- Review fraud alerts
- Generate reports
- Broadcast community alerts
### Transportation Coordinators
- Manage delivery schedules
- Coordinate volunteer drivers
- Monitor safety conditions
- Optimize routes
---
## Success Metrics
- Response time from request to fulfillment
- Reduction in staging area congestion
- User satisfaction ratings
- Resource utilization efficiency
- Fraud incident rate
- System uptime and reliability
- User adoption rate
---
## Implementation Priorities
### Phase 1 (MVP)
- AI chat interface
- Basic inventory management
- User registration and verification
- Simple reservation system
- Push notifications
- Offline data persistence
### Phase 2
- Appointment scheduling
- Congestion management
- Safety-aware routing
- Enhanced fraud prevention
- Public display screens
### Phase 3
- Ride-sharing integration
- Advanced distribution policies
- Comprehensive analytics
- News stream integration
- Multi-disaster deployment capability
---
## Additional Considerations
### Claude API Integration Details
- **API Key Management:** Store Claude API key securely in Cloudflare Workers environment variables
- **Worker Integration:** All Claude API calls made server-side via Cloudflare Workers
- **Rate Limiting:** Monitor and manage API usage within limits using Workers
- **Error Handling:** Graceful fallbacks if API is temporarily unavailable
- **Response Streaming:** Real-time streaming of Claude responses for better UX
- **Prompt Engineering:** Optimized system prompts for disaster response context
- **Conversation History:** Maintain context using D1 database or KV storage
- **Cost Management:** Token usage tracking and optimization
### Cloudflare-Specific Optimizations
- Leverage edge caching for static content and frequently accessed data
- Use Workers KV for ultra-fast session and state management
- Implement rate limiting using Durable Objects or KV
- Geographic routing to nearest edge locations
- Automatic HTTPS and security headers
- Built-in analytics and monitoring
### Scalability
- Cloudflare's global network automatically handles traffic spikes
- Workers scale instantly without configuration
- D1 database scales with application needs
- Edge caching reduces database load
- Ability to quickly deploy to new regions/disasters
- No server management or auto-scaling configuration needed
### Accessibility
- WCAG 2.1 AA compliance
- Screen reader compatibility
- High contrast modes
- Voice input/output options
- Support for users with limited literacy
- **Multi-language support: English and Spanish**
- Language selection on first visit
- Language preference stored locally
### Privacy & Data Protection
- HIPAA compliance for medical information
- Secure data transmission and storage
- User consent management
- Data retention and deletion policies
- Anonymous usage options for vulnerable populations
### Integration Points
- Emergency management systems (FEMA, local emergency services)
- Weather services and hazard monitoring
- Transportation APIs (Uber, Lyft, local transit)
- Mapping services (Google Maps, OpenStreetMap)
- SMS gateways
- Social media for community outreach
### Localization
- **Initial support: English and Spanish**
- Language selection screen on first app visit
- Cultural sensitivity in messaging
- Local customs and preferences consideration
- Regional resource categories
- Future expansion to additional languages
---
## Project Timeline Estimate
**Hackathon MVP (24-48 hours):**
- Responsive web interface deployed on Cloudflare Pages
- Language selection screen (English/Spanish)
- Home screen with two primary buttons
- Cloudflare Workers for backend API endpoints
- Cloudflare D1 database setup with core tables (Users, Locations, Supply_Categories, Supplies, Reservations)
- Privy integration for user authentication
- Claude API-powered full-screen chat interface
- Two markdown documents (Provider Guide and Seeker Guide) for AI conversation flow
- Geocoding integration for locations, providers, and seekers
- Basic inventory display through chat responses
- Simple reservation system via chat
- Core notification system (email or SMS via Workers)
- Local storage for offline capability
- Environment variables for Claude API key in Workers
- Deploy script for Cloudflare (wrangler.toml configuration)
**Post-Hackathon Enhancements:**
- Phase 1 Complete: 3-4 months
- Phase 2 Complete: 6-8 months
- Phase 3 Complete: 10-12 months
---
## Team Roles Needed
**For Hackathon:**
- Full-Stack Web Developers (2-3) with Cloudflare experience
- UI/UX Designer (1)
- Backend Developer familiar with Cloudflare Workers and D1
**For Full Production:**
- Product Manager
- UX/UI Designer
- Frontend Developers
- Cloudflare Workers/Backend Developers
- AI/NLP Engineer (Claude API integration)
- DevOps Engineer (Cloudflare infrastructure)
- QA Engineers
- Emergency Management Consultant
---
## Technology Stack Summary
**Frontend:**
- HTML5, CSS3, JavaScript (or React/Vue/Svelte)
- Deployed on Cloudflare Pages
**Backend:**
- Cloudflare Workers (JavaScript/TypeScript)
- Cloudflare D1 (SQLite database)
- Cloudflare KV (Key-value storage)
**AI:**
- Claude API (via Anthropic)
**Tools:**
- Wrangler CLI for deployment
- Git for version control
**External APIs:**
- Claude API for AI features (via Anthropic)
- Privy for authentication
- Geocoding service (Google Maps Geocoding API or similar)
- SMS gateway (Twilio/similar)
- Mapping services (Google Maps/Mapbox)
- Ride-sharing APIs (optional for MVP)
---
*Document Version: 1.0*
*Date: October 14, 2025*
*Status: Initial Specification for Hackathon*