Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ  KhidmatApp โ€” AI-Powered Home Services Platform

Hackathon Project โ€” An intelligent service marketplace for Pakistan's informal economy, powered by a multi-agent AI orchestration engine.

KhidmatApp connects users with local service providers (AC technicians, electricians, plumbers, beauticians) through a conversational AI interface that understands Roman Urdu, English, and code-switched input. Behind the scenes, a swarm of specialized AI agents handles everything from intent parsing to dynamic pricing to dispute resolution.


๐Ÿ“ Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   React Native (Expo)                โ”‚
โ”‚  ChatInput โ†’ ProviderList โ†’ Pricing โ†’ Booking โ†’      โ”‚
โ”‚  LiveTracking โ†’ Feedback โ†’ Dispute                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚ REST API (fetch)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Express.js Gateway (port 5000)           โ”‚
โ”‚                                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚ Intent Agent โ”‚โ†’โ”‚ Matching     โ”‚โ†’โ”‚ Pricing     โ”‚  โ”‚
โ”‚  โ”‚ (Gemini NLP) โ”‚  โ”‚ Agent        โ”‚  โ”‚ Agent       โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚          โ”‚                โ”‚                โ”‚          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ Booking Agent โ”‚  โ”‚ Follow-upโ”‚  โ”‚ Dispute     โ”‚  โ”‚
โ”‚  โ”‚ (Double-book  โ”‚  โ”‚ Agent    โ”‚  โ”‚ Agent       โ”‚  โ”‚
โ”‚  โ”‚  prevention)  โ”‚  โ”‚ (Timelineโ”‚  โ”‚ (Decision   โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚  sim)    โ”‚  โ”‚  tree)      โ”‚  โ”‚
โ”‚                      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Cloud Firestore + Google Maps API             โ”‚
โ”‚  Collections: providers, bookings, notifications,     โ”‚
โ”‚               agent_logs                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”Œ API Endpoints

Method Endpoint Agent Description
POST /api/parse-intent Intent Agent Parses Roman Urdu/English input into structured JSON via Gemini 2.5 Flash
POST /api/match-providers Matching Agent Ranks providers using a weighted 6-factor scoring algorithm
POST /api/calculate-price Pricing Agent Computes dynamic pricing with 7 factors (base, distance, urgency, complexity, surge, loyalty, budget)
POST /api/book-service Booking Agent Handles booking transactions with double-booking prevention
POST /api/simulate-followup Follow-up Agent Simulates post-booking timeline notifications
POST /api/submit-feedback Follow-up Agent Submits star rating + comment; updates rolling average
POST /api/file-dispute Dispute Agent Processes disputes through a severity-based decision tree

๐Ÿงฎ Provider Matching: 6-Factor Weighted Algorithm

The Matching Agent scores every available provider using a composite weighted formula:

Factor Weight Description
Rating 25% Normalized provider rating (1โ€“5 โ†’ 0โ€“1)
Availability 20% Exact time-slot match = 1.0, partial = 0.5, none = 0.0
Distance 20% Google Maps API driving distance, capped at 20 km (closer = higher score)
Specialization 15% Exact skill match vs. general provider
On-Time Reliability 15% Historical punctuality score (0โ€“1)
Review Recency 5% Exponential decay โ€” recent reviews weighted more

Formula:

score = (rating ร— 0.25) + (availability ร— 0.20) + (distance ร— 0.20) +
        (specialization ร— 0.15) + (onTime ร— 0.15) + (recency ร— 0.05)

Providers are sorted descending by score. The top recommendation includes a reasoning trace explaining why it beat the runner-up (e.g., "Selected despite being 1.8km farther due to 31% higher reliability").


๐Ÿ—ƒ๏ธ Provider Schema (Firestore)

{
  "id": "prov_ac_001",
  "name": "Ali AC Services (G-13)",
  "service_types": ["AC technician"],
  "location": { "lat": 33.6442, "lng": 72.9918, "area": "G-13" },
  "rating": 4.5,
  "on_time_score": 0.96,
  "cancellation_rate": 0.02,
  "price_per_hour": 2500,
  "specializations": ["Inverter AC Fix", "Split AC Maintenance", "Gas Charging"],
  "availability_slots": ["09:00-12:00", "13:00-16:00", "17:00-20:00"],
  "risk_score": "low"
}

๐Ÿค– Antigravity Workflow Engine

The service lifecycle is orchestrated as a state machine with 7 states:

INTENT_PARSING โ†’ PROVIDER_MATCHING โ†’ PRICING โ†’ BOOKING โ†’
LIVE_TRACKING โ†’ FEEDBACK โ†’ DISPUTE_RESOLUTION (optional)

Each transition is driven by the API response of the previous state:

  • If confidence_score < 0.70 โ†’ loop back to INTENT_PARSING with a clarification question
  • If ranked_list is empty โ†’ fallback to broadening the search radius
  • If conflict: true on booking โ†’ suggest alternative time slots
  • If dispute severity === "serious" โ†’ escalate to human support, freeze funds

All transitions emit structured reasoning traces to console.log and Firestore agent_logs.


๐Ÿ’ฐ Dynamic Pricing: 7-Factor Formula

