Skip to content

๐Ÿ“ฑ Tobogganing Mobile Development Guide

๐ŸŽฏ Overview

Tobogganing includes a React Native mobile application for Android and iOS (planned) that provides secure VPN access with an intuitive mobile interface. This guide covers setup, development, building, and deployment of the mobile client.

๐Ÿ“‹ Table of Contents


๐Ÿš€ Quick Setup

One-Command Setup

# Install Android Studio, SDK, and build mobile app
./scripts/setup-android-studio.sh

# Deploy mobile app to device/emulator
./scripts/deploy-mobile.sh

Manual Setup

# 1. Install Node.js dependencies
cd clients/mobile
npm install

# 2. Set up Android development environment
./scripts/setup-android-studio.sh

# 3. Build and test
npm run android

๐Ÿ”ง Development Environment

Prerequisites

  • Node.js 18+: JavaScript runtime
  • Android Studio: For Android development
  • Android SDK API 34: Target Android platform
  • Java 17: Required for Android builds
  • Chrome/Chromium: For screenshot generation

Automated Setup

The setup script handles all prerequisites:

# Complete Android development setup
./scripts/setup-android-studio.sh

# Available options:
./scripts/setup-android-studio.sh --help
./scripts/setup-android-studio.sh --verify          # Verify installation
./scripts/setup-android-studio.sh --build-app       # Build app only
./scripts/setup-android-studio.sh --start-emulator  # Start emulator
./scripts/setup-android-studio.sh --create-avd      # Create virtual device

Manual Environment Setup

If you prefer manual setup:

# Install Android Studio
# Download from: https://developer.android.com/studio

# Set environment variables
export ANDROID_HOME=/opt/android-sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools

# Install React Native CLI
npm install -g @react-native-community/cli

# Install mobile dependencies
cd clients/mobile
npm install

Verify Environment

# Check React Native environment
npx react-native doctor

# Expected output:
# โœ“ Node.js - Required to execute JavaScript code
# โœ“ npm - Required to install NPM dependencies
# โœ“ Android Studio - Required for building and installing your app on Android
# โœ“ Android SDK - Required for building and installing your app on Android
# โœ“ ANDROID_HOME - Environment variable that points to your Android SDK installation

๐Ÿ“ฑ Mobile App Architecture

Technology Stack

  • Framework: React Native 0.72.6
  • Language: TypeScript
  • Navigation: React Navigation v6
  • State Management: React Context + Hooks
  • Storage: React Native AsyncStorage + Keychain
  • Networking: Axios
  • UI Components: Custom components with React Native
  • Platform: Android (iOS planned for v1.1+)

Project Structure

clients/mobile/
โ”œโ”€โ”€ android/                     # Android-specific code
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ build.gradle         # Android build configuration
โ”‚   โ”‚   โ””โ”€โ”€ src/main/
โ”‚   โ”‚       โ”œโ”€โ”€ AndroidManifest.xml
โ”‚   โ”‚       โ”œโ”€โ”€ java/com/tobogganing/mobile/
โ”‚   โ”‚       โ””โ”€โ”€ res/             # Android resources
โ”‚   โ”œโ”€โ”€ build.gradle             # Root build configuration
โ”‚   โ”œโ”€โ”€ gradlew                  # Gradle wrapper
โ”‚   โ””โ”€โ”€ settings.gradle          # Gradle settings
โ”œโ”€โ”€ ios/                         # iOS-specific code (planned)
โ”œโ”€โ”€ src/                         # React Native source code
โ”‚   โ”œโ”€โ”€ App.tsx                  # Main app component
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ build.ts             # Build configuration
โ”‚   โ”œโ”€โ”€ constants/
โ”‚   โ”‚   โ””โ”€โ”€ Colors.ts            # App color scheme
โ”‚   โ”œโ”€โ”€ providers/               # React Context providers
โ”‚   โ”‚   โ”œโ”€โ”€ ConfigProvider.tsx   # Configuration management
โ”‚   โ”‚   โ”œโ”€โ”€ ThemeProvider.tsx    # Theme management
โ”‚   โ”‚   โ””โ”€โ”€ VPNProvider.tsx      # VPN state management
โ”‚   โ”œโ”€โ”€ screens/                 # App screens
โ”‚   โ”‚   โ”œโ”€โ”€ AboutScreen.tsx      # About/info screen
โ”‚   โ”‚   โ”œโ”€โ”€ ConfigurationScreen.tsx # VPN configuration
โ”‚   โ”‚   โ”œโ”€โ”€ ConnectionScreen.tsx # Main connection screen
โ”‚   โ”‚   โ”œโ”€โ”€ SettingsScreen.tsx   # App settings
โ”‚   โ”‚   โ””โ”€โ”€ StatisticsScreen.tsx # Connection statistics
โ”‚   โ”œโ”€โ”€ types/                   # TypeScript type definitions
โ”‚   โ”œโ”€โ”€ utils/                   # Utility functions
โ”‚   โ”‚   โ””โ”€โ”€ formatters.ts        # Data formatting utilities
โ”‚   โ””โ”€โ”€ assets/                  # Images, fonts, etc.
โ”œโ”€โ”€ package.json                 # Node.js dependencies
โ”œโ”€โ”€ metro.config.js              # Metro bundler configuration
โ”œโ”€โ”€ babel.config.js              # Babel configuration
โ”œโ”€โ”€ tsconfig.json                # TypeScript configuration
โ””โ”€โ”€ app.json                     # React Native app configuration

