HomeBlogHow to Develop an On-Demand Service...

Engineering Guide · 9 min read · July 5, 2026

How to Develop an On-Demand Service Application

Most on-demand service apps break not on the UI, but on concurrency and payout edge cases: two customers booking the same technician, stale provider GPS coordinates, or messy refund splits. Here is how to architect scheduling locks, PostGIS matching, state machines, and escrow payouts.

Author
Smit Desai
Published
July 5, 2026
Read time
9 min read
Topic
Mobile Apps
Services
Custom Web · Mobile Apps · All Services

Every entrepreneur sketching an on-demand service app—home maintenance in Dubai, mobile mechanics in Texas, physiotherapy visits in London, or pet care in Sydney—starts with the booking screen. Yet the hardest engineering problems sit underneath: matching nearby supply without burning battery, preventing double-bookings under concurrent taps, enforcing strict job state transitions, and splitting payments cleanly when plans change.

Shipping an on-demand marketplace reliably means building a state-machine-driven backend first, then wrapping clean mobile apps around it.

Single App vs. Dual Apps: Choosing the Right Client Topology

Early founders often ask whether customers and service providers should live inside one mobile binary.

Architecture Option Pros Cons Best Fit
Two Apps (Customer + Provider) Sharing Packages Lean permissions, focused UX, independent store release cycles, cleaner background GPS rules Two App Store / Play Store listings to maintain Cleaning, repair, beauty, roadside, tutoring, courier services
Single App with Role Toggle One store submission and binary Bloated permissions (customers asked for background location), complex navigation state Peer-to-peer rentals where users frequently swap sides

Even with two binaries in Flutter or React Native, keep shared API clients, DTO types, and design tokens in a single shared repository so validation rules never drift between customer and provider apps.

Geospatial Matching Without Destroying Provider Batteries

Querying every provider's latitude and longitude on every customer search does not scale, and polling provider GPS every two seconds drains phones by noon.

Adaptive Location Pings + Redis Geo & PostGIS

Split location handling into two tiers:

  1. Live Availability (Redis GEOADD): Online providers send throttled location pings—every 30–60 seconds when idle, shifting to every 5–10 seconds only while actively en route to a job. Store ephemeral coordinates in Redis with a 5-minute TTL so offline providers automatically drop out of search results.
  2. Service Territory & Scheduled Dispatch (PostGIS): For scheduled services (plumbers, cleaners, mobile clinicians), query service polygons or travel radii directly in PostgreSQL using GEOGRAPHY indexes:
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS btree_gist;

CREATE TABLE provider_profiles (
    user_id UUID PRIMARY KEY,
    service_radius_meters INT NOT NULL DEFAULT 15000,
    base_location GEOGRAPHY(Point, 4326) NOT NULL,
    is_verified BOOLEAN NOT NULL DEFAULT FALSE
);

CREATE INDEX idx_provider_location ON provider_profiles USING GIST (base_location);

-- Find verified providers within their configured service radius of customer (lon, lat)
SELECT user_id,
       ST_Distance(base_location, ST_SetSRID(ST_MakePoint($1, $2), 4326)::geography) AS distance_m
FROM provider_profiles
WHERE is_verified = TRUE
  AND ST_DWithin(
        base_location,
        ST_SetSRID(ST_MakePoint($1, $2), 4326)::geography,
        service_radius_meters
      )
ORDER BY distance_m ASC
LIMIT 20;

Eliminating Double-Bookings at the Database Layer

A classic race condition in early marketplaces happens during high demand: two customers tap Confirm Booking for the same 2:00 PM slot within 80 milliseconds. If your API merely runs SELECT count(*) ... and then INSERT, both transactions read zero conflicts and both succeed.

Solve this permanently with a PostgreSQL exclusion constraint (tstzrange):

CREATE TABLE bookings (
    id UUID PRIMARY KEY,
    customer_id UUID NOT NULL,
    provider_id UUID NOT NULL,
    slot TSTZRANGE NOT NULL,
    status VARCHAR(24) NOT NULL, -- 'held' | 'confirmed' | 'in_progress' | 'completed' | 'cancelled'
    CONSTRAINT no_overlapping_active_bookings
        EXCLUDE USING gist (
            provider_id WITH =,
            slot WITH &&
        )
        WHERE (status IN ('held', 'confirmed', 'in_progress'))
);

Now PostgreSQL itself guarantees zero overlapping active bookings for any provider, even across ten horizontally scaled API containers. When a customer initiates checkout, insert a 'held' row with a 10-minute expiration job in Redis/BullMQ; if payment fails or times out, the worker flips the status to 'cancelled' and immediately frees the slot.

