Engineering SpecificationsSyed-exe/shiddat-releasesAuto-Sync

Engineering Decisions & Reliability Matrix

Architectural rationale, verified test suites, jitter benchmarks, and production technology matrix powering Shiddat.

Tag: v1.10.0Branch: mainGo 1.22 + WebSocketsC++17 NDK 27CC0-1.0
Architectural Rationale

Decisions behind the experience.

Every layer in Shiddat was deliberately chosen to solve a concrete engineering problem — prioritizing deterministic playback, cellular efficiency, and real-world audio fidelity.

DECISION 01

Why server-time anchors?

Broadcasting 'play now' creates audible drift across heterogeneous mobile networks.

If a server commands five phones to 'play now', a packet arriving 40ms late on Wi-Fi and 300ms late on mobile data causes them to start a quarter-second apart. Re-sending packets only compounds drift. By transmitting a fixed position anchored to an authoritative server timestamp, every device calculates playhead = positionMs + (serverNow - anchorMs) locally and converges autonomously.

Verified in active production repository
DECISION 02

Why separate queue state?

Queue mutations are low-frequency events that must not bloat recurring heartbeats.

Playback position and active playback state must be refreshed frequently (every 5 seconds) to heal packet drops and clock drift. However, playlist queues can contain hundreds of tracks. Sending the entire track array with every heartbeat would consume substantial cellular data. Decoupling queue state into delta mutations (Append, Remove, Move) preserves network bandwidth.

Verified in active production repository
DECISION 03

Why WebSockets over HTTP polling?

Real-time party sessions require continuous sub-50ms bidirectional interactivity.

HTTP polling introduces connection handshake overheads, HTTP header tax, and unpredictable polling latency. A single persistent WebSocket connection per device enables instantaneous host command dispatch (seek, pause, skip) and deterministic NTP-style ping/pong round-trip time sampling.

Verified in active production repository
DECISION 04

Why Android Media3 / ExoPlayer?

First-class integration with Android OS media sessions and hardware audio sinks.

Media3 provides seamless background audio execution within a proper foreground service, lockscreen transport controls, Android Auto compatibility, and hardware volume key interception. Its customizable AudioSink architecture enables zero-gap crossfades and 32-bit floating-point DSP chaining directly before DAC output.

Verified in active production repository
DECISION 05

Why native C++ for audio analysis?

Intensive Fourier transforms require deterministic memory and SIMD vectorization.

Computing Short-Time Fourier Transforms (STFT), 128-band Mel spectrograms, and autocorrelation tempo detection across thousands of PCM audio frames generates intense heap allocation pressure in the JVM. Compiling optimized C++ algorithms via CMake and NDK executes within pre-allocated scratch buffers with ARM NEON SIMD vectorization without triggering garbage collection pauses.

Verified in active production repository
Automated Test Suite & Verification

Built to survive real playback.

Music playback apps fail under real conditions: phones enter battery doze mode, Bluetooth headphones disconnect, and cell towers drop WebSocket frames. Shiddat is backed by 84+ verified test suites and 30 formal cross-device acceptance specifications.

PASSAudio Pipeline

PrecisionAudioSinkTest.kt

Media3 DirectTrack audio sink zero-underrun verification

PASSAudio DSP

FloatDspChainTest.kt

32-bit float equalizer bands, pre-amp clamping, and dynamic leveling

PASSGo Backend Hub

party_test.go

Time-anchor drift calculations, monotonic clock assertions, and member token auth

PASSListen Together

LocalJamHostServerTest.kt

Local room creation, client join handshake, and heartbeat state reassertion

PASSQueue Sync

PartyQueueMoveTest.kt

Deterministic resolution of concurrent queue delta operations across devices

PASSDeterministic Queue

QueueShuffleTierTest.kt

Pseudo-random seed preservation across session restarts and handoffs

PASSOffline Engine

OfflineDashTest.kt

Segmented media caching, atomic file writes, and corrupted stream recovery

PASSDownload Store

DownloadSessionTest.kt

Network state transitions (cellular vs Wi-Fi) and automatic download throttling

PASSCross-Device Spec

CD-001 Zero Autoplay

Opening second device displays remote status without triggering audio playback

PASSCross-Device Spec

CD-002 Play Here Handoff

Atomic lease transfer preserves playhead within 150ms drift tolerance

PASSCross-Device Spec

CD-008 Buffering Rollback

8-second target buffer failure coordinator rolls back lease to source device

PASSLyrics Engine

WordSyncTest.kt

Sub-millisecond syllable interpolation and LRC time offset bounds checking

Representative Production Stress Scenarios

Zero Inverted State Guarantees
1. Remote Pause

Renderer receives and acknowledges pause state without rewinding playback buffer.

2. Concurrent Queue Move

Multiple users reordering songs concurrently resolve deterministically against central epoch.

3. Network Handover

Wi-Fi to LTE drop recovers via 45-second socket grace period without kicking user from party.

4. Monotonic Clock Leap

Host OS NTP clock stepping does not perturb playback anchor or cause audio stutter.

Production Technology Matrix

An engineered stack from metal to UI.

Every technology in Shiddat was picked for reliability, determinism, and performance. No superficial wrapper frameworks — true native code at every tier.

GROUP 01 — ANDROID
Kotlin 2.0+Coroutines, StateFlow, Serialization
Jetpack ComposeDeclarative UI with Compose BOM 2024
Material 3Dynamic color & expressive components
Android SDK (API 26–36)Backwards-compatible modern runtime
GROUP 02 — PLAYBACK
Android Media3Modern unified media architecture
ExoPlayer 1.4+DASH/HLS/Progressive stream engine
MediaSessionForeground service & system controls
Custom Float DSPGapless crossfade & 10-band EQ
GROUP 03 — BACKEND
Go (Golang) 1.22Low-overhead concurrency runtime
WebSocket HubSub-50ms full-duplex client streams
In-Memory StoreZero-latency party rooms & tokens
REST EndpointsHealthz & monotonic time bootstrapping
GROUP 04 — DATA
Room SQLiteEncrypted offline tracks & playlists
OkHttp 4 & RetrofitHTTP/2 connection pooling & cache
Supabase CloudUser sync & remote metadata backup
Coil3Hardware-accelerated bitmap caching
GROUP 05 — NATIVE
Modern C++ (C++17)STFT, Mel spectrograms, tempo lag
CMake 3.22.1Native build orchestration
Android NDK 27Direct ARM NEON SIMD acceleration
JNI Zero-CopyDirect byte buffer bridging
GROUP 06 — BUILD
Gradle 8.7+Incremental modularized build daemon
Kotlin DSLType-safe build scripts (build.gradle.kts)
R8 ProguardAggressive dead-code elimination & minification
GitHub Actions CIAutomated test suites & APK release tagging