Key Components

๐Ÿ”Œ VPN Connection Management

  • VPNProvider: Manages VPN connection state
  • ConnectionScreen: Main interface for connection control
  • WireGuard Integration: Native WireGuard client integration

โš™๏ธ Configuration Management

  • ConfigProvider: Handles app configuration and server settings
  • ConfigurationScreen: User interface for VPN configuration
  • Secure Storage: Encrypted storage for sensitive data

๐Ÿ“Š Monitoring & Statistics

  • StatisticsScreen: Real-time connection statistics
  • Performance Metrics: Data usage, connection quality
  • Health Monitoring: Connection status and diagnostics

๐Ÿ”’ Security Features

  • Certificate Management: X.509 certificate handling
  • Biometric Authentication: Fingerprint/face unlock
  • Secure Keychain: Encrypted credential storage

๐Ÿ—๏ธ Building & Deployment

Quick Build & Deploy

# Build and deploy in one command
./scripts/deploy-mobile.sh

# Output:
# โœ… APK built successfully!
# ๐Ÿ“ฑ APK ready for installation
# To install: adb install -r path/to/app-debug.apk

Manual Build Process

# Navigate to mobile project
cd clients/mobile

# Install dependencies
npm install

# Build Android APK
cd android
./gradlew assembleDebug

# APK location: android/app/build/outputs/apk/debug/app-debug.apk

Build Configurations

Development Build

# Build for development
BUILD_TYPE=development ./scripts/deploy-mobile.sh

# Features:
# - Debug mode enabled
# - Development API endpoints
# - Debugging tools available

Staging Build

# Build for staging
BUILD_TYPE=staging ./scripts/deploy-mobile.sh

# Features:
# - Staging API endpoints
# - Performance optimizations
# - Limited debugging

Production Build

# Build for production
BUILD_TYPE=production npm run build:android

# Features:
# - Production API endpoints
# - Full optimizations
# - No debugging tools
# - Code obfuscation

Installation & Deployment

Install to Connected Device

# Install APK to connected Android device
adb install -r clients/mobile/android/app/build/outputs/apk/debug/app-debug.apk

# Check connected devices
adb devices

# View app logs
adb logcat | grep Tobogganing

Install to Emulator

# Start Android emulator
./scripts/setup-android-studio.sh --start-emulator

# Wait for emulator to start
adb wait-for-device

# Install app
./scripts/deploy-mobile.sh

Automated CI/CD

The GitHub Actions workflow automatically builds mobile apps:

# .github/workflows/mobile.yml
- name: Build Android APK
  run: |
    cd clients/mobile/android
    ./gradlew assembleDebug

- name: Upload APK Artifact
  uses: actions/upload-artifact@v3
  with:
    name: android-apk
    path: clients/mobile/android/app/build/outputs/apk/debug/app-debug.apk

๐Ÿงช Testing

Unit Testing

# Run unit tests
cd clients/mobile
npm test

# Run with coverage
npm run test:coverage

# Watch mode for development
npm run test:watch

Integration Testing

# Test React Native environment
npx react-native doctor

# Test Android build
./scripts/deploy-mobile.sh

# Test emulator deployment
./scripts/setup-android-studio.sh --start-emulator
adb wait-for-device
adb install -r android/app/build/outputs/apk/debug/app-debug.apk

Manual Testing Checklist

  • Connection Flow
  • Initial app setup with API key
  • VPN connection establishment
  • Connection status updates
  • Disconnect functionality

  • Configuration

  • Server configuration
  • Auto-connect settings
  • Biometric authentication
  • Theme switching

  • Statistics & Monitoring

  • Real-time data usage
  • Connection quality metrics
  • Historical statistics
  • Export functionality

  • Security

  • Certificate validation
  • Secure credential storage
  • Biometric unlock
  • Auto-lock functionality

