惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
S
Securelist
小众软件
小众软件
WordPress大学
WordPress大学
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
博客园 - Franky
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
O
OpenAI News
Cloudbric
Cloudbric
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
V
V2EX
PCI Perspectives
PCI Perspectives
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
P
Palo Alto Networks Blog
M
MIT News - Artificial intelligence
V2EX - 技术
V2EX - 技术
阮一峰的网络日志
阮一峰的网络日志
Hacker News - Newest:
Hacker News - Newest: "LLM"
G
Google Developers Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
The Last Watchdog
The Last Watchdog
The Register - Security
The Register - Security
腾讯CDC
N
News and Events Feed by Topic
C
Check Point Blog
爱范儿
爱范儿
T
Tailwind CSS Blog
Webroot Blog
Webroot Blog
P
Proofpoint News Feed
S
Schneier on Security
MyScale Blog
MyScale Blog
N
News | PayPal Newsroom
Recorded Future
Recorded Future
T
Tenable Blog
I
InfoQ
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Microsoft Security Blog
Microsoft Security Blog
Simon Willison's Weblog
Simon Willison's Weblog
Engineering at Meta
Engineering at Meta

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
How We Built a Sober Driver Booking System in Moldova: Real-time Dispatch with Node.js, Supabase & Vercel
Lilian · 2026-04-26 · via DEV Community

How We Built a Sober Driver Booking System in Moldova: Real-time Dispatch with Node.js, Supabase & Vercel
In September 2024, Moldova reclassified drunk driving from an administrative offense into a criminal offense — with prison sentences up to 4 years and fines reaching 150,000 MDL (~3,000 EUR).
This single legal change transformed the local market for designated driver services overnight. As the team behind PlusRent, a car rental and sober driver platform in Chișinău, we suddenly faced 3-5x more booking requests during peak hours (Friday-Saturday nights, 22:00-04:00).
Our existing manual dispatch system — phone calls, WhatsApp messages, Excel spreadsheets — became a bottleneck within weeks. We had to build something better.
This article documents the technical journey of building a real-time sober driver booking system that handles dispatch, GPS tracking, ETA calculation, and payment integration — using a serverless architecture on a startup budget.

Context: If you're curious about the legal side of why this market exploded, I wrote a separate piece on Moldova's 2026 DUI legislation covering all the legal details. This post focuses on the engineering side.

The Problem We Faced
A "sober driver" service has unique constraints that traditional rideshare apps don't address:

The driver drives the customer's car, not their own
Customer is intoxicated — UX must be foolproof
Peak hours are extreme — 80% of bookings happen in 6-hour windows
Geographic precision matters — restaurants, weddings, private addresses
Trust is critical — driver gets keys to expensive vehicles

Existing solutions like Yandex Go or Uber don't offer this service in Moldova. Local competitors used WhatsApp + manual dispatch — slow, error-prone, and unscalable.
We needed:

Real-time booking with under 30-second confirmation
Live driver GPS tracking
Automatic dispatch to nearest available driver
Customer-facing ETA updates
Multi-language UI (Romanian, Russian, English)
Payment options (cash + card)

All on a budget that wouldn't bankrupt a small startup.

Our Stack
After evaluating options, we chose:
Frontend: Next.js 14 (App Router)
Hosting: Vercel (Edge Functions)
Backend: Node.js + Supabase Edge Functions
Database: Supabase (PostgreSQL + Realtime)
Auth: Supabase Auth
Maps: Google Maps Platform
SMS: Twilio
Payments: Stripe + cash handling
Monitoring: Sentry + Vercel Analytics
Why this stack?

Vercel + Next.js: Zero-config deployment, edge functions for sub-100ms response globally
Supabase: PostgreSQL + Realtime WebSockets in one service. Replaces 3-4 separate services we'd otherwise need
Google Maps: No alternative comes close for Moldova's address coverage
Twilio: Reliable SMS for OTP and dispatch notifications

Total monthly infrastructure cost during MVP phase: ~$40/month. After scaling to current volume: ~$180/month.

Database Schema: The Foundation
The data model needed to handle three primary entities and their relationships:
sql-- Core tables (simplified)

CREATE TABLE drivers (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
phone TEXT UNIQUE NOT NULL,
full_name TEXT NOT NULL,
status TEXT CHECK (status IN ('offline', 'available', 'busy')),
current_location GEOGRAPHY(POINT, 4326),
rating NUMERIC(3,2) DEFAULT 5.00,
total_rides INTEGER DEFAULT 0,
created_at TIMESTAMPTZ DEFAULT now()
);