Factor Formula Example
Base Price provider.price_per_hour ร— hours 2500 ร— 2 = 5000 PKR
Distance Cost max(0, km - 3) ร— 20 5 km โ†’ 40 PKR
Urgency ร— 1.0 / 1.2 / 1.5 Same-day = ร—1.2
Complexity ร— 1.0 / 1.3 / 1.6 Intermediate = ร—1.3
Surge (Peak Hours) ร— 1.3 if 17:00โ€“20:00 Evening booking = ร—1.3
Loyalty Discount โˆ’5% if returning user โˆ’325 PKR
Budget Alternative Find cheaper provider Suggest alternative

๐Ÿ›ก๏ธ Dispute Resolution Decision Tree

Severity Action Refund
Minor Auto-credit PKR 100 flat
Moderate Partial refund 30% of booking total
Serious Escalate to human + freeze funds Full review

Provider risk scoring: cancellation/no-show events increment cancellation_rate. If rate > 20%, provider is flagged as HIGH RISK and deprioritized in matching.


๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+
  • Expo CLI (npm install -g expo-cli)
  • Firebase project with Firestore enabled
  • Google Maps API key (Distance Matrix enabled)
  • Gemini API key

Backend Setup

cd backend
npm install
# Create .env with: PORT, GEMINI_KEY, MAPS_KEY, FIREBASE_PROJECT_ID
# Place firebase-service-account.json in backend/
node -r dotenv/config index.js

Mobile Setup (Expo)

cd mobile
npm install
npx expo start
# Press 'w' for web, or scan QR with Expo Go app

Environment Variables

Variable Description
PORT Backend server port (default: 5000)
GEMINI_KEY Google Gemini API key for NLP processing
MAPS_KEY Google Maps API key for distance calculations
FIREBASE_PROJECT_ID Firebase project identifier

๐Ÿ“Š Cost & Latency Estimates

Component Latency Cost per Request
Gemini 2.5 Flash (NLP) ~800msโ€“2s ~$0.0001 (input) + ~$0.0004 (output)
Google Maps Distance Matrix ~200ms $5 per 1000 elements
Firestore Read/Write ~50ms $0.06 per 100K reads
Full Booking Flow ~3โ€“5s ~$0.005 total

โš ๏ธ Assumptions & Limitations

Assumptions

  • Provider data is pre-seeded in Firestore (15 providers across 5 service categories)
  • User authentication is simulated (hardcoded user_id strings)
  • WhatsApp notifications are simulated via console logs
  • Review recency uses a fixed 5-day decay (no real timestamp tracking)
  • Geocoding uses a mock lookup table for Islamabad sectors

Limitations

  • No real-time GPS tracking (timeline is simulated with setTimeout)
  • No payment gateway integration (prices are calculated but not charged)
  • No image/voice input support (text-only NLP)
  • Provider availability resets require manual Firestore updates
  • Surge pricing is time-slot-based, not demand-based
  • No multi-language UI (interface is English-only; NLP supports Urdu input)

๐Ÿ“ Project Structure

antigravity-service-app/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ agents/
โ”‚   โ”‚   โ”œโ”€โ”€ intentAgent.js        # Gemini-powered NLP
โ”‚   โ”‚   โ”œโ”€โ”€ matchingAgent.js      # 6-factor provider ranking
โ”‚   โ”‚   โ”œโ”€โ”€ pricingAgent.js       # Dynamic pricing engine
โ”‚   โ”‚   โ”œโ”€โ”€ bookingAgent.js       # Booking + double-booking prevention
โ”‚   โ”‚   โ”œโ”€โ”€ followupAgent.js      # Timeline simulation + feedback
โ”‚   โ”‚   โ””โ”€โ”€ disputeAgent.js       # Severity-based dispute resolution
โ”‚   โ”œโ”€โ”€ docs/                     # Stress test results & traces
โ”‚   โ”œโ”€โ”€ workflows/                # State machine definitions
โ”‚   โ”œโ”€โ”€ index.js                  # Express gateway
โ”‚   โ””โ”€โ”€ .env                      # API keys
โ”œโ”€โ”€ mobile/
โ”‚   โ”œโ”€โ”€ screens/
โ”‚   โ”‚   โ”œโ”€โ”€ ChatInputScreen.js
โ”‚   โ”‚   โ”œโ”€โ”€ ProviderListScreen.js
โ”‚   โ”‚   โ”œโ”€โ”€ PricingScreen.js
โ”‚   โ”‚   โ”œโ”€โ”€ BookingConfirmationScreen.js
โ”‚   โ”‚   โ”œโ”€โ”€ LiveTrackingScreen.js
โ”‚   โ”‚   โ”œโ”€โ”€ FeedbackScreen.js
โ”‚   โ”‚   โ””โ”€โ”€ DisputeScreen.js
โ”‚   โ”œโ”€โ”€ config.js                 # API base URL config
โ”‚   โ””โ”€โ”€ App.js                    # Navigation + font loading
โ””โ”€โ”€ README.md

๐Ÿ† Tech Stack

Layer Technology
Frontend React Native (Expo SDK 55)
Backend Express.js (Node.js)
Database Cloud Firestore
NLP Engine Google Gemini 2.5 Flash
Distance API Google Maps Distance Matrix
Fonts Inter (Google Fonts)
Icons Expo Vector Icons (Ionicons, Feather)
Animations React Native Animated API

Built during a hackathon with โค๏ธ and Antigravity.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages