Hi, I'm Jiayuan
Flutter Developer
Building high-performance cross-platform apps with Flutter & Rust FFI. 2.5+ years shipping production apps across 5 platforms.
About Me
Flutter developer focused on performance & cross-platform excellence
I'm a Flutter developer with 2.5+ years of experience building production-grade cross-platform applications. I specialize in Flutter + Rust FFI development, having designed and shipped 11 FFI modules in production covering system proxy management, socket connection pooling, and protocol parsing.
My work spans the full product lifecycle — from architecture design to app store deployment — across iOS, Android, macOS, Windows, and Linux. I've built apps serving 10K+ daily active users with complex features including payment integration, real-time push notifications, and concurrent media processing.
Tech Stack
Technologies I work with daily
Cross-Platform
State Management
High-Performance
Native Development
Networking & Storage
Build & Tools
Projects I Built
Production apps with real users and measurable impact
BitVPN
Cross-Platform VPN Proxy Client
2023 - 2025
Production-grade cross-platform VPN proxy client with Mihomo kernel integration, supporting 20+ protocols across 5 platforms. Architected with multi-layer resilience (circuit breaker, graceful degradation, DoH failover), Rust FFI with panic boundary safety, and concurrency-safe state machines preventing ABA races.
Key Implementations
- ▸ Concurrency Safety: VPN state machine with generation counters (CAS-style ABA prevention) — timer-based error recovery checks generation before overwriting, preventing stale timers from corrupting valid state transitions
- ▸ Completer-based Operation Lock: connect/disconnect serialized via Completer with 30s timeout; ghost lock detection force-completes stale Completers before acquiring new ones, eliminating deadlocks from crashed operations
- ▸ Rust FFI Panic Boundary: ffi_catch_unwind! macro wraps all extern "C" functions with std::panic::catch_unwind(AssertUnwindSafe(...)), preventing Rust panics from unwinding into Dart; CAS (compare_exchange with AcqRel ordering) guards concurrent proxy operations against TOCTOU races
- ▸ Isolate-safe FFI: DynamicLibrary cannot cross isolate boundaries — Windows/Linux reopen .dll/.so per-isolate, macOS uses DynamicLibrary.process() for static libs; manual malloc/free lifecycle with Rust-allocated pointer arrays (length encoded as negative first element)
- ▸ RAII via Dart Finalizer: ProcessGuard attaches Finalizer callback to kill orphan processes on GC, matching Rust Drop trait semantics; detach on explicit dispose() prevents double-cleanup
- ▸ In-flight Request Deduplication: stores Future (not result) in Map — concurrent identical requests await same Future, then extract data independently; critical-path URLs auto-promote to 7-channel racing across API gateways
- ▸ 7-Channel Racing Resolution: Completer-based first-win pattern with CancelToken propagation — first successful gateway completes Completer and cancels all others; all-fail scenario aggregates to single error; timeout cancels all tokens preventing request leaks
Technical Highlights
- ▸ DoH Resolver: triple pattern — in-flight dedup (shared Future), grace period (60min expired-IP fallback with background refresh), concurrent DoH server racing (first-win Completer); prevents thundering herd under DNS pollution
- ▸ Circuit Breaker: per-endpoint 3-state (CLOSED/OPEN/HALF_OPEN) with progressive backoff (30s→600s via 2^n); health scoring (successRate*80 + latencyBonus*20 - recencyPenalty).clamp(0,100); cross-session persistence via SharedPreferences with 15min grace
- ▸ 3-Level Graceful Degradation: normal (0-2 fails) → degraded (3+: cached data, hide non-core) → emergency (6+: VPN connect/disconnect only); auto-recovery timers (emergency→degraded 10min, degraded→normal 5min)
- ▸ Optimistic UI with Rollback: state updates immediately on user action, backend operation runs async; success confirms, failure rolls back to previous state and rethrows — UI never shows inconsistent state
- ▸ Dual Crash Reporting: Crashlytics (production, last 64 logs per crash, user identity binding) + Sentry APM (debug, full sampling, jank detection at 500ms/3-consecutive threshold, ANR watchdog 5s); Zone-based print() interception captures all output system-wide
Cloud Museum
Art Authentication Platform
Dec 2024 - Oct 2025
Full-featured B2C art authentication marketplace with 10K+ DAU. Supports online/offline authentication, digital collection preservation, membership tiers, and payment transactions.
UI Design Showcase Figma Design Screens
Homepage & AI Chatbot
Waterfall Gallery
AI Authentication Report
Authentication Result
Gallery & Login
Upload & History
Key Implementations
- ▸ Led architecture design with ViewModel + Service + Repository three-layer pattern enabling clean separation of UI, business logic, and data access
- ▸ Built unified reactive state management with GetX: global state, business modules, routing, dependency injection
- ▸ Concurrent media upload pipeline: 6 images + 1 video, local image compression (30% bandwidth savings), real-time progress
- ▸ Dual payment integration: WeChat Pay (App + URL Scheme) and Alipay (Universal Link + URL Scheme) with complete state machine handling timeout, cancellation, retry
- ▸ JPush-based push notifications with alias management, message categorization, and Deep Link navigation to specific pages
- ▸ Rust FFI via flutter_rust_bridge for performance-critical RSA encryption and digital signature verification
Technical Highlights
- ▸ 5-minute intelligent cache with TTL invalidation reducing API calls by 40%
- ▸ Image compression pipeline reducing bandwidth by 30%
- ▸ Dual payment state machine with full error recovery flow
Architecture & Code Deep Dive
BitVPN — sanitized code snippets demonstrating technical depth. Source repos are private (company NDA).
System Architecture
UI Layer
lib/pages/ · lib/widgets/ViewModel & State
lib/models/ · lib/bitState/AppModel
VPN status · Theme · UI
ServerModel
Node list · Selection · Cache
UserModel
Auth · Preferences
bitConfigState
Riverpod StateProvider
BaseModel extends ChangeNotifier · PageState (loading / error / success)
Service Layer
lib/service/MihomoConnectionService
Proxy switch · Connect · Disconnect
EndpointRegistry
Circuit breaker · Health scoring (0-100)
GatewayHeartbeat
Active probing · 60s · Exp. backoff
DegradationManager
3-level graceful degradation
ConfigResolver
7-channel race · DoH · IP direct
FallbackManager
Node failover · Exp. backoff
MonitorService
Sentry APM · Jank · ANR watchdog
CrashlyticsService
User binding · Custom keys · Non-fatal
ConfigManager
C3 pipeline · Debounce · Rollback
Desktop: MihomoPortManager · ProcessCleanup · TrayService · BinaryResolver · ResourceCleanupUtil
FFI Bridge & Platform Channels
lib/utils/ffi/ · lib/channels/Rust FFI (base_ffi.dart)
Isolate-safe · Lazy init · Platform detection
Platform Channels
MethodChannel · EventChannel (Android/iOS)
Native Layer
native/ · android/ · ios/Android
Kotlin
TunnelService
Mihomo Core
iOS
Swift
PacketTunnel
NetworkExt
macOS
Static lib
.process()
Universal
Windows
DLL
x64 / ARM64
WinReg
Linux
.so
x64 / ARM
iptables
Rust FFI Modules (bit_native)
sysproxy
mihomo_socket
process_guard
port_scanner
hostname
privilege
network_if
sysinfo
timer
winreg
clash_verge_svc
tokio runtime
Compiled as staticlib + rlib · Dependencies: sysproxy-rs, tokio, sysinfo, network-interface
Code Deep Dive Sanitized snippets — concurrency, FFI safety, resilience patterns
// CAS-style: stale timer can't
// overwrite valid state transition
int _stateGeneration = 0;
void setError(String error) {
_connectionState = VpnConnectionState.error;
_stateGeneration++;
final genAtError = _stateGeneration;
// 5s recovery timer — but only if
// no new state change happened
_recoveryTimer = Timer(5.s, () {
if (_stateGeneration == genAtError
&& _connectionState == .error) {
_connectionState = .disconnected;
_stateGeneration++;
}
});
} // Serializes connect/disconnect ops
Completer<void>? _operationLock;
Future<bool> _acquireOperationLock()
async {
if (_operationLock != null
&& !_operationLock!.isCompleted) {
try {
await _operationLock!.future
.timeout(30.s);
} on TimeoutException {
// Force-complete stale Completer
// to unblock all waiters
_operationLock!.complete();
}
}
_operationLock = Completer<void>();
return true;
} // Macro: catch Rust panic at FFI
macro_rules! ffi_catch_unwind {
($body:expr) => {
std::panic::catch_unwind(
AssertUnwindSafe(|| $body))
.unwrap_or(ERROR_RUNTIME)
};
}
// CAS guards concurrent proxy ops
static UPDATING: AtomicBool = ..;
#[no_mangle]
pub extern "C" fn set_global(..) {
ffi_catch_unwind!({
// compare_exchange: AcqRel
if UPDATING.compare_exchange(
false, true,
Ordering::AcqRel, Ordering::Acquire
).is_err() {
return ERROR_BUSY;
}
let r = set_global_inner(..);
UPDATING.store(false, Release);
r
})
} // DynamicLibrary can't cross isolates
static List<int> _findInIsolate(
_Params p) {
final lib = p.libPath != null
? DynamicLibrary.open(p.libPath!)
: DynamicLibrary.process();
// Manual malloc/free lifecycle
final name = p.name.toNativeUtf8();
final pids = findByName(name.cast());
malloc.free(name);
// Length = -pids[0] (Rust convention)
final len = -pids.value;
freePidArray(pids); // Rust dealloc
}
// RAII: Finalizer = Rust Drop trait
static final _finalizer =
Finalizer<void Function()>(
(cb) => cb());
ProcessGuard._(handle) {
_finalizer.attach(this,
() => FFI.kill(handle),
detach: this); // no double-free
} // Store Future, not result — all
// concurrent callers share one flight
static final _inflight =
<String, Future<Response>>{}
Future get(url) async {
final key = 'GET:$url';
if (_inflight[key] != null)
return await _inflight[key]!;
// Critical path → auto-race
final f = isCritical(url)
? _raceGateways(url) : dio.get(url);
_inflight[key] = f;
try { return await f;
} finally { _inflight.remove(key); }
}
// First-win: Completer + CancelToken
final c = Completer<Response>();
gateways.forEach((gw) => dio.get(
gw + url, cancelToken: ct)
.then((r) {
if (!c.isCompleted) {
c.complete(r); cancelOthers();
}
})); // Triple pattern: dedup + grace + race
Future<String?> resolve(domain) {
final cached = _cache[domain];
if (cached != null) {
if (!cached.expired) return cached.ip;
// 60min grace: serve stale, refresh bg
if (!cached.graceExpired) {
_refreshInBackground(domain);
return cached.ip;
}
}
// Dedup: share Future for same domain
return _pending.putIfAbsent(
domain, () => _queryServers(domain));
}
// 3-level degradation + auto-recovery
enum Level { normal, degraded, emergency }
// emergency→degraded: 10min timer
// degraded→normal: 5min timer Experience
My professional journey
Cloud Museum Data Group Co., Ltd.
Flutter Developer
- ▸ Led core business module development for art authentication platform (10K+ DAU)
- ▸ Architected state management, payment integration, push notifications
- ▸ Integrated Rust FFI for cryptographic operations
Beijing ZeroOne Smart Technology
Flutter Developer
- ▸ Built cross-platform VPN client across 5 platforms with multi-layer resilience (circuit breaker, graceful degradation, DoH fallback)
- ▸ Designed 11-module Rust FFI architecture and custom DoH resolver with concurrent racing and self-healing endpoint pool
- ▸ Implemented dual crash reporting (Crashlytics + Sentry APM), jank detection, and GitHub Actions CI/CD for 5-platform releases
Hebei University
B.S. in Bioinformatics
Let's Work Together
I'm available as a remote contractor for US companies. Whether through 1099 contractor (ITIN in process), W-8BEN individual agreement, or B2B contract via my company entity, I'm ready to help build your next cross-platform application.