How to Find the Nearest Driver in an Uber-Style App [Full Repo]

Behind every ride request is one question: who is closest? Store locations the right way and the database answers it for you, in the right order, without a line of distance maths.

What this guide builds: a database with Driver, Passenger and PointOfInterest tables holding five records each, and a position column storing New York coordinates

Someone opens the app and taps the button. Before a map appears, before a price shows up, the system has to answer one question: of all the drivers out there, which one is closest to this person right now?

You do not have to work that out yourself. Store each location in the right kind of field and the database will sort everyone by distance for you, nearest first. What is new is that you no longer have to set it up by hand either — an AI assistant connected to your account can create the tables, fill them and ask the question.

This guide does exactly that, then does the part most write-ups skip: it checks the answer by working the distances out separately and comparing. Measured on 23 September 2026 — three tables in 516 ms, 15 records in 729 ms.

Watch it instead

The original walkthrough builds the same three classes and asks the same nearest-driver question, entirely in conversation.

Video: No Code Uber App
Watch it instead No Code Uber App
From the Back4app channel. The data model and the questions are unchanged; the tool it uses to reach the backend no longer exists, and this guide uses what replaced it. Open on YouTube →

What does the model need to look like?

Three classes and one field type. Drivers, passengers and points of interest each need a name and a position, and the position has to be a GeoPoint rather than a pair of numbers.

That choice is the whole guide in one decision. A GeoPoint stores latitude and longitude as a single value, and it is the only thing Parse’s geospatial operators will read. Store the two numbers separately and the data is still there, but $nearSphere and its relatives stop being available to you.

ClassFields
Drivername (String), position (GeoPoint)
Passengername (String), position (GeoPoint)
PointOfInterestname (String), position (GeoPoint)

How do you connect the AI client?

Through an MCP server, which exposes your Back4app account to the assistant as a set of tools. Create an account key under Account Settings → Account Keys, then point your editor at the server — the package is fetched on demand.

{
  "mcpServers": {
    "back4app": {
      "command": "npx",
      "args": ["-y", "@back4app/mcp-server-back4app@latest",
               "--account-key", "YOUR_ACCOUNT_KEY"]
    }
  }
}

Two of its tools carry this guide: create_parse_app makes the app, and call_parse_server_rest_api does everything else — defining schemas, inserting records and running queries, in batches.

How do you build the classes and the data?

Describe them. The app was created first, then the three schemas, then the records — each step an instruction rather than a file.

Create an app called uber-clone-demo. In it, create Driver, Passenger and PointOfInterest classes, each with a name string and a position GeoPoint. Then add five of each, using real New York coordinates for the points of interest.

Creating the app took 3.4 seconds. The three schemas came back together in 516 ms, each reporting the fields it had defined. The 15 records went in as one batch in 729 ms, all fifteen returning HTTP 201.

The Database browser showing the Driver class with five records: object ids, ACLs, names and a position column

For the landmarks, real coordinates matter — the distances later are only meaningful if the Statue of Liberty is where the Statue of Liberty is.

The PointOfInterest class holding Empire State Building, Central Park, Statue of Liberty, Times Square and Brooklyn Bridge, each with its GeoPoint coordinates

How do you find the nearest driver?

With $nearSphere, which sorts by distance for you. Read the passenger’s position, then query Driver with that point — Parse returns the rows already ordered nearest-first, so there is no sorting step and no distance maths in your code.

{
  "position": {
    "$nearSphere": {
      "__type": "GeoPoint",
      "latitude": 40.7291,
      "longitude": -73.9965
    }
  }
}

For the passenger standing at 40.7291, −73.9965, that returned Nadia Okonkwo, then Priya Raman, then Ana Ferreira. The ordering is not obvious by eye: Ana Ferreira is almost identical in longitude to the passenger, which makes her look like the closest until you account for latitude.

Is the database’s answer actually right?

Do not take its word for it. The ordering was recomputed from the same coordinates with a plain haversine formula, outside the database, and compared.

1. Nadia Okonkwo    1.231 mi   (1.981 km)
2. Priya Raman      1.448 mi   (2.331 km)
3. Ana Ferreira     1.589 mi   (2.558 km)
4. Marcus Hale      2.078 mi   (3.344 km)
5. Tomas Vidal      4.058 mi   (6.531 km)

