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.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.
JavaVersion.VERSION_17 in build.gradle.ktsThe project targets
compileSdk = 35 and minSdk = 24 (Android 7.0+). Any emulator or physical device running Android 7.0 or higher will work.The root of the cloned directory contains the Android project. Do not open any inner subdirectory — open the root in Android Studio.
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).Create a Firebase project
- Go to console.firebase.google.com and click Add project.
- Choose a project name (e.g.
la-previa-dev) and follow the wizard.
Enable Realtime Database
- In the Firebase Console, navigate to Build → Realtime Database.
- Click Create database and choose a region.
- Select Start in test mode for local development (you can tighten rules later).
Enable Authentication
- Navigate to Build → Authentication → Sign-in method.
- Enable Email/Password as a provider.
- 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
- In Project settings → General, scroll to Your apps and click the Android icon.
- Register the package name
com.laprevia.restobar. - Download
google-services.json. - Place the file at
app/google-services.json(alongsidebuild.gradle.kts):
The
FIREBASE_API_KEY BuildConfig field is injected at compile time from local.properties. A template is provided at local.properties.example:# 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
# 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
The key is read in
build.gradle.kts and injected as a BuildConfig string field for every build variant:// 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
}
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.LaPreviaRestobar/ directory.build.gradle.kts).Shift+F10).The app should launch and display the Login screen within a few seconds. On first launch,
LaPreviaApp.onCreate() initialises Firebase and schedules SyncWorker:// LaPreviaApp.kt
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
FirebaseApp.initializeApp(this)
SyncWorker.schedule(this)
}
The Login screen (
LoginScreen) supports both quick role-selection (for local testing without Firebase Auth credentials) and full Firebase Email/Password authentication. Quick role select (testing)
Tap one of the three role buttons on the login screen:
| Button label | UserRole value | Destination route |
|---|---|---|
| MESERO | UserRole.MESERO | waiter_main |
| COCINERO | UserRole.COCINERO | chef_main |
| ADMIN | UserRole.ADMIN | admin_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:
LoginViewModelreads theUserRolefromUserPreferencesRepository.AppNavigation’sLaunchedEffectdetects the non-nullcurrentUser+userRoleand navigates automatically.- Each protected route checks
isAuthenticated && userRole == <expected role>before rendering; unauthenticated access redirects back tologin.
Backend: Express.js REST API
La Previa Restobar includes a companion Express.js server in thebackend/ 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:
- 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/
Troubleshooting
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.