We recently completed a major architectural overhaul of the Terminal Tracker App. The objective was clear: automate heavy document ingestion, eliminate single points of failure during critical operational windows, and ensure tight, role-based interface isolation.
While production cluster topography and endpoints remain strictly confidential, we can lift the hood on the actual engineering, image manipulation pipelines, and sync mechanisms driving this update.
1. Document Ingestion Pipeline: OCR & Signature Capture
To optimize driver turnaround times at the gate, we engineered a native scanning module to capture and process physical driver-signed gate releases digitally.

- Dual-Input Ingestion Engine: The UI framework handles both real-time camera capture (optimized via mobile device webview constraints) and asynchronous bulk file uploads for batch back-office processing.
- Regex-Driven Extraction: Once an image is buffered, it hits our OCR translation engine. The system evaluates the parsed text string using specific regular expressions (regex) to isolate, extract, and validate unique load numbers dynamically.
- Percentage-Based Canvas Cropping: To isolate authorization and proof-of-delivery without manual intervention, the backend crops the signature block out of the original image document using relative, percentage-based coordinate mapping. This signature snippet is extracted, isolated, and bound directly to the database record as a permanent audit asset.

2. Infrastructure Resilience: Dual-Mode Replication & DB Heartbeats
Because field tracking and vessel movements run continuously, dropping a session or losing data during an active gate operation is unacceptable.

- Active-Passive Topology: We shifted the app deployment into a high-availability, dual-mode cluster. A primary active node accepts and processes inbound payloads, while a secondary replica mirrors the application state in hot-standby.
- Database Heartbeats: To handle failovers reliably, we engineered a constant synchronization heartbeat that updates the database layer at strict intervals. If the primary node misses a heartbeat window or drops connection, the cluster initiates an automated failover to the standby node, mitigating session dropouts or transaction corruption.
3. Client-Side Decoupling: Runtime RBAC Tab Display
Security and interface cleanliness go hand-in-hand. To limit exposure of backend features and reduce cognitive clutter for field teams, we decoupled the main navigation from static layouts.
tabs_to_show = [t("tab_dash"), t("tab_gate")]
if is_office_or_dev:
tabs_to_show.append(t("tab_vessel"))
tabs_to_show.append("🖨️ Gate Releases")
tabs_to_show.extend([t("tab_history"), t("tab_audit"), t("tab_team")])
if is_admin:
tabs_to_show.append(t("tab_sync"))
all_tabs = st.tabs(tabs_to_show)
tab_dash = all_tabs[0]
tab1 = all_tabs[1]
idx = 2
if is_office_or_dev:
tab2 = all_tabs[idx]
tab6 = all_tabs[idx+1]
idx += 2
else:
tab2 = None
tab6 = None
tab3 = all_tabs[idx]
tab4 = all_tabs[idx+1]
tab_team = all_tabs[idx+2]
idx += 3
if is_admin:
tab5 = all_tabs[idx]
idx += 1
else:
tab5 = None
# --- TAB 0: DASHBOARD ---
with tab_dash:
render_live_dashboard()
- Token-Driven Hydration: Upon authentication, the client-side router reads the user’s secure token payloads and session scopes at runtime.
- Conditional Tab Rendering: The app dynamically injects or strips tabs depending entirely on the logged-in user profile. Office staff and verification administrators are dynamically provisioned with the new scanning and OCR tabs, while field operatives receive a lean, high-performance execution dashboard entirely stripped of administrative configuration panels.


4. Operational Alignment: The Integrated Team Message Board
To replace noisy, out-of-band communication systems like radios or separate chat channels, we embedded an operational hub directly into the application layout.

- Context-Aware Communication: The new Team Message Board serves as a persistent, centralized ledger for shift handovers, gate delays, and system alerts.
- Unified State Logging: Because message payloads are committed straight alongside tracking operations, the application maintains a fully unified chronological timeline, linking communication directly to active logistics state.
Technical Summary & Next Sprints
By implementing runtime UI-level RBAC, automated computer vision document parsing, and an HA cluster reinforced with transactional database heartbeats, the Terminal Tracker has fully matured into an enterprise-ready hub.
The next development phase will focus on shrinking the OCR processing latency profile and refining local asset storage limits.
