The La Previa Restobar backend is a lightweight Express.js server (v4.18.2) that uses theDocumentation 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.
firebase-admin SDK (v12.0.0) to bridge the Android client to a Firebase Realtime Database. Every resource endpoint reads from or writes to a named node in the database (products, orders, tables, inventory, users). The server listens on port 3000 and requires a serviceAccountKey.json credential file to authenticate with Firebase.
Base URL
The Android app selects the base URL automatically at runtime throughNetworkModule, using BuildConfig.BASE_URL for emulator targets and BuildConfig.PHYSICAL_BASE_URL for physical devices.
| Environment | Target | Base URL |
|---|---|---|
debug | Android Emulator | http://10.0.2.2:8080/ |
debug | Physical Device | http://192.168.0.104:8080/ |
staging | Physical Device | http://192.168.0.104:8080/ |
release | Production | https://api.laprevia.com/ |
Note:10.0.2.2is the special loopback alias the Android Emulator uses to reach the host machine’slocalhost. Use this address when running both the server and emulator on the same development machine.
Port discrepancy:server.jslistens on port 3000 (seeapp.listen(3000, ...)andEXPOSE 3000in the Dockerfile). However, the Android app’sBuildConfig.BASE_URLvalues all use port 8080. When the backend is deployed to Cloud Run, the platform remaps the container’s port 3000 to the externally visible port 8080. For local development, run the server normally on port 3000 and — if you are not using Cloud Run — either update thedebugBASE_URLinbuild.gradle.ktsto use port 3000, or place a reverse proxy in front of the server on port 8080.
How the Android App Consumes the API
The Android app uses Retrofit 2 with an OkHttp client, wired together by Hilt inNetworkModule. Key configuration details:
- Converter:
GsonConverterFactory— all bodies are JSON serialized/deserialized via Gson. - Timeouts: 30 seconds for connect, read, and write.
- Logging:
HttpLoggingInterceptorlogs full request/response bodies inDEBUGbuilds; logging is suppressed inreleasebuilds. - Emulator detection:
NetworkModule.isRunningOnEmulator()checksBuild.FINGERPRINT,Build.MODELfor emulator signatures and routes to the correct base URL automatically. - Coroutines: Every
ApiServicefunction issuspend, intended to be called from a Kotlin coroutine scope (e.g., aViewModel).
Authentication
The currentserver.js does not enforce any authentication headers or tokens on incoming requests. This is a development-grade API — no Bearer tokens, API keys, or session cookies are required for any endpoint. When moving to a production deployment you should add middleware (e.g., Firebase ID token verification) before exposing the server publicly.
Health Check
Use the health endpoint to verify the server is reachable before making resource calls.ApiService maps this to:
Endpoint Summary
The table below covers every route exposed by the backend, including both the typed Retrofit endpoints (ApiService.kt) and the raw Firebase pass-through routes in server.js.
| Method | Path | Description |
|---|---|---|
GET | /api/health | Server health check |
GET | /products | List all menu products |
GET | /products/{id} | Get a single product by ID |
POST | /products | Create a new product |
PUT | /products/{id} | Update an existing product |
DELETE | /products/{id} | Delete a product |
GET | /products/categories | List distinct product categories |
GET | /orders | List all orders |
GET | /orders/table/{tableId} | List orders for a specific table |
POST | /orders | Create a new order |
PUT | /orders/{id}/status | Update an order’s status |
GET | /tables | List all tables |
GET | /tables/{id} | Get a single table by ID |
PUT | /tables/{id}/status | Update a table’s status |
GET | /inventory | List all inventory records |
PUT | /inventory/{productId}/stock | Update stock for a product |
GET | /inventario | Raw Firebase inventory read |
POST | /inventario | Raw Firebase inventory write |
GET | /usuarios | Raw Firebase user list |
POST | /usuarios | Raw Firebase user save |
Running Locally
Prerequisites:- Node.js 18 or later.
- A Firebase project with Realtime Database enabled.
- A
serviceAccountKey.jsonfile downloaded from the Firebase console (Project Settings → Service accounts → Generate new private key). Place it in the same directory asserver.js.
http://localhost:3000. If you are hitting it from an Android Emulator, use http://10.0.2.2:3000 as the base URL in your build config.
Docker Deployment
ADockerfile is included for containerised deployment. It uses the official node:18 base image, copies all backend files, runs npm install, exposes port 3000, and starts the server with node server.js.
Important: Make sureserviceAccountKey.jsonis present in the build context before runningdocker build, as it is copied into the image byCOPY . ..
Resource Pages
Products
CRUD operations for menu items, pricing, and inventory tracking flags.
Orders
Create orders and advance them through the eight-step status lifecycle.
Tables
Retrieve table configurations and update table status as orders progress.
Inventory
Read current stock levels and update quantities for tracked products.