Skip to main content

Overview

A job in MechZie follows a strict state machine from creation to payment. Understanding these states is critical for building the correct UI flows.

State Machine

Status Reference

Creating a Job

Required fields: service_category_id, pickup_address, pickup_lat, pickup_lng Optional fields: vehicle_id, description, photo_urls
If the customer has unpaid cancellation fees, job creation returns 402 PAYMENT_REQUIRED. The customer must pay the fee first via POST /payments/create-order.

Dispatch System

After job creation, the system automatically dispatches to nearby mechanics in expanding tiers: How it works:
  1. System finds available, verified mechanics within Tier 1 radius
  2. Filters by vehicle type (matches job’s vehicle type) and service category (double gate)
  3. Sends job:offer Socket.io event to each matching mechanic
  4. First mechanic to call POST /jobs/{id}/accept wins. Their availability flips to false. The winning mechanic’s other pending offers for different jobs are superseded. Other mechanics contacted for the same job get a job:taken Socket.io event.
  5. If the mechanic accepts another job, their pending offers for other jobs are superseded (revoked) and the mechanic receives a job:offer-revoked Socket.io event.
  6. If no one accepts within the timeout, expands to Tier 2, then Tier 3
  7. If all tiers exhaust → status becomes no_mechanic_found
Mechanics only receive job offers for vehicle types they registered for. A mechanic who only services two_wheeler will never receive offers for four_wheeler jobs.
The customer sees the job status change from pendingdispatching almost immediately. They receive job:status events via Socket.io as the state changes. Show a loading/searching animation during dispatching.

Mechanic Registration

Before receiving job offers, a mechanic must register with their vehicle types and service categories:

Updating Vehicle Types

Mechanics can update their vehicle type preferences after registration:
Both vehicle_types and service_category_ids are required at registration. The mechanic must select at least one of each.

Mechanic Actions (State Transitions)

Each transition is a simple POST:
All require Authorization: Bearer ACCESS_TOKEN. Invalid transitions return 409 INVALID_TRANSITION.

Line Items (Parts & Labor)

Mechanics can add charges during arrived or in_progress status:
When completed, final_price = base_price + SUM(quantity × unit_price for all line items). The customer receives a job:line-item-added Socket.io event in real-time.

Cancellation Rules

Fee Schedule

When a cancellation fee is charged, the customer cannot create new jobs until they pay it. Check for outstanding fees: GET /api/v1/payments/unpaid-fees.

Checking Unpaid Fees

Response:

Listing Jobs

Response:
Filter by status: pending, dispatching, accepted, en_route, arrived, in_progress, completed, paid, cancelled, no_mechanic_found.

Job Detail

GET /api/v1/jobs/{id} returns an enriched response with nested related entities:
estimated_price is computed as base_price + sum(line_items quantity × unit_price). All prices are in paisa.

Mechanic Public Profile

For a dedicated mechanic profile screen, use GET /api/v1/mechanics/{mechanicProfileId}. This endpoint exposes only customer-safe fields:
Any authenticated user can access this endpoint. Response is cached for 5 minutes.

Frontend Integration Summary

Customer App Flow

  1. Create job → Show searching animation
  2. Listen for job:status → Update UI based on status
  3. On accepted → Show mechanic info, start tracking
  4. job:join → Join job room for location updates
  5. Listen for location:updated → Animate map marker + show ETA
  6. Listen for job:line-item-added → Show added parts/labor
  7. On completed → Show final price, open payment flow
  8. On paid → Show receipt, prompt for rating

Mechanic App Flow

  1. Listen for job:offer → Show accept/decline dialog (with timer)
  2. On job:taken or job:offer-revoked → Dismiss dialog if another mechanic accepted or mechanic is no longer available (e.g. accepted another job)
  3. Accept → Navigate to job detail, start sending location:update
  4. Transition through statesen-routearrivestartcomplete
  5. Add line items during arrived/in_progress
  6. On paid → Show completion, prompt for rating