Skip to content

Latest commit

 

History

History
124 lines (103 loc) · 6.68 KB

File metadata and controls

124 lines (103 loc) · 6.68 KB

Backend MVP Implementation Checklist

Overview & Goal

Transform the static MVP into a dynamic, location-aware civic event discovery platform with AI-generated content, persistent storage, and push notifications.

Phase 1: Core Backend Infrastructure

1. Local Storage Persistence ✅

  • Install and configure AsyncStorage for saved events persistence
  • Update EventsContext to load/save events from AsyncStorage on app start
  • Add loading states while hydrating saved events from storage
  • Implement data migration for future app updates

2. Location Services ✅

  • Install expo-location package
  • Add location permissions to app.json
  • Implement GPS-based location detection on app launch
  • Create location search functionality for the expandable button
  • Add location preference storage and retrieval
  • Handle location permission denials gracefully

3. Perplexity AI Integration

3.1 Card Generation (Sonar Pro) ✅

  • Create API service wrapper for Perplexity API using the API key from the .env.local file
    • Implementation: utils/perplexity-api.ts with full error handling
  • Use the Perplexity Sonar Pro to generate event cards
    • Implementation: Uses sonar-pro model with temperature 0.2 for consistent output
  • Implement event card generation endpoint that takes user location as input using location data that's already stored
    • Implementation: contexts/discovery-events-context.tsx with fetchEvents() method
  • Generate cards with required fields: location, name, AI overview, date, time, address
    • Implementation: Three-tier type system (PerplexityEventData → DiscoveredEvent → SerializedEvent)
  • Create the prompt for the Perplexity Sonar Pro to generate event cards
    • Implementation: utils/event-generation.ts - generates civic/political events with structured JSON output
  • Target: Generate maximum possible civic/political events for the next month
    • Implementation: Prompt configured for month-long event discovery with search_recency_filter
  • Add API response caching (6-24 hour cache durations)
    • Implementation: 12-hour TTL cache system in utils/event-cache.ts with AsyncStorage
  • Implement fallback data for API failures
    • Implementation: 3 hardcoded sample events (Phoenix/Austin/Seattle) when API fails
  • Add rate limiting and retry logic
    • Implementation: 3 retry attempts with exponential backoff (1s, 2s, 4s), respects Retry-After header
  • Trigger generation on location change or manual refresh
    • Implementation: DiscoveryEventsContext with fetchEvents() and refreshEvents() methods
  • The API search doesn't really work every time, logs an error with the API fetch. Figure out why these are happening. The solution was adding a 60 second cooldown between searches. UPDATE: Cooldown removed as requested.
  • Should remove the fallback test cards and instead just show the search failed, with a retry button

3.2 Visual Indicators

  • Should have visual indicators of which card you're at and how many are left
  • Something that's engaging to see when AI response is loading

3.3 View Details Generation (Sonar Pro)

  • This will use Perplexity Sonar Pro to create the back of the cards when view details is clicked
  • Implement "View Details" backend that triggers on card flip
  • Generate back-of-card data structure:
    • Top section: Venue name, full address (with map link), organizer, website link
    • Bottom section: "Impact of This Event" paragraph, three pre-generated Q&A pairs (Who is this for?, Why does it matter?, What should I expect?) under that similar to recently asked question in the google ui when viewing search results

3.3.1 Fixing scrolling

  • I'm not able to scroll the card when the text get's longer than the horizontal limits of the card viewport
  • The scrolling on the front of the card is not working when starting on the middle of the screen. Might not be super user friendly since people don't know where to start scrolling
  • The current scrolling mechanism on the back of the card where you start from the close details card might not be super intuitive.

3.4 Loading Animation & Cache

  • Add loading animation trigger point before API call
  • Add AI text generation animation trigger point after API response
  • Cache detailed view data per event to avoid regenerating

4. Image Integration

  • Set up Unsplash API integration for event images
  • Implement 15 fallback curated images for common event types
  • Create image URL validation and error handling, if image api doesn't return an image, use the fallback image
  • Implement progressive loading, the loader that was initally for the perplexity response should now also include the images loading

Phase 2: Database & Cloud Services

5. Push Notifications

  • Install expo-notifications package
  • Configure notification permissions and settings in app.json
  • Implement local notification scheduling for saved events
  • Add reminder preference options (1 hour, 1 day, 1 week before)
  • Create notification tap handling to navigate to events
  • Add notification management (cancel, update) for removed events

Phase 3: Scaling for more users

6. Supabase Setup

  • Initialize Supabase project and configure connection
  • Create database schema for users, saved events, location preferences
  • Implement Row Level Security (RLS) policies for data protection
  • Set up Supabase Storage for cached images and user data
  • Add cross-device sync for saved events
  • Configure environment variables for Supabase credentials

Dependencies & Environment Setup

Required Packages

  • @react-native-async-storage/async-storage
  • expo-location
  • expo-notifications
  • @supabase/supabase-js
  • Any additional utility packages for API handling

Environment Variables

  • PERPLEXITY_API_KEY - For AI content generation
  • EXPO_PUBLIC_SUPABASE_URL - Supabase project URL
  • EXPO_PUBLIC_SUPABASE_KEY - Supabase public key
  • UNSPLASH_ACCESS_KEY - For event images (optional)

API Services Setup

  • Perplexity AI API access and key configuration
  • Unsplash API access for images
  • Supabase project creation and configuration
  • Test API connections and rate limits

Success Metrics

Functional Requirements

  • Users can save events that persist across app restarts
  • Location detection works and filters events appropriately
  • AI generates relevant civic events with accurate details
  • Images load reliably and are contextually appropriate
  • Push notifications work for saved events
  • App functions offline with cached data