Case Study
Social Mate App Icon

SocialMate

Production-grade, AI-powered social platform built with Flutter & Supabase

Demo idle
Social Mate Core Social Features & Real-Time Experience Demo
Watch demo0:00 / 3:00
01 — OVERVIEW

Project Overview & Scope

Social Mate is a production-grade cross-platform social networking application engineered to deliver the breadth and depth of tier-1 consumer platforms. It brings together 24 self-contained feature modules spanning real-time messaging, multi-party audio/video conferencing, ephemeral stories, short-form video reels, creator sticker packs, and on-device generative AI assistance.

Architected around a Feature-First Clean Architecture paradigm with BLoC/Cubit state management, the application guarantees strict unidirectional data flow and modular boundary isolation. The persistent data layer is backed by Supabase PostgreSQL, leveraging real-time Change Data Capture (CDC) and row-level security (RLS) to synchronize complex social graphs, message streams, and threaded discussions.

Real-time audio and video communications are powered by LiveKit's open WebRTC Selective Forwarding Unit (SFU) architecture, replacing proprietary SDKs with high-efficiency media routing. Complementing this is a pluggable multi-provider AI gateway hot-swapping between Google Gemini, Groq, and OpenRouter, paired with Hive binary offline caching and biometric security.

RoleLead Developer
PlatformiOS & Android
Tech Stack
FlutterDartSupabase (PostgreSQL & Realtime)LiveKit (WebRTC SFU)Firebase (FCM)BLoC / CubitHiveMulti-Provider AI (Gemini · Groq · OpenRouter)Cloudinary CDN
02 — SHOWCASE

Social Mate

Production-grade, AI-powered social platform built with Flutter & Supabase

Feature 1 of 8: Real-time Messaging & Unified Media Engine
1-on-1 Chat Interface with Read Receipts & Voice Note
01 / 08

Real-time Messaging & Unified Media Engine

Instant 1-on-1 and group chats with Supabase Realtime, typing indicators, read receipts, professional voice messaging with live waveforms, rich link previews, @mentions, and multi-target message forwarding.

03 — ARCHITECTURE

Technical Architecture

A high-level overview of how the system is structured to ensure scalability, fault tolerance, and low-latency throughput.

Step 01 of 04

Presentation & Reactive State Management

Feature-First Clean Architecture isolating 24 modules with unidirectional BLoC/Cubit state flow and 12-theme dynamic color adaptation.

Flutter 3.xBLoC / Cubit PatternCustom AppRouter & Active-Screen Tracker12 Dynamic Themes
Step 02 of 04

Realtime Communications & Signaling Layer

Scalable PostgreSQL database utilizing Supabase Realtime Change Data Capture (CDC) over WebSockets with optimistic client reconciliation.

Supabase PostgreSQLPostgreSQL CDC SubscriptionsRow Level Security (RLS)Cloudinary CDN
Step 03 of 04

LiveKit WebRTC SFU Audio/Video Engine

Carrier-grade 1-on-1 and group calling utilizing LiveKit SFU, FCM full-screen incoming call intents, flutter_foreground_task, and Picture-in-Picture.

LiveKit SDK (WebRTC SFU)FCM Full-Screen Intentsflutter_foreground_taskIn-App PiP Overlay
Step 04 of 04

Pluggable Multi-Provider AI Gateway & Hive Offline Tier

Multi-provider AI inference layer with automatic vision detection, accompanied by Hive-backed offline caching with LRU storage eviction.

Gemini · Groq · OpenRouter GatewayHive Binary PersistenceLRU Cache EvictionBiometric local_auth
04 — ENGINEERING

Engineering Insights

Key architectural tradeoffs, state management paradigms, and hard technical challenges encountered during production development.

Key Decisions

Tradeoff 01

LiveKit WebRTC SFU vs P2P Mesh or Proprietary SDKs

Context

Peer-to-peer WebRTC mesh architectures degrade rapidly in mobile group calling due to N*(N-1) uplink bandwidth saturation, while proprietary SDKs like ZEGOCLOUD introduce vendor lock-in and opaque pricing.

Approach & Outcome

Standardized on LiveKit's open WebRTC Selective Forwarding Unit (SFU) architecture. Clients publish a single upstream track while the SFU intelligently distributes downlinks based on active speaker detection and network conditions. This reduced mobile bandwidth by over 65% in group calls and enabled seamless Picture-in-Picture (PiP) background multitasking.

