# Scaling a Regional Bike-Sharing Network

## From City Program to Regional Platform

A regional bike-sharing network rarely grows by simply adding more docks. When three neighboring municipalities combined their programs, the platform had to support 1,800 stations, multiple fare policies, and commuters crossing jurisdictional boundaries without ending or restarting a trip. The new architecture separated physical infrastructure management from pricing, allowing each municipality to retain local rules while sharing accounts, bicycles, and operational data.

## Station and Bicycle Telemetry

Each dock and e-bike publishes battery level, lock state, and location data through an MQTT gateway. Messages are assigned a device timestamp and an ingestion timestamp because cellular connectivity can delay delivery. The stream processor rejects impossible location jumps, preserves late events for auditing, and updates a low-latency availability index used by rider applications.

```yaml
telemetry:
  topic: stations/+/status
  stale_after: 90s
  retention_days: 30
```

## Consistent Trip Processing

Trip creation is handled as an idempotent workflow. Unlock requests receive a unique operation key, preventing retries from opening multiple rentals when a mobile client loses connectivity. The trip service records the fare zone at departure and arrival, while a rules engine calculates charges after the bicycle is returned. This keeps billing changes independent from firmware deployed to stations.

## Rebalancing Across Municipal Boundaries

Demand forecasting uses historical rentals, weather, transit disruptions, and scheduled events to estimate bicycle shortages in 15-minute intervals. Operators receive suggested truck routes, but regional constraints matter: one municipality may restrict overnight loading while another prioritizes accessible docking space. Recommendations are therefore optimized centrally and filtered through local operating policies before dispatch.

## Reliability and Public Reporting

The network targets 99.95% availability for unlocking and returning bicycles, with offline stations able to validate recently issued credentials from a local cache. Metrics distinguish application failures from empty stations, full docks, and disabled bicycles so reliability reports reflect the rider’s actual experience. Aggregated trip data is published for planners only after identifiers are removed and low-volume routes are suppressed to reduce privacy risk.