CREATE TABLE bookings (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
customer_phone TEXT NOT NULL,
pickup_location GEOGRAPHY(POINT, 4326) NOT NULL,
pickup_address TEXT NOT NULL,
destination_location GEOGRAPHY(POINT, 4326),
destination_address TEXT,
status TEXT CHECK (status IN (
'pending', 'assigned', 'en_route',
'arrived', 'in_progress', 'completed', 'cancelled'
)),
driver_id UUID REFERENCES drivers(id),
estimated_price NUMERIC(10,2),
final_price NUMERIC(10,2),
payment_method TEXT,
created_at TIMESTAMPTZ DEFAULT now(),
assigned_at TIMESTAMPTZ,
completed_at TIMESTAMPTZ
);

CREATE TABLE driver_locations (
driver_id UUID REFERENCES drivers(id),
location GEOGRAPHY(POINT, 4326) NOT NULL,
heading NUMERIC(5,2),
speed NUMERIC(5,2),
recorded_at TIMESTAMPTZ DEFAULT now()
);

-- Critical index for nearest-driver lookup
CREATE INDEX idx_drivers_location ON drivers
USING GIST(current_location)
WHERE status = 'available';

CREATE INDEX idx_bookings_status ON bookings(status, created_at);
The PostGIS extension on Supabase made geographic queries trivial. Finding the 5 nearest available drivers to a pickup point became a single query:
sqlSELECT
id,
full_name,
ST_Distance(current_location, $1::geography) AS distance_meters
FROM drivers
WHERE status = 'available'
AND ST_DWithin(current_location, $1::geography, 5000) -- 5km radius
ORDER BY current_location <-> $1::geography
LIMIT 5;
This query runs in ~3-8ms even with thousands of bookings in history.

The Dispatch Algorithm
The hardest engineering problem was the dispatch algorithm. Naive "nearest driver" doesn't work because:

A driver 1km away with rating 4.2 is worse than one 1.5km away with rating 4.9
A driver who just finished a ride 2km away might decline; a driver idle for 20 minutes will accept
Some drivers prefer specific zones; Friday-night dispatching to a known difficult area shouldn't go to a new driver

We ended up with a weighted scoring algorithm:
javascript// Simplified scoring logic
function scoreDriver(driver, booking) {
const distanceKm = haversine(driver.location, booking.pickup);

// Distance: closer is better, but with diminishing returns
const distanceScore = Math.max(0, 100 - (distanceKm * 15));

// Rating: higher is better (4.0 = 60pts, 5.0 = 100pts)
const ratingScore = (driver.rating - 4) * 100;

// Idle time: drivers idle 5-20 min are eager
const idleMinutes = (Date.now() - driver.last_active) / 60000;
const idleScore = idleMinutes > 5 && idleMinutes < 20 ? 20 : 0;

// Zone familiarity: bonus for drivers with rides in this area
const zoneScore = driver.zones.includes(booking.pickup_zone) ? 15 : 0;

// Weights
return (
distanceScore * 0.5 +
ratingScore * 0.25 +
idleScore * 0.15 +
zoneScore * 0.10
);
}

async function dispatchBooking(bookingId) {
const booking = await getBooking(bookingId);
const candidates = await getNearbyAvailableDrivers(booking.pickup, 5000);

if (candidates.length === 0) {
return { error: 'no_drivers_available' };
}

const ranked = candidates
.map(d => ({ driver: d, score: scoreDriver(d, booking) }))
.sort((a, b) => b.score - a.score);

// Try top 3 in parallel with race condition handling
for (const { driver } of ranked.slice(0, 3)) {
const accepted = await offerToDriver(driver.id, bookingId, 30_000);
if (accepted) {
return { driver_id: driver.id };
}
}

return { error: 'all_drivers_declined' };
}
The 30-second offer window with sequential fallback proved critical. Customers wouldn't wait longer than 60 seconds for confirmation.

Real-time Updates with Supabase
The customer experience requires live updates: "Your driver is 3 minutes away" → "Your driver has arrived" → "Trip in progress."
Supabase's realtime PostgreSQL subscriptions made this surprisingly simple:
javascript// Customer's frontend subscribes to their booking
const channel = supabase
.channel(booking_${bookingId})
.on(
'postgres_changes',
{
event: 'UPDATE',
schema: 'public',
table: 'bookings',
filter: id=eq.${bookingId}
},
(payload) => {
updateUI(payload.new);
}
)
.subscribe();
For driver location updates, we initially used PostgreSQL realtime as well — sending location every 5 seconds. This crashed our database connections at scale.
The fix: a separate Supabase Edge Function that wrote driver locations to a Redis-like cache (we used Upstash) and only persisted to PostgreSQL every 30 seconds for analytics. Real-time location was streamed via WebSocket directly:
javascript// Driver app sends location to Edge Function
async function broadcastLocation(driverId, lat, lng) {
await fetch('/api/driver-location', {
method: 'POST',
body: JSON.stringify({ driverId, lat, lng, ts: Date.now() })
});
}

