2024
Medical platform microservices
Patient records, shared settings and geospatial services for calls and ambulance movement. Realtime map updates via WebSocket/Centrifugo, with Kafka messaging between services.
Backend engineer
The challenge
New functionality required clear service boundaries and data exchange with the existing system.
What I built
- Implemented a geospatial service for call geotags/distribution and ambulance movement, with realtime updates via WebSocket and Centrifugo.
- Implemented a centralized settings service for the other services.
- Implemented a client data service for patient records.
- Built a Kafka module for the internal PHP framework, including producers, consumers and topics.
- Worked with PostgreSQL and integration with the existing application.
Results
- Implemented patient, configuration and geodata services, plus a shared Kafka integration module.
Components & connections
Legacy system
- PHP monolithExisting functionality migrated incrementally.
Event exchange
- Shared Kafka · moduleA shared internal PHP framework module for producers, consumers and topics.
- Kafka brokerAsynchronous messaging between the application and extracted services.
Domain services
- Geospatial · Calls · Ambulance movementCall geotags, call distribution on the map and ambulance movement.
- Shared · settingsCentralized settings for the other services.
- Patient · recordsClient data and patient records.
Data
- PostgreSQL · Service dataRelational storage for services.
Realtime map
- Centrifugo · WebSocketRealtime delivery of geospatial updates.
- Call map · Ambulance movementDisplay of call geotags and ambulance movement.
- PHP monolith↔Shared Kafka · moduleevents
- Shared Kafka · module↔Kafka brokerpublish/consume
- Kafka broker↔Geospatial · Calls · Ambulance movementevent exchange
- Geospatial · Calls · Ambulance movement↔PostgreSQL · Service datastorage
- Kafka broker↔Shared · settingsevent exchange
- Shared · settings↔PostgreSQL · Service datastorage
- Kafka broker↔Patient · recordsevent exchange
- Patient · records↔PostgreSQL · Service datastorage
- Shared · settings→Geospatial · Calls · Ambulance movementshared settings
- Shared · settings→Patient · recordsshared settings
- Geospatial · Calls · Ambulance movement→Centrifugo · WebSocketgeo updates
- Centrifugo · WebSocket→Call map · Ambulance movementWebSocket
Engineering takeaway
Context
An emergency medical software platform.
- The monolith and new services had to coexist.
- Sensitive data and consistent contracts between services.
Approach
Gradually extracted functional areas into services and connected them to shared messaging.
- Service boundaries based on the domain.
- A common Kafka module for consistent messaging.
Lessons
- System decomposition starts with responsibility boundaries and data contracts.
Stack
- PHP
- Kafka
- PostgreSQL
- Microservices
- Docker
- WebSocket
- Centrifugo