๐Ÿ“Š Features

Core Functionality

๐Ÿ”Œ VPN Connection

  • WireGuard Integration: Native WireGuard protocol support
  • Auto-Connect: Automatic connection on app launch
  • Quick Connect: One-tap connection establishment
  • Connection Profiles: Multiple server configurations
  • Offline Support: Graceful handling of network changes

โš™๏ธ Configuration Management

  • Server Settings: Manager URL and authentication
  • Connection Preferences: Auto-connect, timeout settings
  • Security Options: Biometric authentication, auto-lock
  • Network Settings: DNS, proxy configuration
  • Backup/Restore: Configuration backup and restore

๐Ÿ“Š Monitoring & Statistics

  • Real-time Metrics: Data usage, connection speed
  • Historical Data: Usage patterns over time
  • Performance Monitoring: Latency, packet loss
  • Data Export: Export statistics for analysis
  • Alerts: Connection status notifications

๐Ÿ”’ Security Features

  • Dual Authentication: Certificate + JWT tokens
  • Biometric Security: Fingerprint/face unlock
  • Secure Storage: Encrypted credential storage
  • Certificate Management: Automatic certificate updates
  • Security Alerts: Threat detection notifications

User Interface

๐ŸŽจ Modern Design

  • Material Design: Android-native UI patterns
  • Dark/Light Themes: Automatic theme switching
  • Responsive Layout: Optimized for all screen sizes
  • Smooth Animations: Fluid transitions and interactions
  • Accessibility: Screen reader and accessibility support
  • Bottom Tabs: Main navigation structure
  • Stack Navigation: Hierarchical screen flow
  • Drawer Navigation: Settings and advanced options
  • Deep Linking: URL-based navigation support
  • Back Button: Native Android back button support

Advanced Features

๐Ÿ›ก๏ธ Enterprise Security

  • MDM Integration: Mobile Device Management support
  • Compliance Reporting: Security compliance status
  • Remote Configuration: Centralized configuration management
  • Audit Logging: Detailed security event logging
  • Zero-Touch Deployment: Automated configuration

๐Ÿ“ˆ Analytics & Insights

  • Usage Analytics: App usage patterns
  • Performance Metrics: App performance monitoring
  • Crash Reporting: Automatic crash reporting
  • User Feedback: In-app feedback collection
  • A/B Testing: Feature testing framework

๐Ÿ”ง Troubleshooting

Common Issues

Build Failures

Gradle Build Errors

# Clear Gradle cache
cd clients/mobile/android
./gradlew clean

# Clear React Native cache
cd clients/mobile
npx react-native clean

# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install

Metro Bundler Issues

# Reset Metro cache
npx react-native clean
npx react-native start --reset-cache

# Clear watchman
watchman watch-del-all

Android SDK Issues

# Verify Android environment
./scripts/setup-android-studio.sh --verify

# Reinstall Android SDK components
./scripts/setup-android-studio.sh --create-avd

Runtime Issues

VPN Connection Failures

# Check device logs
adb logcat | grep Tobogganing

# Verify network connectivity
adb shell ping manager.example.com

# Check certificate validity
adb shell cat /data/data/com.tobogganing.mobile/files/cert.pem

Performance Issues

# Enable performance monitoring
adb shell setprop debug.choreographer.skipwarning 1

# Monitor memory usage
adb shell dumpsys meminfo com.tobogganing.mobile

# Check CPU usage
adb shell top | grep tobogganing

Debug Tools

React Native Debugger

# Enable debugging
npx react-native run-android --variant=debug

# Open Chrome DevTools
# Navigate to: chrome://inspect

Android Studio Debugging

# Open project in Android Studio
~/open-tobogganing-mobile.sh

# Use Android Studio debugger
# Set breakpoints in Java/Kotlin code
# Use Logcat for runtime logging

Native Logging

# View React Native logs
npx react-native log-android

# View native Android logs
adb logcat *:E | grep Tobogganing

# Export logs for analysis
adb logcat -d > tobogganing-logs.txt

Performance Optimization

Build Optimization

# Enable Proguard for release builds
# Edit android/app/build.gradle:
# minifyEnabled true

# Optimize bundle size
npx react-native bundle --dev false --platform android

# Generate APK with optimizations
cd android && ./gradlew assembleRelease

Runtime Optimization

# Enable Hermes engine
# Edit android/app/build.gradle:
# enableHermes: true

# Optimize images
# Use WebP format for images
# Implement lazy loading

Getting Help

This comprehensive mobile development guide provides everything needed to develop, build, test, and deploy the Tobogganing mobile application across different environments and use cases.