Khabri is a real-time city issue reporting platform that uses Google Gemini AI to validate, aggregate, and escalate citizen reports to government authorities. The platform reduces noise through intelligent aggregation and provides transparency to citizens about government response.
- AI-Powered Validation: Gemini AI validates reports for authenticity and quality
- Noise Reduction: Aggregates multiple reports of same issue into clean data
- Government Integration: Severity-aware threshold monitoring with department routing
- Real-time Transparency: Citizens can see escalation status and government response
- Social Media Integration: Processes Twitter/X reports through same AI pipeline
- Backend: Google Firebase (Auth, Firestore, Functions, Storage)
- AI Processing: Google Gemini AI (Multimodal analysis)
- Message Queue: Google Cloud Pub/Sub
- Notifications: FCM, SMS Gateway, Email Service
- Language: TypeScript/Node.js
Current Phase: Setup & Planning
Development Timeline: 8-10 weeks to MVP
Last Updated: January 2024
- Architecture Design & Documentation
- Low Level Design (LLD)
- API Specifications & Mock Stubs
- Phase 1: Project Setup & Infrastructure
- Phase 2: Authentication System
- Phase 3: Core Report Processing
- Phase 4: Gemini AI Integration
- Phase 5: Aggregation System
- Phase 6: Government Threshold & Alerts
- Phase 7: Location-based API
- Phase 8: Social Media Integration
- Phase 9: Testing & Quality Assurance
- Phase 10: Deployment & Production
- Node.js 18+
- npm or yarn
- Google Cloud Platform account
- Firebase CLI
- Git
# Clone the repository
git clone https://github.com/your-org/khabri-backend.git
cd khabri-backend
# Install dependencies
npm install
# Install Firebase CLI globally
npm install -g firebase-tools
# Login to Firebase
firebase login
# Initialize Firebase project (follow prompts)
firebase init# Copy environment template
cp .env.example .env.local
# Edit environment variables
# Add your Firebase config, Gemini AI keys, etc.
nano .env.local# Start Firebase emulators
npm run emulators
# Start development server
npm run dev
# Run tests
npm test
# Deploy to staging
npm run deploy:stagingkhabri-backend/
βββ docs/ # Documentation
β βββ LOW_LEVEL_DESIGN.md # Technical specifications
β βββ API_STUBS.md # Mock API for frontend
β βββ DEVELOPMENT_PLAN.md # Implementation roadmap
βββ functions/ # Firebase Cloud Functions
β βββ src/
β β βββ auth/ # Authentication services
β β βββ reports/ # Report processing
β β βββ aggregation/ # Data aggregation
β β βββ ai/ # Gemini AI integration
β β βββ government/ # Government alerts
β β βββ location/ # Location-based APIs
β β βββ utils/ # Utility functions
β βββ package.json
β βββ tsconfig.json
βββ firestore/ # Firestore configuration
β βββ rules/ # Security rules
β βββ indexes.json # Database indexes
βββ storage/ # Cloud Storage rules
βββ scripts/ # Build and deployment scripts
βββ tests/ # Test suites
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
β βββ e2e/ # End-to-end tests
βββ .github/ # GitHub workflows
β βββ workflows/ # CI/CD pipelines
βββ firebase.json # Firebase configuration
βββ .firebaserc # Firebase project settings
βββ package.json # Root package configuration
βββ README.md # This file
# Development
npm run dev # Start development server
npm run build # Build for production
npm run serve # Serve built functions locally
# Testing
npm test # Run all tests
npm run test:unit # Run unit tests
npm run test:integration # Run integration tests
npm run test:e2e # Run end-to-end tests
npm run test:coverage # Generate coverage report
# Firebase
npm run emulators # Start Firebase emulators
npm run emulators:ui # Start emulators with UI
npm run deploy:staging # Deploy to staging
npm run deploy:prod # Deploy to production
# Code Quality
npm run lint # Lint TypeScript code
npm run lint:fix # Fix linting issues
npm run format # Format code with Prettier
npm run type-check # TypeScript type checking
# Database
npm run db:backup # Backup Firestore data
npm run db:seed # Seed test data
npm run db:migrate # Run database migrationsusers/{userId}- User profiles and trust scoresreports/{reportId}- Individual validated reports (internal processing)aggregations/{aggregationId}- Noise-reduced aggregated issues (API primary source)government_alerts/{alertId}- Government notification trackingthresholds/config- System configuration and thresholds
See Low Level Design for complete schema specifications.
POST /auth/register- User registrationPOST /auth/login- User authentication
POST /reports/submit- Submit new issue reportGET /reports/my-reports- Get user's reportsGET /reports/{reportId}- Get report details
GET /location/escalated-reports- Get nearby escalated issuesGET /location/heatmap- Get issue density data
GET /government/dashboard- Official dashboard data
See API Stubs for complete API documentation and mock responses.
- Individual function testing
- Mock external dependencies
- 90%+ code coverage target
- Firebase services integration
- Gemini AI pipeline testing
- End-to-end workflows
- Aggregation system performance
- API response times
- Concurrent user handling
- Firebase Performance Monitoring: API performance tracking
- Google Cloud Logging: Centralized log aggregation
- Custom Metrics: Business KPIs and system health
- Alerting: SLA monitoring and incident response
- Development: Local emulators
- Staging: Firebase staging project
- Production: Firebase production project
- Pull Request: Automated testing and linting
- Staging Deployment: Auto-deploy to staging on merge to
develop - Production Deployment: Manual approval for
mainbranch - Rollback: Automated rollback on critical errors
We welcome contributions! Please read our Contributing Guidelines before submitting PRs.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes following our coding standards
- Write/update tests for your changes
- Run the test suite:
npm test - Commit with conventional commit format:
feat: add amazing feature - Push to your fork:
git push origin feature/amazing-feature - Submit a Pull Request
We use Conventional Commits:
type(scope): description
[optional body]
[optional footer]
Types: feat, fix, docs, style, refactor, test, chore
Please report security vulnerabilities to: security@khabri.com
- Firebase Authentication with JWT tokens
- Firestore Security Rules for data access control
- Image encryption in Cloud Storage
- API rate limiting and abuse prevention
- Regular security audits and dependency updates
- Location API: <500ms response time
- Report Submission: <2s processing time
- AI Validation: <5s end-to-end
- Government Alerts: <1s delivery time
- Uptime: 99.9% availability
- Documentation: docs/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@khabri.com
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Firebase team for the robust platform
- Google Gemini AI for multimodal capabilities
- Open source community for tools and libraries
Built with β€οΈ for better cities and transparent governance