Skip to main content
Threadly requires a backend server for authentication, data storage, and real-time messaging. This guide shows you how to set up and configure the backend connection.

Backend Repository

Threadly’s backend is hosted in a separate repository:

Threadly Server

Node.js + Express + MySQL backend with Socket.IO support

Backend Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MySQL
  • Real-time: Socket.IO
  • Push Notifications: Firebase Cloud Messaging (FCM)

Configuration Options

You have two options for backend configuration:

Use the Hosted Instance

The easiest way to get started is using the pre-configured hosted backend:
  • API URL: https://threadlyserver.onrender.com/api
  • Socket URL: https://threadlyserver.onrender.com/
The debug build variant is pre-configured with these URLs. No changes needed!
The hosted backend may have usage limits or slower response times. For production use, deploy your own instance.

Update Endpoint Configuration

To point Threadly to your own backend instance, update the build configuration:
1

Open app/build.gradle

Navigate to app/build.gradle in your Android Studio project.
2

Locate buildTypes section

Find the buildTypes block with debug and release configurations:
app/build.gradle
buildTypes {
    debug {
        buildConfigField "String", "BASE_URL",  "\"https://threadlyserver.onrender.com/api\""
        buildConfigField "String", "SOCKET_URL",  "\"https://threadlyserver.onrender.com/\""
    }
    release {
        buildConfigField "String", "BASE_URL",   "\"https://threadlyserver.onrender.com/api\""
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
3

Update the URLs

Replace the URLs with your backend endpoints:
buildTypes {
    debug {
        buildConfigField "String", "BASE_URL",  "\"http://10.0.2.2:8001/api\""
        buildConfigField "String", "SOCKET_URL",  "\"http://10.0.2.2:8001/\""
    }
}
  • Use 10.0.2.2 for Android emulator to access localhost on your machine
  • For physical devices, use your machine’s local IP address (e.g., 192.168.1.x)
  • Always include /api suffix for BASE_URL
  • Always include trailing / for SOCKET_URL
4

Sync Gradle

Click Sync Now in the notification bar, or:
  • Windows/Linux: Ctrl + Shift + O
  • macOS: Cmd + Shift + O
5

Rebuild the app

Click Build > Rebuild Project to apply the new configuration.

Accessing BuildConfig Values

The configured URLs are available throughout your app via BuildConfig:
Java
import com.rtech.threadly.BuildConfig;

public class ApiService {
    private static final String BASE_URL = BuildConfig.BASE_URL;
    private static final String SOCKET_URL = BuildConfig.SOCKET_URL;
    
    // Use these constants in your API calls
}

Verify Backend Connection

After configuration, verify the connection:
1

Run the app

Launch Threadly on your device or emulator.
2

Check Logcat

Open Logcat in Android Studio and filter for network requests:
tag:OkHttp OR tag:Socket.IO
3

Test authentication

Try to log in or sign up. Successful requests indicate proper backend connectivity.
Connected successfully? You’re ready to use all of Threadly’s features.

Troubleshooting

  • Verify backend server is running
  • Check firewall settings
  • Ensure URLs are correctly formatted (no typos)
  • For local development, confirm your device can reach the server
  • Verify BASE_URL ends with /api
  • Check backend routes are properly configured
  • Confirm backend database is set up correctly
  • Ensure SOCKET_URL has trailing /
  • Check CORS settings on backend
  • Verify Socket.IO server is running on the correct port
  • Check Logcat for Socket.IO connection events
Update both debug and release build types separately:
buildTypes {
    debug {
        buildConfigField "String", "BASE_URL", "\"https://dev.api.com/api\""
    }
    release {
        buildConfigField "String", "BASE_URL", "\"https://api.com/api\""
    }
}

Environment-Specific Configuration

For team development, consider creating product flavors for different environments:
android {
    flavorDimensions "environment"
    productFlavors {
        dev {
            dimension "environment"
            buildConfigField "String", "BASE_URL", "\"https://dev-api.com/api\""
        }
        staging {
            dimension "environment"
            buildConfigField "String", "BASE_URL", "\"https://staging-api.com/api\""
        }
        prod {
            dimension "environment"
            buildConfigField "String", "BASE_URL", "\"https://api.com/api\""
        }
    }
}

Next Steps

Firebase Setup

Configure push notifications for real-time message delivery

Build docs developers (and LLMs) love