HomeCase studiesReal-Time Short-Form Polling Social Platform on iOS...

Case study · Warsaw, Poland

Real-Time Short-Form Polling Social Platform on iOS and PHP

Consumer social media and user-generated content

We architected and shipped a native iOS social polling application paired with a PHP REST API and MySQL data layer deployed on Google Cloud. The platform enables users to publish structured binary and multi-choice opinion cards, cast verified votes in real time, and follow live consensus shifts without feed lag. To keep vote tallies accurate under bursty traffic while blocking automated ballot stuffing, we combined Twilio SMS identity verification, stateless JWT session rotation, and write-optimized MySQL tally tables.

Industry
Consumer social media and user-generated content
Solution
Native Swift iOS client backed by a custom PHP/MySQL REST API on Google Cloud with Twilio, Firebase, and SendGrid integrations.
Platforms
iOS · Web & API
Stack
PHP · MySQL · Swift · Firebase · Google Cloud · Twilio
Location
Warsaw, Poland · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Warsaw, Poland. Names withheld by agreement.

Project Overview

Short-form opinion networks live or die by how fast a user can read a prompt, register a stance, and see where the crowd stands. For a consumer social product launched out of Warsaw, we built the complete native iOS experience in Swift alongside a custom PHP and MySQL API hosted on Google Cloud. Rather than mimicking long-form comment threads, every post centers on a structured binary or multi-option poll enhanced with optional photography, expiration timers, and topic tags. The engineering mandate was straightforward: keep scrolling and voting instantaneous on mobile networks while protecting poll integrity against coordinated spam and duplicate ballots.

Business Bottleneck

Earlier prototypes suffered from three compounding issues that stalled user retention. First, polling endpoints coupled image uploads, vote tally recalculation, and push notification dispatch inside synchronous HTTP request cycles, causing mobile UI freezes whenever a poll gained traction. Second, unverified email-only signups invited automated scripts that skewed public polls within minutes of publication. Third, naively incrementing a single counter column on the central polls table created InnoDB row-lock queues during peak evening traffic, turning a smooth swipe gesture into multi-second spinner delays.

Architectural Strategy

We decoupled interactive voting from heavy side effects and media movement. The Swift client talks directly to Google Cloud Storage via short-lived signed URLs for poll attachments, keeping binary payloads off the PHP application tier. Authentication pairs Twilio phone verification at onboarding with short-lived JWT access tokens so stateless API workers authenticate requests without central session-store round-trips. On the write path, ballots append cleanly and asynchronously trigger Firebase Cloud Messaging alerts and SendGrid digests only after the core vote transaction commits.

Core Capabilities

  • Structured Opinion Composer: Users author timed or open-ended polls with two to four choices, topic categorization, and cropped imagery uploaded directly to cloud object storage.
  • Instant Consensus Reveal: Casting a vote transitions the Swift card smoothly into live percentage bars while prefetching the next batch of topic-matched cards.
  • Verified Identity Onboarding: New accounts pass Twilio SMS one-time passcode checks before publishing or voting, raising the cost of automated account farming.
  • Targeted Event Notifications: Firebase Cloud Messaging alerts creators when polls cross participation thresholds, receive replies, or reach their closing timestamp.
  • Moderation and Abuse Controls: Staff review flagged prompts, mute repeat offenders, and invalidate compromised refresh token families from an internal operations console.
  • Lifecycle Email Workflows: SendGrid handles account verification backups, security alerts, and curated weekly recap emails with bounce and complaint webhook tracking.

Technical Architecture

Flow: Swift iOS Client -> JWT-Authenticated PHP API (Google Cloud) -> MySQL Vote Ledger & Feed Index -> Async Workers -> Firebase FCM / SendGrid / Twilio

The Swift application uses a unidirectional state store backed by URLSession and a lightweight local cache so previously viewed polls remain readable offline. API endpoints accept and emit compact JSON payloads protected by Bearer JWT headers signed with asymmetric keys. Behind the Google Cloud load balancer, stateless PHP workers validate token claims locally before querying Cloud SQL (MySQL).

To eliminate hot-row lock contention on trending polls, vote submissions insert into a poll_votes table governed by a composite unique index on (poll_id, user_id) and an idempotency token column. Read endpoints consult precomputed option tallies refreshed on a sub-second debounce window, ensuring voters immediately see their own ballot reflected client-side while global percentages converge cleanly without locking concurrent writers. Media uploads bypass PHP entirely: the API issues a scoped Google Cloud Storage upload policy, Swift uploads the compressed JPEG directly, and the final poll creation call references only the verified object key.

Technology Stack