Tradeoff 02

Pluggable Multi-Provider AI Gateway with Runtime Vision Detection

Context

Relying on a single AI vendor introduces rate limit vulnerabilities, regional latency spikes, and feature constraints when bridging text assistance and multimodal image analysis.

Approach & Outcome

Built an abstraction layer over Gemini, Groq, and OpenRouter. The gateway dynamically inspects the request context: when an image attachment is detected, it automatically routes the payload to Gemini or OpenRouter's vision endpoints; for rapid conversational replies and comment suggestions, it prioritizes Groq for sub-second token delivery.

Tradeoff 03

Supabase Realtime CDC with Optimistic Client-Side Reconciliation

Context

Maintaining instantaneous chat delivery, typing indicators, and deeply nested comment threads across hundreds of concurrent users without excessive polling or race conditions.

Approach & Outcome

Employed Supabase Realtime Change Data Capture (CDC) directly hooked to PostgreSQL table events. The presentation layer applies immediate optimistic UI updates upon user action, then seamlessly reconciles with the authoritative WebSocket broadcast payload, ensuring zero perceivable UI lag.

Tradeoff 04

Feature-First Domain Isolation with Unified Shared Primitives

Context

Organizing a 24-feature social app by technical layers (all models in one folder, all views in another) creates high coupling and makes parallel feature evolution error-prone.

Approach & Outcome

Structured the codebase into self-contained feature slices (`single_chats`, `reels`, `stories`, `stickers`, etc.), each encapsulating its own Cubits, Models, Services, and Views. Reusable infrastructure — such as MediaCacheRepository, AttachmentPicker, and ChatPresenceService — is centralized in `core/` as shared primitives.

Technical Challenges

Challenge 01

Reliable Lock-Screen Incoming Call Delivery via FCM Full-Screen Intents

The Challenge

Android's battery-saving Doze modes and background execution limits frequently delay standard notifications and terminate background sockets when an incoming audio/video call arrives.

The Engineering Solution

Configured high-priority FCM data messages coupled with Android Full-Screen Intents and custom notification channels. When an incoming call payload is received, the app immediately raises a full-screen calling activity over the lock screen and initializes `flutter_foreground_task` to prevent the OS from killing the LiveKit signaling socket before the user answers.

Challenge 02

Video Controller Lifecycle & Memory Pooling in Reels Feed

The Challenge

Continuous vertical swiping through short-form video reels causes rapid memory accumulation and eventual Out-Of-Memory (OOM) crashes if VideoPlayerControllers are not aggressively managed.

The Engineering Solution

Engineered a pooled video controller manager that maintains active controllers only for the current video and the immediate adjacent videos (index - 1, index + 1) for seamless pre-buffering. Out-of-viewport controllers are aggressively paused and disposed, keeping native video memory within a predictable, bounded ceiling.

Challenge 03

Multi-Surface Cache Eviction & Offline Storage Synchronization

The Challenge

Caching rich media (voice notes, thumbnails, high-res photos, sticker packs) for offline browsing quickly exhausts device storage if unbounded.

The Engineering Solution

Implemented an indexed Hive cache with an intelligent Least-Recently-Used (LRU) eviction pipeline. The MediaCacheRepository tracks access frequencies and timestamps, automatically purging non-essential cached media when local storage approaches a configurable limit while keeping textual chat history and user profile metadata intact.

06 — DOWNLOADS

Download Social Mate

Install the latest Android build directly to your device. All builds are optimized for high-performance native execution and security.

Recommended BuildTarget Architecture: arm64-v8a

Social Mate — ARM64-v8a

Recommended for 95% of modern 64-bit Android devices (Snapdragon, MediaTek, Exynos, Tensor).

Versionv1.0.0
Build1.0.0+6
Size62.1 MB
Commit5f0bee9

minSdk 24 (Android 7.0+) — targetSdk 36. Unknown sources must be enabled.

Other Architectures

Social Mate — ARMv7

60.3 MB armeabi-v7a 1.0.0+5

For older 32-bit Android devices.

Social Mate — x86_64

63.3 MB x86_64 1.0.0+7

For Android Studio emulators, PCs, and x86_64 devices.

Ready to dive deeper?

Explore the open-source architecture or see how these performance principles translate across other production case studies.