Lockstate
Mobile App2023

LOCKSTATE

LoRaWAN smart locks → TTN MQTT → Cloud Functions → Firestore → Flutter (Momentum) with FCM alerts.

4
Explicit lock states
2
Platforms (iOS · Android)
<3s
Uplink-to-app target
SCROLL
Client
Domain
Mobile / IoT
Platform
Flutter
Duration
Core Stack
Flutter · Firebase · MQTT · TTN
The Brief

THE
PROBLEM

IoT smart lock management with Flutter (Momentum): users onboard locks via QR or BLE WiFi configuration. Firebase Auth and Firestore model users, rooms, devices, history, and notifications. Uplinks flow LoRaWAN → The Things Network → MQTT → Cloud Functions that parse payloads and update Firestore with FCM on state changes.

mqttFunction subscribes to eu1.cloud.thethings.network, maps decoded payloads to device docs and history subcollections; sendDeviceStateChangeNotification triggers FCM with human-readable state text; Momentum presenters keep the Flutter UI reactive to Firestore streams.

Core Engineering Challenge

A reliable MQTT→Firestore bridge under TTN broker churn; a four-state lock model (Not Set; Unlocked/Closed; Locked/Closed; Unlocked/Open); real-time UI consistency with battery and history; and duplicate-safe notification delivery.

Live
Pipeline
Extended stack
mobile
Flutter
backend
Firebase
backend
MQTT
locksure1
locksure1
How we built it

THE ARCHITECTURE

01
Device onboarding

QR scan for device IDs and BLE-driven WiFi provisioning with flutter_blue.

FlutterBLEqr_code_scanner
02
TTN MQTT ingest

Cloud Function connects to TTN broker, subscribes to uplink topics, parses lockState, batVolts, lockCount.

MQTTTTNCloud Functions
03
Firestore model

Devices, rooms, history subcollections, and notification feeds with real-time listeners in the app.

FirestoreFlutter
04
FCM on state change

Secondary function on writes pushes notifications with state summaries to subscribed devices.

FCMFirebase
05
Operational UX

Battery voltage, history timelines, and multi-device room grouping for facility managers.

MomentumFlutter
System Data Flow
Ingestion
CrawlerContent Hash10K+ pages
Processing
ChunkerDeduplicatorEmbedding API
Storage
pgvectorPostgreSQLRedis Cache
Auth
Identity ProviderJWT BridgeSessions
Query
HNSW SearchRe-rankerLLM Stream
Delivery
Web AppMobile AppUsers
What we delivered

THE RESULTS

Live

End-to-end path from physical device through LoRaWAN, TTN MQTT, Cloud Functions, and Firestore into the Flutter app with push alerts — validated so field teams could see lock transitions within seconds of uplink.

Live
Pipeline

End-to-end path from physical device through LoRaWAN, TTN MQTT, Cloud Functions, and Firestore into the Flutter app with push alerts — validated so field teams could see lock transitions within seconds of uplink.

Visual documentation

SCREENS &
INTERFACES

locksure2
locksure2
locksure3
locksure3
Engineering decisions

TECH
DEEP DIVE

TTN
TTN + MQTT Cloud Function

Server-side subscriber avoids keeping MQTT credentials on mobile and centralizes parsing.

Four explicit states simplified UX and support playbooks versus ambiguous raw integers.

FCM
Firestore-triggered FCM

Decouples push from the ingest path so retries and fan-out stay in Firebase’s delivery layer.

Momentum kept presenter logic testable as the IoT schema grew.

Next Case Study
AI / RAG
mypromo.be

AI pamphlet deals — Belgium

FastAPIFlutterFirebase
Start a project

LET'S
BUILD
SOMETHING.

We take on a small number of projects at a time. If the problem is hard, we're interested.

Email
hello@techmusketeers.com
Response time
Within 24 hours
Availability
Open for new projects · 2025