Category Technology detail
Mobile Client Native Swift (UIKit, URLSession, local CoreData feed cache)
Backend Runtime PHP 8 REST API with strict JSON schema validation
Primary Database MySQL with composite feed indexes and unique vote constraints
Authentication Stateless JWT access tokens with rotating refresh records
Phone Verification Twilio Programmable SMS OTP for Sybil and bot resistance
Push Notifications Firebase Cloud Messaging (FCM) for vote milestones and replies
Transactional Email SendGrid API for account recovery and weekly digest delivery
Cloud Infrastructure Google Cloud Compute Engine, Cloud SQL, and Cloud Storage
Media Delivery Google Cloud Storage signed upload URLs for poll card imagery

Engineering Trade-offs & Solutions

Challenge Architectural Solution
Hot-row locking on viral polls Append-only poll_votes ledger paired with debounced tally aggregation instead of synchronous UPDATE polls SET count = count + 1 per request
Duplicate votes on flaky mobile networks Client-generated idempotency keys plus MySQL composite unique index on (poll_id, user_id) to turn retries into safe no-ops
Session revocation with stateless JWT Short-TTL access tokens combined with revocable MySQL refresh token families so banned devices lose access promptly
API bandwidth saturation from photos Direct-to-Google Cloud Storage signed upload URLs from Swift so PHP workers never buffer raw image streams
Automated bot ballot stuffing Mandatory Twilio SMS OTP verification gated prior to first vote, backed by per-IP and per-prefix rate limiting

Security & Reliability

All client-to-API traffic enforces TLS with strict payload size limits and schema validation at the PHP boundary. JWT signing keys support rotation via key identifiers (kid) in the token header, preventing forced logouts during routine key rollover. Twilio verification codes expire rapidly, enforce exponential backoff after failed attempts, and store only salted hashes of phone numbers for duplicate-account detection rather than exposing raw numbers across feed endpoints. SendGrid event webhooks run through signature verification so bounced addresses automatically suppress future digest sends, preserving sender reputation. Automated Cloud SQL snapshots and point-in-time recovery logs protect user timelines and vote histories against accidental deletion.

Performance & Scale

Pagination uses cursor-based keyset queries over indexed (created_at, id) tuples rather than OFFSET scans, keeping deep scroll performance flat as poll archives grow. In Swift, feed cells reuse pre-measured layout attributes and downsample images to exact display dimensions before caching, preventing memory spikes during rapid scrolling on older iPhones. Background worker pools absorb notification fan-out to Firebase Cloud Messaging in batched multicast calls, isolating API response times from external push gateway latency. Google Cloud autoscaling rules add PHP API instances horizontally on CPU and request-queue thresholds without requiring sticky sessions.

Operational Outcomes

Moving media transfers to signed cloud storage and decoupling vote aggregation removed the request-queue bottlenecks that previously degraded peak evening browsing. Trust and safety teams gained deterministic enforcement controls capable of halting coordinated spam campaigns through phone-verified onboarding and immediate refresh-token revocation. For end users, the Swift feed delivers responsive, jitter-free card transitions and dependable real-time poll results whether browsing on home broadband or commuting across mobile cells.

01 — Questions

asked about this kind of project

How did you prevent duplicate voting and bot manipulation during viral polls?

Every participating account requires a Twilio-verified mobile number before voting privileges unlock. At the persistence layer, MySQL enforces a composite unique key on (poll_id, user_id), guaranteeing at-most-once vote insertion even under concurrent mobile retries.

Why choose a custom lightweight PHP API instead of a monolithic framework for this workload?

Short-form poll feeds and vote endpoints exhibit asymmetric read-to-write spikes where sub-50ms serialization overhead matters. A lean PHP service layer with minimal bootstrap cost kept memory per worker predictable and reduced tail latency during viral bursts.

How does the backend avoid MySQL lock contention when thousands of users vote on one trending poll simultaneously?

Rather than executing immediate row-level increments on the hot polls table for every ballot, vote records append to an indexed ledger table while summary counters refresh via short-interval batch aggregation and short-TTL read caching.

How are JWT sessions revoked if a user loses a device or violates community guidelines?

Access tokens remain short-lived and stateless for fast API verification, while refresh tokens map to hashed records in MySQL. Revoking a user or device invalidates the refresh family immediately, terminating session renewal within minutes.

What happens when a user taps a poll on an unstable cellular connection in Warsaw?

The Swift client generates a deterministic client-side idempotency key per vote gesture and queues the mutation locally if offline. Once connectivity returns, the API deduplicates repeated submissions safely without returning false errors.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

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.