Daniel Sosinskiy
← Back to Engineering Stories Production systems / Conbo

Building a sector warnings system

Turning sector data and configurable rules into a view of traffic delays, lane occupancy, travel times, and vehicle counts at ports and warehouses.

At a glance

My role · I owned the backend implementation of the warnings and statistics service, from gathering data to calculating metrics and serving the results. I also worked on the admin-panel interfaces used to configure sector rules.

Context · Professional work, with company details generalized.

Context

The product represents a port or warehouse as a map of sectors, the lanes inside them, and traffic moving between them. An operator can select a sector to inspect its activity. The underlying platform collects camera, detection, and RFID data, but those inputs need business logic before they can describe what is happening on the site.

The Problem

There was not enough visibility into the state of a sector. Operators needed to know whether traffic was stuck, which lanes were available, how long vehicles took to travel to or from the sector, and roughly how many vehicles were there. The relevant information was spread across the system, and each sector had its own rules configured in an admin panel.

Technical Approach

  • Read the rules configured for each sector and gathered the associated inputs from five upstream APIs.
  • Calculated approximate vehicle counts, lane occupancy, and travel times to and from the sector, then evaluated the warning conditions defined by its rules.
  • Ran the calculations in a background loop, refreshing the maintained state approximately every 1-2 seconds.
  • Served that state through HTTP endpoints. Selecting a sector requested its latest calculated state rather than starting a new calculation; the frontend used HTTP polling for updates.

Generalized process

  1. Sector rules + source data
  2. Gather inputs
  3. Calculate metrics and warnings
  4. Refresh maintained state
  5. Return state on request
  6. Display selected sector

Engineering challenges

Fit data gathering into a short calculation cycle

A cycle could build up to about 100 requests, so fetching the inputs was a substantial part of the work. I improved database indexes and tuned request-pool settings to handle many requests concurrently. I also added caching, including Redis, so data that changed rarely did not have to be fetched repeatedly. The timing requirement applied to gathering the data and calculating the result together, not just to one endpoint.

Separate rules, calculations, and service plumbing

The service had to combine business rules with data retrieval and numerical calculations without mixing them into one flow. I spent time carefully structuring the code so the business logic, calculation routines, and technical coordination stayed separate. This was an implementation challenge in its own right: improving request throughput was only one part of making the service work correctly.

Decisions and Tradeoffs

Calculate in the background, serve on request

The calculation loop and the user request have different responsibilities. The loop produces the current sector state; selecting a sector retrieves it. That keeps the full aggregation cycle out of the click path, while the displayed state still reflects the background refresh cadence.

Cache the inputs that change rarely

Repeated cycles do not need to retrieve every input at the same frequency. Caching reduced repeated requests for slowly changing data, while request-pool tuning addressed the inputs that still needed to be gathered concurrently.

Background updates versus on-demand calculation

Calculating on demand would put data retrieval and business-rule evaluation in the operator request path. The implemented background loop instead returns maintained state, trading per-click calculation for a result refreshed at the loop cadence.

Outcome

Operators could inspect a sector on the map and see its calculated operational state: approximate vehicle counts, lane availability, travel times, and warnings about traffic conditions. The backend brought these results together, and the admin-panel interfaces supported configuration of the rules behind them.

Reflection

This work needed attention at two levels: how quickly data moved through the service, and how clearly the code represented the rules applied to it. Indexes, request pools, and caching addressed the first; careful separation of responsibilities addressed the second.

Technologies

  • TypeScript
  • NestJS
  • PostgreSQL
  • Redis
  • REST APIs

Links

No public repository or live demo is available for this professional work.

© 2026 Daniel SosinskiyIsrael