Enforcing the Booking State Machine

On-demand operations break when client apps send arbitrary status strings ("done", "cancelled"). Protect every transition with an explicit server-side state table and audit log:

const ALLOWED_TRANSITIONS: Record<string, string[]> = {
  held: ['confirmed', 'cancelled'],
  confirmed: ['en_route', 'cancelled'],
  en_route: ['arrived', 'cancelled'],
  arrived: ['in_progress', 'no_show'],
  in_progress: ['completed', 'disputed'],
  completed: ['disputed'],
};

export function assertValidTransition(current: string, next: string): void {
  const allowed = ALLOWED_TRANSITIONS[current] ?? [];
  if (!allowed.includes(next)) {
    throw new Error(`Invalid booking transition: ${current} -> ${next}`);
  }
}

Combine this with role checks (only the assigned provider can move confirmed -> en_route, while only an admin or verified OTP/PIN check can resolve disputed). Requiring a 4-digit job start/completion PIN shared verbally between customer and provider eliminates "provider marked job done without showing up" disputes.

Payments, Escrow, and Real-World Operations Admin

Following the Android app architecture guide and clean API boundaries, isolate billing behind a dedicated payment ledger rather than scattering Stripe webhooks across controllers:

  • Authorization vs. Capture: For short on-demand jobs, authorize the estimated amount at dispatch and capture the final metered amount on completion. For scheduled multi-day services, capture into your platform balance and schedule a Stripe Connect transfer after a 24-hour dispute window.
  • Webhook Idempotency: Store every incoming gateway event ID (stripe_event_id) in a unique table column before mutating booking balances so duplicate webhook deliveries never double-credit a provider wallet.
  • Operations Admin Panel: Launch day one with a lightweight web console where support staff can reassign stalled jobs, override travel fees, issue partial refunds, and inspect provider KYC documents—this prevents founders from running SQL updates by hand at midnight.

Check our mobile app development guide for offline field sync patterns, or browse our shipped case studies to see marketplace systems in production.

Launch Your On-Demand Platform with SmitDev

At SmitDev, I build complete two-sided mobile ecosystems—Flutter or React Native apps for customers and providers, hardened Node.js/Laravel/FastAPI backends, PostGIS dispatch engines, and operations admin portals—drawing on 170+ shipped engagements since 2017.

Start with a structured launch consulting sprint to lock in unit economics, booking state machines, and compliance boundaries, or bring on dedicated senior full-stack engineering at $55/day (8–9 focused hours) or $1,999/month. Reach out via our contact page or review our mobile app development practice to scope your launch.

Written by Smit Desai · Principal Full-Stack & FDSE

8+ years shipping production systems · 171 case studies · 300+ WordPress servers managed for Finland partners.

Next Steps and Recommended Resources

Next Steps · Recommended Resources

Pillar 1 · Cross-Platform & Native

Mobile App Development Services

Production iOS and Android apps built with Flutter, React Native, Swift, and Kotlin alongside scalable Laravel/Node backends.

Interactive Tool · Estimate Scope

Mobile App Cost Estimator

Calculate week-by-week scope for customer apps, offline sync, push notifications, and App Store / Google Play launches.

01 — Frequently asked questions

mobile apps

Should an on-demand app have two separate apps or one app with role switching?

If customers book occasionally while providers use the app all day for dispatch, navigation, and payouts, ship two lightweight apps sharing a monorepo or shared UI/API packages. A single app with role switching bloats permissions and confuses store review unless users regularly act as both buyer and seller.

How do you prevent two users from booking the same service provider at once?

Never rely on a simple SELECT check before INSERT. Use PostgreSQL range exclusion constraints (`EXCLUDE USING gist`) on provider ID and time window, or transactional row locks (`SELECT ... FOR UPDATE`), so the database rejects overlapping bookings atomically.

How should an on-demand marketplace handle payments and provider payouts?

Authorize or capture funds into platform escrow using Stripe Connect (or local regional gateways) at booking time, hold funds until job completion or dispute window expiry, and then release automated split transfers minus platform commission.

How much does it cost to build an on-demand MVP with SmitDev?

Entrepreneurs can hire dedicated senior full-stack engineering at $55/day for 8–9 hours of daily work or $1,999/month for continuous delivery—covering customer mobile app, provider app, dispatch backend, and web admin dashboard.

03 — Have an engineering need?

hire the right expertise

Let's talk tech.

Deciding between an embedded forward deployed engineer or a senior full stack developer? Share your technical context and timeline.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.