Same order, including the non-obvious swap. But matching the order is a weak test — a sort can be right while the distances are wrong. So the magnitudes were tested too, by adding $maxDistanceInMiles and walking the radius across the computed gaps.

Radius asked forDrivers returnedExpected from the table
1.2 mi0nearest is 1.231 — none should qualify
1.3 mi1Nadia only
1.5 mi2Nadia, Priya
1.6 mi3+ Ana
2.1 mi4+ Marcus

Every boundary fell exactly where the independent calculation said it would. Parse is not approximating here, and the numbers are safe to price a trip with.

How do you price the ride?

Ask for the distance between two stored points and multiply. With the positions already in the database, the fare is one query and one multiplication.

The trip from that passenger to the Statue of Liberty measures 3.731 miles, so at a dollar a mile it prices at $3.73. That is straight-line distance, which is the right number for a demo and the wrong number for a real fare — road distance is longer, and any production pricing needs a routing service rather than a great-circle formula.

The database will happily tell you how far apart two points are. It will not tell you that nobody can drive across the Hudson in a straight line.

What has to change before this is real?

The permissions, first. Open the Database browser and every record created in this run shows an ACL of Public Read + Write — anyone with the client key can read or overwrite any of it. That is the Parse default rather than anything the AI client decided, and on a class holding people’s live positions it is exactly the wrong default.

Driver positions also need to move. Everything here is a static snapshot; a working system updates a driver’s GeoPoint continuously and queries against the current value, which changes the write volume by orders of magnitude and makes an index on the position field non-optional.

None of that changes the model, which is the point worth taking away. Three classes, one GeoPoint field each, and a query operator that does the geometry — the shape is right from the first prompt, and what remains is the work of making it safe and keeping it current.

Tagsmcpgeopointgeo-queriesparse-serverdata-modelingai-agentsrest-api

Frequently asked questions

How do you find the nearest record to a location in Parse Server?

Store the coordinates in a GeoPoint field and query it with $nearSphere. Parse returns matching records already sorted nearest-first, so no distance calculation or sorting is needed on your side. Add $maxDistanceInMiles to cut the query off at a radius — on September 23, 2026 a $nearSphere query with a 1.3 mile limit returned exactly one driver out of five, and the boundary matched a haversine calculation to three decimal places.

Can an AI assistant create classes and records in my backend?

Yes, through an MCP server that exposes your account to the assistant as tools. The Back4app MCP server can create a Parse app, define class schemas, insert records and run REST queries against them. In this run it created three classes in 516 ms and inserted 15 records in 729 ms, all from plain instructions rather than hand-written API calls.

What happened to the Back4app ChatGPT plugin?

The category it belonged to no longer exists. OpenAI closed the ChatGPT plugin store on March 19, 2024 and ended plugin conversations on April 9, 2024, replacing plugins with GPTs. Guides that tell you to enable a Back4app plugin inside ChatGPT cannot be followed today. The equivalent path now is the Model Context Protocol, which any MCP-capable AI client can use.

What data type should you use for coordinates in Parse Server?

GeoPoint, not two number fields. A GeoPoint stores latitude and longitude as one value and is what the geospatial query operators read — $nearSphere, $maxDistanceInMiles, $within. Store latitude and longitude separately and you keep the data but lose every one of those operators, leaving you to compute distances in application code.

Are records created this way secure by default?

No, and this is worth checking before you build on top of them. Every record created through the REST API in this run landed with an ACL of Public Read + Write, visible in the Database browser — meaning anyone holding the client key can read or overwrite them. That is the Parse default, not something the AI client chose, and it has to be tightened deliberately before any of this faces real users.

Further reading

Reviewed & verified by Back4app Engineering, Editorial review at Back4app

Tested Sep 23, 2026 — Backend: Parse Server 7.5.2, Back4app free plan, USA East · Client: MCP server 0.1.9 over stdio, Node 22.

More from Back4app Engineering

Web Deployment · tutorial

How to Deploy a Figma Make Site With an MCP Server [Full Repo]

Backend · tutorial

Your Frontend Talks Straight to the Database. Here Is How to Lock It Down [Full Repo]

Backend · tutorial

Build and Deploy a Node.js REST API in 15 Minutes — Without Owning a Server [Full Code Inside]