Skip to content

LafaekStreet Mobile App - Deployment Guide

Guide for building and deploying the Flutter mobile app to connect with production API.


🌐 API Configuration

Production API

  • Domain: api.lafaekstreet.com
  • Base URL: https://api.lafaekstreet.com
  • Full API URL: https://api.lafaekstreet.com/api/v1

Development API (Depend your IP)

  • Local Backend: http://10.237.178.32:8000
  • Full API URL: http://10.237.178.32:8000/api/v1

📋 Environment Files

Available Environments

  1. .env.development - Local development

    • Uses local backend IP
    • Debug mode enabled
    • Detailed logging
  2. .env.production - Production builds

    • Uses https://api.lafaekstreet.com
    • Debug mode disabled
    • Optimized for release
  3. .env - Active configuration

    • Copy from .env.development or .env.production
    • This file is used by the app

🚀 Quick Start

For Development

bash
cd lafaekstreet_app

# Use development environment
cp .env.development .env

# Run app
flutter run

For Production Build

bash
cd lafaekstreet_app

# Use production environment
cp .env.production .env

# Build for Android
flutter build apk --release

# Or build App Bundle (for Play Store)
flutter build appbundle --release

# Build for iOS
flutter build ios --release

🔧 Configuration Details

API Configuration

The app uses EnvConfig class to load environment variables:

dart
// lib/core/config/env_config.dart
class EnvConfig {
  static String get apiBaseUrl => dotenv.env['API_BASE_URL'] ?? 'http://localhost:8000';
  static String get apiVersion => dotenv.env['API_VERSION'] ?? 'v1';
  static String get apiUrl => '$apiBaseUrl/api/$apiVersion';
}

API Service

All API calls go through ApiService:

dart
// lib/services/api_service.dart
class ApiService {
  String get baseUrl => EnvConfig.apiUrl;

  // Example: GET request
  Future<dynamic> get(String endpoint) async {
    final response = await http.get(
      Uri.parse('$baseUrl$endpoint'),
      headers: await _getHeaders(),
    );
    return _handleResponse(response);
  }
}

📱 Building for Production

Prerequisites

  1. Backend Deployed

    • Lightsail instance running
    • SSL certificate installed
    • API accessible at https://api.lafaekstreet.com
  2. DNS Configured

    • api.lafaekstreet.com points to Lightsail IP
    • DNS propagated globally
  3. Test API

    bash
    curl https://api.lafaekstreet.com/health

Android Build

1. Switch to Production Environment

bash
cd lafaekstreet_app
cp .env.production .env

2. Update Version

Edit pubspec.yaml:

yaml
version: 1.0.0+1 # Increment for each release

3. Build APK

bash
# Build APK (for direct installation)
flutter build apk --release

# Output: build/app/outputs/flutter-apk/app-release.apk
bash
# Build App Bundle
flutter build appbundle --release

# Output: build/app/outputs/bundle/release/app-release.aab

5. Test APK

bash
# Install on connected device
flutter install --release

# Or manually install
adb install build/app/outputs/flutter-apk/app-release.apk

iOS Build

1. Switch to Production Environment

bash
cd lafaekstreet_app
cp .env.production .env

2. Update Version

Edit pubspec.yaml:

yaml
version: 1.0.0+1 # Increment for each release

3. Build iOS

bash
# Build iOS
flutter build ios --release

# Open in Xcode for signing and distribution
open ios/Runner.xcworkspace

4. Archive and Upload

  1. In Xcode: Product → Archive
  2. Distribute App → App Store Connect
  3. Upload to TestFlight or App Store

🐛 Troubleshooting

Issue 1: API Connection Failed

Symptoms: App can't connect to API

Solutions:

  1. Check API URL in .env:

    bash
    cat .env | grep API_BASE_URL
    # Should be: API_BASE_URL=https://api.lafaekstreet.com
  2. Test API from browser:

    https://api.lafaekstreet.com/health
  3. Check device internet connection

  4. Verify SSL certificate:

    bash
    curl -v https://api.lafaekstreet.com/health

Issue 2: Wrong Environment

Symptoms: App connects to wrong API

Solutions:

bash
# Check current .env
cat .env | grep API_BASE_URL

# Switch to production
cp .env.production .env

# Rebuild app
flutter clean
flutter build apk --release

Issue 3: SSL Certificate Error

Symptoms: Certificate verification failed

Solutions:

  1. Ensure using HTTPS in production
  2. Check certificate validity:
    bash
    openssl s_client -connect api.lafaekstreet.com:443
  3. Update device date/time

Issue 4: CORS Error

Symptoms: "CORS policy blocked"

Solutions:

  1. Check backend CORS configuration
  2. Ensure backend allows your domain
  3. Mobile apps typically don't have CORS issues (browser-only)

📦 Distribution

Android

Google Play Store

  1. Build App Bundle:

    bash
    flutter build appbundle --release
  2. Upload to Play Console:

    • Go to Play Console
    • Create new release
    • Upload app-release.aab
    • Fill in release notes
    • Submit for review

Direct Distribution (APK)

  1. Build APK:

    bash
    flutter build apk --release
  2. Share APK file:

    • Upload to website
    • Share via email/messaging
    • Users must enable "Install from Unknown Sources"

iOS

App Store

  1. Build and archive in Xcode
  2. Upload to App Store Connect
  3. Submit for review

TestFlight

  1. Upload to App Store Connect
  2. Add internal/external testers
  3. Distribute beta builds

🔄 Update Process

For New Backend Changes

  1. Backend Updated → No app changes needed (if API compatible)

  2. API Changes → Update app code:

    bash
    # Update API service
    # Test with new endpoints
    # Rebuild app
    flutter build apk --release

For App Updates

  1. Update version in pubspec.yaml
  2. Update code
  3. Test thoroughly
  4. Build release
  5. Distribute

📱 App Store Metadata

App Name

LafaekStreet

Description

Civic engagement platform for Timor-Leste. Report road issues, track progress, and improve your community.

Keywords

civic, engagement, road, report, timor-leste, community

Category

Utilities / Productivity

Screenshots

  • Prepare 5-8 screenshots per device size
  • Show key features: report creation, map view, notifications

🎉 Success!

Production API: https://api.lafaekstreet.com

Build Commands:

bash
# Android
cp .env.production .env && flutter build apk --release

# iOS
cp .env.production .env && flutter build ios --release

📞 Support

Check Configuration

bash
cat .env | grep API_BASE_URL

Test API

bash
curl https://api.lafaekstreet.com/health

View Logs

bash
flutter logs

Happy Building! 🚀

Built for Timor-Leste