LafaekStreet Public Dashboard β
Live: https://www.lafaekstreet.com
A cutting-edge civic engagement platform that empowers citizens of Timor-Leste to report infrastructure issues and track their resolution through an intelligent public dashboard powered by Amazon Nova 2 Lite AI.
π― AI-Powered Civic Engagement β
This project showcases the power of Amazon Nova 2 Lite in transforming civic engagement through:
- Intelligent Chat Assistant (RuaLafaek) - Natural language queries about infrastructure data
- Real-time Data Analysis - AI-powered insights from citizen reports
- Smart Query Processing - Converting natural language to database queries
- Automated Response Generation - Context-aware responses with suggestions
π What's Already Implemented β
β Core Platform Features β
π Dashboard Homepage β

- Real-time Statistics Cards: Total reports, pending, in-progress, and fixed counts
- Interactive Map Preview: Clustered markers showing report locations
- Performance Metrics: Response times, resolution rates, and system health
- Recent Activity Feed: Live updates of platform activity
- Quick Action Navigation: Direct access to all major features
πΊοΈ Interactive Map System β

- Full-screen Map Interface: Leaflet-based mapping with OpenStreetMap tiles
- Smart Marker Clustering: Automatic grouping of nearby reports for better performance
- Advanced Filtering: Filter by status, issue type, municipality, and date ranges
- Color-coded Status Indicators: Visual distinction between pending, in-progress, fixed, and rejected reports
- Detailed Popups: Rich information display for each report marker
- Responsive Design: Optimized for both desktop and mobile viewing
π Comprehensive Statistics β

- Multi-dimensional Analytics: Reports by type, municipality, and time series
- Interactive Charts: Pie charts, bar charts, and line graphs using Recharts
- Performance Tracking: Resolution rates, average response times, and trends
- Municipality Breakdown: Detailed statistics for each region in Timor-Leste
- Time Series Analysis: 30-day trend visualization with submission patterns
π Report Management β

- Advanced Search & Filtering: Multi-criteria filtering with real-time updates
- Pagination System: Efficient handling of large datasets
- Detailed Report Views: Complete report information with images and status history
- Status Tracking: Visual indicators for report lifecycle stages
- AI-Powered Similarity Search: Vector-based similar report detection using Amazon Nova 2 Multimodal Embeddings
- Mobile-optimized Interface: Responsive design for all screen sizes

π€ RuaLafaek AI Chat Assistant (Amazon Nova 2 Lite Integration) β

Core AI Capabilities β
- Natural Language Processing: Understands citizen queries in conversational language
- Intelligent Query Classification: Automatically categorizes questions as database queries, general info, or help requests
- Dynamic SQL Generation: Converts natural language to safe PostgreSQL queries
- Context-aware Responses: Provides relevant, formatted answers with follow-up suggestions
- Multi-step AI Pipeline: Sophisticated processing chain for optimal results
Security & Protection β
- hCaptcha Integration: Bot protection with verification system
- Input Validation: 500-character limit with safety checks
- SQL Injection Prevention: Whitelist-only query validation
- Rate Limiting: Protection against abuse and automated requests
User Experience β
- Floating Chat Widget: Non-intrusive interface with custom AI mascot
- Rich Markdown Responses: Formatted text with headers, lists, and emphasis
- Suggestion System: Contextual follow-up questions for continued engagement
- Error Handling: Graceful fallbacks with helpful error messages
- Theme Integration: Seamless light/dark mode support
π AI-Powered Similarity Search β

