RunningSince 2023

Web · Mobile · Windows stations

Architecture, backend, web, mobile and station apps

Healthy Zone

The operating system of a pharmaceutical distributor: sales, invoicing, the warehouse floor and field reps, on web, mobile and station apps that share one backend.

  • Commits across web, server and mobile

  • Automated test cases

  • Backend modules

  • Screens in the reps' app

Healthy Zone home: the company's systems in one place

01/Problem

The company ran on an older pharmacy ERP on SQL Server plus a separate Express and React app for store operations. Every new need meant another screen bolted on, and the warehouse floor still worked from paper.

The goal: one platform for the whole company, built while the old systems keep running, moving one domain at a time without stopping a single day of sales.

02/Constraints

  • 01The legacy ERP stays the source of truth for stock and money until each domain moves.
  • 02Warehouse stations are shared Windows PCs on the local network, used with gloves and a scanner.
  • 03Reps work in the field on Android phones with weak coverage.
  • 04Amounts are hidden on screen by default; staff reveal them on purpose.

03/Architecture

People

  • Web · React 19
  • Reps · Expo / React Native
  • Stations · Tauri

Edge

  • Redis sessions
  • short-lived JWT
  • Socket.io

Core

  • NestJS on Bun
  • ~80 modules
  • jobs · reports

Data

  • MongoDB
  • legacy ERP · SQL Server
  • Redis
One NestJS backend serves the web app, the reps' app and the station apps. New domains keep their data in MongoDB; anything the legacy ERP still owns is read through its stored procedures.

04/Decisions

  1. Move domain by domain, from a written roadmap

    Store operations moved off the old Express app one slice at a time: invoice preparation first, then expiry by batch, recalls and zone statistics. Each slice ships behind the old one until it matches.

    Trade-off: Two systems run side by side for months, and every slice needs its own cut-over.

  2. Fail closed on legacy reads

    The old app returned an empty list when the ERP query failed, so a screen could look like there were no invoices. Every legacy read now throws instead, and the money math (opening balance sign, bonus split) moved into a pure helper tested against real cases.

  3. Stations are a thin shell, not a fork

    The routes, preparation and check stations are small Tauri apps that load the deployed web UI full screen. One codebase, one release, and a station updates the moment the web app does.

  4. Sessions you can actually revoke

    Login creates a Redis session plus a short-lived JWT. Logging out on a phone deletes its session server-side, so a lost phone or a departed employee loses access at once instead of keeping a 30-day refresh token.

  5. Packaging codes that cannot collide

    A review found bag codes were unique only per millisecond and customer, so generating several bags at once could duplicate them and let a checked invoice be emptied. Codes got a random suffix and the writes became atomic guards.

05/Screens

Delivery routes: loading each truck, sending it out, tracking every invoice to delivery
Delivery routes: loading each truck, sending it out, tracking every invoice to delivery
Invoice preparation, moved off the old app
Invoice preparation, moved off the old app
Monitoring: live requests, response time and database load
Monitoring: live requests, response time and database load

06/Stack

React 19TypeScriptViteTanStack QueryZustandNestJSBunMongoDBSQL ServerRedisSocket.ioExpo / React NativeTauri

Next systemHealthy Tax
Mohammed Yousef Ali | Systems Architect for real businesses