Delivered remotely for a business based in Adelaide, Australia. Names withheld by agreement.
Project Overview
Local resale thrives on proximity—nobody drives forty minutes across town for a second-hand bookshelf or a set of gardening tools—yet most classifieds platforms treat geography as an afterthought and force every transaction into a cash price tag. In Adelaide's neighborhood resale scene, users wanted both straightforward local sales and flexible barter swaps where two neighbors bundle spare items or top up a small cash difference. We built a hyperlocal peer-to-peer marketplace and barter trading platform uniting a PHP and MySQL spatial backend with native Java Android and Swift iOS apps, Google Maps discovery, Firebase live negotiation, and SendGrid transactional notifications.
Business Bottleneck
Supporting peer-to-peer barter fundamentally changes marketplace data modeling. In a cash marketplace, a listing has one owner, one price, and one buyer at checkout. In a barter marketplace, a user can offer one or three items from their own inventory—potentially mixed with cash—against someone else's listing, while simultaneously fielding offers from other neighbors on those exact same inventory items. Without strict transactional state guards, traders routinely accepted overlapping offers by mistake. Meanwhile, neighborhood sellers hesitated to post high-value household goods if public map pins exposed their street address.
Architectural Strategy
We separated authoritative inventory and spatial state from ephemeral negotiation chatter. PHP and MySQL own user identity, spatial listing discovery, and an atomic barter state machine governed by stateless JWT access tokens. Firebase handles real-time offer messaging and instant push alerts across Android and iOS, while Google Maps renders privacy-masked neighborhood discovery circles rather than exact rooftops.
Core Capabilities
- Radius & Map-Clustered Discovery: Buyers browse within tunable kilometer radii using spatial queries and Google Maps clustering that preserves performance in dense suburbs.
- Multi-Item & Cash-Hybrid Barter Builder: Traders assemble counter-offers combining one or more personal listings with optional cash adjustments inside an explicit propose/counter/accept flow.
- Automatic Conflict Resolution: Accepting a trade reserves all involved items atomically and notifies competing offer threads immediately.
- Privacy-Masked Pickup Zones: Public listings display approximate neighborhood rings until both parties confirm a trade and share an agreed meetup pin.
- Offline-Resilient Image Publishing: Native Java and Swift uploaders resize and orient photos client-side before posting, reducing cellular upload drops.
Technical Architecture
Flow: Android (Java) / iOS (Swift) + Google Maps SDK <-> PHP REST API (JWT Auth) -> MySQL Spatial & Trade State + Firebase (Live Chat/FCM) + SendGrid (Digests/Alerts)
Mobile clients authenticate via login or social flows and receive a short-lived JWT access token alongside a rotating refresh token. When a user pans the Google Maps viewport or adjusts a distance slider, the PHP API computes a bounding box and executes a MySQL spatial query ordered by ST_Distance_Sphere, masking returned coordinates to zone centroids.
Barter negotiations open a linked thread in Firebase Realtime Database referencing an immutable offer ID in MySQL. Counter-offers and final acceptances submit back to the PHP API, which locks the participating listing rows with SELECT ... FOR UPDATE, verifies every bundled item remains available, transitions them to reserved, and triggers Firebase Cloud Messaging and SendGrid notifications for offline counterparties.
Technology Stack
| Category | Technology detail |
|---|---|
| Backend API | Modular PHP REST services with strict JSON schema validation |
| Spatial database | MySQL 8 with SRID 4326 POINT columns and R-tree spatial indexes |
| Authentication | Stateless JWT access tokens paired with rotating refresh tokens |
| Android client | Native Java app with image compression and map clustering |
| iOS client | Native Swift app with responsive feed caching and trade builder UI |
| Geolocation & maps | Google Maps SDK for radius pickers, clustered pins, and fuzzy zones |
| Real-time chat & push | Firebase Realtime Database and FCM for live offer negotiation |
| Transactional email | SendGrid templates and webhooks for trade alerts and verification |
| Trust & moderation | Automated listing state guards, report queues, and blocklists |
| Media pipeline | Server-side thumbnail generation and EXIF orientation normalization |
Engineering Trade-offs & Solutions
| Architectural Dilemma | Chosen Solution & Rationale |
|---|---|
| Pure MySQL spatial queries vs. external search index | Syncing barter reservation status to an external search engine introduces stale windows where users tap items already reserved seconds earlier. Keeping spatial queries inside MySQL guarantees strong consistency at offer time. |
| Exact map pins vs. fuzzy neighborhood circles | Pinning exact seller coordinates improves travel estimates but compromises home privacy. Masking coordinates to deterministic neighborhood offsets on public feeds protects sellers while keeping radius filtering accurate. |
| Native Java/Swift clients vs. hybrid web views | Smooth 60 fps Google Maps marker clustering, camera multi-pickers, and fluid drag-and-drop barter tray interactions perform noticeably better in native Swift and Java than inside cross-platform WebViews. |
| Firebase-only trade state vs. PHP transaction authority | Letting clients mutate trade acceptance directly in Firebase risks race conditions and tampered bundles. Keeping Firebase strictly for chat delivery and anchoring state transitions in MySQL transactions closes both gaps. |
Security & Reliability
All API endpoints validate JWT signatures, audience claims, and token expiration before touching user data, while refresh tokens rotate on every use with reuse detection to flag stolen credentials. Input sanitization and strict media MIME inspection block spoofed image uploads, and rate-limiting shields authentication and messaging endpoints against credential stuffing and automated listing spam. SendGrid webhook listeners track bounces and spam reports automatically, suppressing bad addresses to protect sender reputation.
Performance & Scale
Spatial index bounding boxes prevent full-table scans as neighborhood inventory grows across suburbs, keeping feed queries tightly bounded by latitude/longitude envelopes and category predicates. Client-side image downscaling on Android and iOS trims multi-megabyte phone camera captures before upload, cutting PHP memory usage and keeping feed scrolling brisk over mobile connections. Cursor-based pagination avoids offset drift when new neighborhood listings arrive mid-scroll.
Operational Outcomes
Local buyers and sellers gained a trustworthy way to discover nearby goods without exposing home addresses, while barter traders moved from chaotic text negotiations to structured, conflict-free item swaps. Moderation staff gained clean visibility into flagged listings and trade histories, and native Android and iOS clients delivered responsive map exploration suited to everyday neighborhood trading.