CIVIZ is a Next.js application that combines civic engagement with AI-powered visualization. Users can submit their visions for improving San Francisco locations by providing an address and transformation description, which are then brought to life using Google Street View and DALL-E 3.
- Address Input: Users enter any San Francisco address
- Vision Prompt: Describe how the location should be transformed
- AI Generation: Combines Google Street View with DALL-E 3 to create photorealistic transformed images
- Real-time Feedback: Loading states and progress indicators during image generation
- Category Matching: Automatically categorizes visions (Housing, Parks, Transportation, etc.)
- Points System: Earn points for submitting visions and receiving likes
- Community Views: Toggle between personal visions and city-wide submissions
- Interactive Collage: Browse and like community visions
- Next.js 13+ App Router: Modern React framework with server components
- Zustand State Management: Lightweight state management for vision data
- Tailwind CSS: Responsive design with custom animations
- TypeScript: Full type safety throughout the application
- Error Handling: Comprehensive error handling for API failures
- Node.js 18+ and npm/yarn/pnpm
- Google Cloud Platform account with Maps API enabled
- OpenAI account with API access
git clone <repository-url>
cd civiz
npm installCopy the example environment file and add your API keys:
cp .env.example .env.localEdit .env.local with your API keys:
# Google Street View API
GOOGLE_MAPS_API_KEY=your_google_maps_api_key_here
# OpenAI DALL-E API
OPENAI_API_KEY=your_openai_api_key_here- Go to Google Cloud Console
- Create or select a project
- Enable the Street View Static API
- Create an API key in APIs & Services > Credentials
- Restrict the key to Street View Static API for security
- Go to OpenAI Platform
- Create an account and add billing information
- Generate an API key in API Keys section
- Ensure you have credits for DALL-E 3 usage (~$0.040 per image)
npm run devThe application will be available at http://localhost:3000
- Enter Address: User inputs a San Francisco location (e.g., "Golden Gate Park, SF")
- Describe Vision: User describes desired transformation (e.g., "turn into a sustainable urban farm")
- AI Processing: System fetches Street View image and sends to DALL-E with structured prompt
- Result Display: Generated image appears in the vision collage with loading animations
User Input (Address + Vision)
β
VisionForm Component
β
Zustand Store (submitVision)
β
API Route (/api/transform)
β
Google Street View API β β OpenAI DALL-E 3
β
Generated Image URL
β
Updated Vision Store
β
VisionCollage Display
Fetches Street View images for a given address.
{
"address": "Golden Gate Park, San Francisco, CA"
}Generates AI-transformed images using DALL-E 3.
{
"address": "Golden Gate Park, San Francisco, CA",
"creativePrompt": "turn it into a sustainable urban farm"
}civiz/
βββ app/
β βββ api/
β β βββ streetview/route.ts # Google Street View API endpoint
β β βββ transform/route.ts # DALL-E transformation endpoint
β βββ globals.css
β βββ layout.tsx
β βββ page.tsx
βββ components/
β βββ VisionForm.tsx # Address + vision input form
β βββ VisionCollage.tsx # Image gallery with loading states
β βββ CivizV0.tsx # Main app component
β βββ [other components]
βββ lib/
β βββ visionStore.ts # Zustand state management
β βββ visionService.ts # API service layer
β βββ [utilities]
βββ package.json
- Google Street View: $0.007 per request
- DALL-E 3: ~$0.040 per image generation
- Implement rate limiting and user quotas for production
- Images are fetched as needed (not pre-generated)
- Loading states prevent UI blocking
- Error handling provides user-friendly feedback
- Generated images are displayed directly from OpenAI URLs
The application handles various error scenarios:
- Invalid/expired API keys
- Rate limiting from both APIs
- Content policy violations (OpenAI)
- Network timeouts
- Billing/quota issues
- Update the Vision interface in
lib/visionStore.ts - Modify API endpoints in
app/api/ - Update UI components in
components/ - Add proper TypeScript types
- Use real San Francisco addresses (e.g., "Union Square, SF")
- Try various transformation prompts
- Monitor API usage in respective dashboards
- Test error scenarios by temporarily using invalid API keys
"Google Maps API key not configured"
- Check
.env.localfile exists and has correctGOOGLE_MAPS_API_KEY - Ensure Street View Static API is enabled in Google Cloud Console
"OpenAI billing not configured"
- Add payment method to OpenAI account
- Check billing limits and current usage
"Rate limit exceeded"
- Wait a few minutes between requests during development
- Consider implementing request queuing for production
Images not loading
- Check browser console for CORS errors
- Verify API endpoints are responding correctly
- Check network tab for failed requests
This project is part of a civic engagement initiative for San Francisco.