Vector Embedding Technology β
- Amazon Nova 2 Multimodal Embeddings: Generates 1024-dimensional vectors from report content
- Multimodal Analysis: Combines text descriptions and image content for comprehensive similarity
- pgvector Integration: PostgreSQL extension for efficient vector operations
- Cosine Similarity: Mathematical similarity scoring between 0-1
Smart Detection β
- Automatic Processing: All reports generate embeddings upon submission
- Configurable Thresholds: Default 50% similarity threshold (adjustable 0-100%)
- Real-time Search: Find similar reports instantly from any report detail page
User Interface Features β
- "Find Similar" Button: One-click similarity search from report details
- Similarity Scores: Visual percentage indicators showing relationship strength
- Smart Filtering: Results filtered by relevance and public visibility
- Loading States: Real-time feedback during embedding analysis
Technical Implementation β
-- Vector similarity query using cosine distance
SELECT r.*, (1 - (e2.embedding <=> e1.embedding)) as similarity_score
FROM report_embeddings e1
JOIN report_embeddings e2 ON e1.embedding_type = e2.embedding_type
JOIN reports r ON e2.report_id = r.id
WHERE e1.report_id = $1 AND similarity_score >= $2
ORDER BY similarity_score DESCUse Cases β
- Citizens: Discover if their issue has been reported before
- Government: Identify patterns and recurring problem areas
- Analytics: Track similar infrastructure issues across regions
- Fraud Prevention: Detect potential duplicate or spam reports
ποΈ System Architecture β
π AI Chat Flow Diagram β
π οΈ Technology Stack β
Frontend β
- Next.js 14: App Router with server-side rendering and static generation
- React 19: Latest React features with concurrent rendering
- TypeScript: Full type safety across the application
- Tailwind CSS: Utility-first styling with custom design system
- Framer Motion: Smooth animations and transitions
AI & Machine Learning β
- Amazon Nova 2 Lite: Advanced language model via AWS Bedrock
- Amazon Nova 2 Multimodal Embeddings: 1024-dimensional vectors for similarity search
- LangChain: AI application framework for complex workflows
- AWS Bedrock: Managed AI service infrastructure
- Natural Language Processing: Query understanding and response generation
- Vector Similarity Search: pgvector with cosine similarity for duplicate detection
Backend & Database β
- PostgreSQL: Robust relational database with advanced features
- pgvector Extension: Vector similarity search with 1024-dimensional embeddings
- Prisma ORM: Type-safe database access with migrations
- Next.js API Routes: Serverless API endpoints
- Connection Pooling: Optimized database performance
Maps & Visualization β
- Leaflet: Open-source mapping library
- React Leaflet: React integration for Leaflet
- Marker Clustering: Performance optimization for large datasets
- Recharts: Responsive chart library for data visualization
Security & Validation β
- hCaptcha: Bot protection and verification
- Input Sanitization: XSS and injection prevention
- SQL Safety Validation: Whitelist-based query filtering
- Environment Variable Management: Secure configuration handling
π Getting Started β
Prerequisites β
- Node.js 18+
- PostgreSQL 14+
- AWS Account with Bedrock access
- hCaptcha account (optional, for bot protection)
Installation β
Clone the repository
bashgit clone https://github.com/ajitonelsonn/lafaekstreet.git cd lafaekstreet_dashboardInstall dependencies
bashnpm installEnvironment Setup
bashcp .env.example .env.localConfigure Environment Variables
env# Database DATABASE_URL="postgresql://user:password@localhost:5432/lafaekstreet" # AWS Configuration (Required for AI Chat) AWS_REGION="us-east-1" AWS_ACCESS_KEY_ID="your_access_key" AWS_SECRET_ACCESS_KEY="your_secret_key" BEDROCK_MODEL_ID="us.amazon.nova-2-lite-v1:0" # hCaptcha (Optional) NEXT_PUBLIC_HCAPTCHA_SITE_KEY="your_site_key" HCAPTCHA_SECRET_KEY="your_secret_key" # App Configuration NEXT_PUBLIC_APP_URL="http://localhost:3000"Database Setup
bashnpm run db:generateStart Development Server
bashnpm run devOpen Application Navigate to http://localhost:3000 (local) or https://www.lafaekstreet.com (production)
π Project Structure β
lafaekstreet_dashboard/
βββ app/ # Next.js App Router
β βββ api/ # API Routes
β β βββ chat/ # AI Chat endpoint
β β βββ statistics/ # Statistics APIs
β β βββ reports/ # Report management APIs
β β βββ health/ # Health check endpoints
β βββ map/ # Interactive map page
β βββ reports/ # Report browsing page
β βββ statistics/ # Analytics dashboard
β βββ layout.tsx # Root layout with AI chat
βββ components/ # React Components
β βββ chat/ # AI Chat components
β β βββ LafaekAIChat.tsx # Main chat widget
β β βββ ChatMessage.tsx # Message rendering
β β βββ ChatInput.tsx # Input with validation
β βββ map/ # Map components
β βββ statistics/ # Chart components
β βββ reports/ # Report components
β βββ common/ # Shared components
βββ lib/ # Utilities & Configuration
β βββ ai/ # AI Integration
β β βββ nova-client.ts # Amazon Nova client
β β βββ database-handler.ts # SQL generation
β β βββ web-scraper.ts # General info handler
β βββ prisma.ts # Database client
β βββ hcaptcha.ts # Bot protection
βββ prisma/ # Database Schema
βββ public/ # Static Assets
βββ styles/ # Global Stylesπ API Endpoints β
Core Data APIs β
GET /api/statistics- Dashboard statistics and metricsGET /api/reports- Paginated reports with advanced filteringGET /api/reports/[id]- Individual report detailsGET /api/reports/[id]/similar- AI-powered similar reports using vector embeddingsGET /api/reports/map- Optimized data for map visualization
AI Chat API β
POST /api/chat- Main AI chat endpoint with Nova integrationGET /api/health/db- Database connectivity check
Analytics APIs β
GET /api/statistics/by-type- Reports grouped by issue typeGET /api/statistics/by-municipality- Regional breakdownGET /api/statistics/time-series- Trend analysis data
π¨ Features Showcase β
Intelligent Conversational Interface β
- Natural language queries: "Show me all potholes in Dili"
- Context-aware responses with rich formatting
- Follow-up suggestions for continued exploration
- Multi-language support preparation
Advanced Data Visualization β
- Real-time dashboard with live statistics
- Interactive charts with hover details and animations
- Geographic visualization with clustering algorithms
- Responsive design optimized for all devices
AI-Powered Similarity Search β
- Vector-based similar report detection using 1024-dimensional embeddings
- Multimodal analysis combining text and image content
- Configurable similarity thresholds for precise matching
- Real-time duplicate detection and fraud prevention
Comprehensive Filtering System β
- Multi-criteria search across all report fields
- Date range filtering with calendar integration
- Geographic filtering by municipality and district
- Status and priority-based filtering
Performance Optimizations β
- Server-side rendering for fast initial loads
- Incremental static regeneration for cached content
- Database query optimization with indexing
- Image optimization and lazy loading
π Security Implementation β
AI Chat Security β
- hCaptcha verification prevents automated abuse
- Input length limits (500 characters) prevent overload
- SQL injection prevention with whitelist validation
- Rate limiting protects against spam attacks
Data Protection β
- Environment variable encryption for sensitive data
- Database connection pooling with secure credentials
- HTTPS enforcement in production environments
- Input sanitization across all user inputs
π Amazon Nova Integration Highlights β
Why Amazon Nova 2 Lite? β
- Cost-effective: Optimized for high-volume civic engagement use cases
- Fast Response Times: 3-8 second average response for complex queries
- Reliable Performance: Consistent quality for government applications
AI Pipeline Architecture β
- Question Classification: Determines query type (database/general/help)
- Context Processing: Analyzes user intent and required data
- Query Generation: Converts natural language to safe SQL
- Response Formatting: Creates markdown-formatted, user-friendly responses
- Suggestion Generation: Provides relevant follow-up questions
Real-world Impact β
- Citizen Empowerment: Easy access to infrastructure data
- Government Transparency: Open data with intelligent querying
- Scalable Architecture: Ready for nationwide deployment
π Deployment & Production β
Hosting: Vercel β
- Deployed on Vercel at https://www.lafaekstreet.com
- Automatic deployments from Git
- Environment-specific configuration management
- Serverless API routes with edge optimization
Performance Monitoring β
- Real-time API response tracking
- Database query performance analysis
- AI model usage and cost monitoring
- User engagement analytics
οΏ½ Project Summary β
LafaekStreet demonstrates the transformative power of Amazon Nova 2 Lite in civic engagement, providing citizens of Timor-Leste with an intelligent, accessible platform for infrastructure reporting and government transparency. The AI-powered chat assistant, RuaLafaek, makes complex data queries as simple as asking a question in natural language, bridging the gap between citizens and their government data.
Key Innovation: Converting natural language citizen queries into actionable database insights, making government data truly accessible to everyone.
