Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/luisumit/LaPreviaRestobar/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you through every step needed to run La Previa Restobar on a local Android emulator or physical device. The only external service required is a Firebase project — everything else is included in the repository.
1
Install prerequisites
2
Make sure the following tools are installed before you clone:
3
RequirementMinimum versionNotesAndroid StudioJellyfish (2023.3.1) or laterRequired for the Compose toolingJava / JDK17Compile options are set to JavaVersion.VERSION_17 in build.gradle.ktsGitAny recent versionFor cloning the repositoryFirebase account—Free Spark plan is sufficient
4
The project targets compileSdk = 35 and minSdk = 24 (Android 7.0+). Any emulator or physical device running Android 7.0 or higher will work.
5
Clone the repository
6
git clone https://github.com/luisumit/LaPreviaRestobar.git
cd LaPreviaRestobar
7
The root of the cloned directory contains the Android project. Do not open any inner subdirectory — open the root in Android Studio.
8
Configure Firebase
9
La Previa Restobar requires three Firebase services: Realtime Database, Authentication, and optionally Performance Monitoring and Crashlytics (both are included in build.gradle.kts but will degrade gracefully without configuration).
10

Create a Firebase project

  1. Go to console.firebase.google.com and click Add project.
  2. Choose a project name (e.g. la-previa-dev) and follow the wizard.

Enable Realtime Database

  1. In the Firebase Console, navigate to Build → Realtime Database.
  2. Click Create database and choose a region.
  3. Select Start in test mode for local development (you can tighten rules later).

Enable Authentication

  1. Navigate to Build → Authentication → Sign-in method.
  2. Enable Email/Password as a provider.
  3. Create at least one test user per role under Users (or use the Login screen’s quick-select once the app is running).

Download google-services.json

  1. In Project settings → General, scroll to Your apps and click the Android icon.
  2. Register the package name com.laprevia.restobar.
  3. Download google-services.json.
  4. Place the file at app/google-services.json (alongside build.gradle.kts):
LaPreviaRestobar/
├── app/
│   ├── google-services.json   ← place it here
│   ├── build.gradle.kts
│   └── src/
google-services.json is listed in .gitignore. Never commit this file to a public repository.
11
Set local.properties
12
The FIREBASE_API_KEY BuildConfig field is injected at compile time from local.properties. A template is provided at local.properties.example:
13
# Template for local.properties
# Copy this file to local.properties and fill in the values

# Firebase API Key (found in google-services.json -> api_key -> current_key)
firebase.api.key=YOUR_API_KEY_HERE
14
Create or edit local.properties in the project root (not inside app/):
15
# local.properties  (project root)
sdk.dir=/Users/you/Library/Android/sdk

# Firebase API Key — copy from google-services.json -> api_key -> current_key
firebase.api.key=AIzaSyXXXXXXXXXXXXXXXXXXXXXXXXXXXX
16
The key is read in build.gradle.kts and injected as a BuildConfig string field for every build variant:
17
// app/build.gradle.kts
val localProperties = Properties()
val localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
    localProperties.load(localPropertiesFile.inputStream())
}

buildTypes {
    debug {
        buildConfigField(
            "String", "FIREBASE_API_KEY",
            "\"${localProperties.getProperty("firebase.api.key") ?: ""}\""
        )
        buildConfigField("String", "BASE_URL", "\"http://10.0.2.2:8080/\"")
        buildConfigField("String", "PHYSICAL_BASE_URL", "\"http://192.168.0.104:8080/\"")
        buildConfigField("String", "WS_URL", "\"ws://10.0.2.2:8080/ws\"")
        buildConfigField("String", "PHYSICAL_WS_URL", "\"ws://192.168.0.104:8080/ws\"")
    }
    // staging and release variants follow the same pattern
}
18
The three build variants — debug, staging, and release — each carry their own FIREBASE_API_KEY, ENVIRONMENT, BASE_URL, PHYSICAL_BASE_URL, WS_URL, and PHYSICAL_WS_URL BuildConfig fields. NetworkModule picks the correct URL at runtime by detecting whether the app is running on an emulator or a physical device.
19
Open and build in Android Studio
20
  • Open Android Studio and choose File → Open, then select the cloned LaPreviaRestobar/ directory.
  • Let Gradle sync finish (this downloads all dependencies declared in build.gradle.kts).
  • In the Build Variants panel (View → Tool Windows → Build Variants), select the debug variant.
  • Choose a target device — either an AVD (API 24+) or a connected physical device.
  • Press Run ▶ (or Shift+F10).
  • 21
    The app should launch and display the Login screen within a few seconds. On first launch, LaPreviaApp.onCreate() initialises Firebase and schedules SyncWorker:
    22
    // LaPreviaApp.kt
    override fun onCreate() {
        super.onCreate()
    
        if (BuildConfig.DEBUG) {
            Timber.plant(Timber.DebugTree())
        }
    
        FirebaseApp.initializeApp(this)
    
        SyncWorker.schedule(this)
    }
    
    23
    Log in and select your role
    24
    The Login screen (LoginScreen) supports both quick role-selection (for local testing without Firebase Auth credentials) and full Firebase Email/Password authentication.
    25
    Quick role select (testing)
    Tap one of the three role buttons on the login screen:
    Button labelUserRole valueDestination route
    MESEROUserRole.MESEROwaiter_main
    COCINEROUserRole.COCINEROchef_main
    ADMINUserRole.ADMINadmin_main
    AppNavigation immediately pops the login back-stack entry and navigates to the role’s main screen.
    Firebase Auth (production)
    Enter the email and password you created in step 3. On successful authentication:
    1. LoginViewModel reads the UserRole from UserPreferencesRepository.
    2. AppNavigation’s LaunchedEffect detects the non-null currentUser + userRole and navigates automatically.
    3. Each protected route checks isAuthenticated && userRole == <expected role> before rendering; unauthenticated access redirects back to login.

    Backend: Express.js REST API

    La Previa Restobar includes a companion Express.js server in the backend/ directory that exposes REST endpoints and a WebSocket channel consumed by SharedViewModel (via RealTimeWebSocketClient and ApiService). The Android app auto-detects the environment at runtime:
    // NetworkModule.kt
    private fun isRunningOnEmulator(): Boolean {
        return (android.os.Build.FINGERPRINT.startsWith("generic") ||
                android.os.Build.MODEL.contains("sdk") ||
                android.os.Build.MODEL.contains("Emulator") ||
                android.os.Build.MODEL.contains("Android SDK"))
    }
    
    • Emulator (debug): BASE_URL = http://10.0.2.2:8080/ (loopback to host machine)
    • Physical device (debug): PHYSICAL_BASE_URL = http://192.168.0.104:8080/
    • Release: BASE_URL = https://api.laprevia.com/
    The app functions fully without the backend — Firebase Realtime Database handles all real-time POS features. The Express.js server is only required for REST-specific features. See the API Overview for endpoint documentation.

    Troubleshooting

    Blank screen on launch — This usually means google-services.json is missing or the Firebase API key in local.properties is empty. Check Logcat for ❌ Error inicializando Firebase.
    Room schema migration — The database version is currently 7. If you pull new commits that bump the schema version, Room will call fallbackToDestructiveMigration() in the DatabaseModule-provided instance, dropping and recreating all tables. Back up any local test data before upgrading.

    Build docs developers (and LLMs) love