956 B
956 B
FatihsMG4 consumption API
The Android app never connects to MongoDB directly and never contains a MongoDB URI. This
service accepts authenticated all-time totals and upserts them into the consumption collection.
Run
-
Copy
.env.exampleto.envand fill in the MongoDB Atlas URI and a random API token. -
Export the variables (Node does not load
.envautomatically), then runnpm installandnpm start. -
Build the Android app with the public HTTPS service address and the same token:
CONSUMPTION_API_URL=https://your-api.example.com \ CONSUMPTION_API_TOKEN=your-random-token \ ./gradlew assembleUnstableRelease
If either Android build variable is missing, cloud sync is disabled and local consumption
tracking continues unchanged. MongoDB receives one continuously updated document per installation,
containing all-time km, kwh, hours, and socDrop totals plus the manually entered sohPercent.