// Edge function broadcasts to customer's WebSocket channel
// (only if customer has active booking with this driver)
This reduced database load by 95% while keeping sub-second update latency.

Multi-language Support: The Hidden Challenge
Moldova has 3 active languages: Romanian (official), Russian (widely spoken), and English (for tourists). The naive approach — t('booking.confirm') — falls apart when:

Drivers receive SMS dispatch in Romanian
The same booking shows in admin dashboard in English
Customer sees confirmation in Russian
Receipt PDF is in Romanian

We built a language matrix at the database level:
sqlCREATE TABLE translations (
key TEXT NOT NULL,
language TEXT NOT NULL,
value TEXT NOT NULL,
context TEXT,
PRIMARY KEY (key, language, context)
);
Each user/driver has a preferred_language field. SMS, push notifications, emails, and PDFs all query this table. The customer-facing UI uses Next.js i18n, but server-generated content (notifications, receipts) goes through the database.
A side benefit: we let customer support staff edit translations in real-time without redeploying.

Payment Integration: Card + Cash Reality
Western tutorials assume Stripe-only. In Moldova, 70% of payments are cash. This required dual-flow support:
javascript// Payment options shown to customer
const PAYMENT_METHODS = {
card: {
flow: 'stripe',
capture: 'immediate',
deposit: true,
},
cash: {
flow: 'manual',
capture: 'on_completion',
deposit: false,
},
};

// On booking completion
async function completeBooking(bookingId, paymentMethod) {
const booking = await getBooking(bookingId);

if (paymentMethod === 'card') {
await stripe.paymentIntents.capture(booking.stripe_intent_id);
} else {
// Cash: driver confirms collection in app
await markBookingCashCollected(bookingId);
await scheduleDriverPayout(booking.driver_id);
}

await sendReceipt(booking);
await updateDriverEarnings(booking.driver_id, booking.final_price);
}
Cash handling required additional complexity: driver shift reconciliation, daily settlement, and a "trust score" system to flag drivers with consistent cash discrepancies.

Deployment & Monitoring
Deploying with Vercel + Supabase was almost too easy:
bash# Push to main branch
git push origin main

Vercel automatically:

1. Builds Next.js app

2. Runs migrations on Supabase

3. Deploys edge functions

4. Updates DNS

The catch: edge functions have a 10-second execution limit. Long-running operations (driver payouts, daily reconciliation) had to move to scheduled Supabase functions or external workers.
Sentry caught most production issues, but the most valuable monitoring was custom: a real-time dashboard showing active bookings, average ETA, driver utilization, and dispatch success rate. When dispatch_success_rate dropped below 85%, alerts fired.

What We'd Do Differently
If starting today, we'd consider:

TanStack Query instead of native React state for booking data — we hit cache invalidation issues with manual implementation
Bun instead of Node.js for backend functions — ~3x faster cold starts
PartyKit or Cloudflare Durable Objects for real-time location instead of Upstash + Edge Functions — simpler architecture
PostHog for product analytics from day one — we added it 6 months in and lost valuable behavior data

We don't regret choosing Supabase. The combination of PostgreSQL + Auth + Realtime + Storage + Edge Functions in one service saved us months of integration work.

Results After 12 Months
The numbers (rounded for simplicity):

Average dispatch time: 22 seconds (down from 8+ minutes manual)
Booking-to-pickup time: 18 minutes average
Customer satisfaction: 4.9/5 across 27+ Google reviews
Driver retention: 85% after 3 months (industry avg is ~50%)
Peak concurrent bookings: 40+ on weekend nights
Infrastructure cost per booking: ~$0.12

The system handles current volume comfortably. The next bottleneck will be human (driver capacity) rather than technical.

Closing Thoughts
Building a sober driver platform in a market of 2.5 million people taught us that "small market" doesn't mean "simple problem." The legal context, language complexity, payment culture, and trust dynamics required engineering solutions that wouldn't appear in a typical SaaS playbook.
For technical founders building local services in non-Western markets: don't over-index on Silicon Valley patterns. Cash payments are real. SMS still beats push notifications for older demographics. Local language nuance matters more than you think.
The full stack — Node.js, Supabase, Vercel, Next.js — proved that small teams can ship serious infrastructure without enterprise budgets.
If you're working on similar problems (dispatch systems, real-time tracking, multi-language services in emerging markets), I'm happy to discuss specifics in the comments.

The legal context for this project is covered in detail in our Moldova DUI legislation guide on Medium.
The platform itself runs at plusrent.md.