Building a collaborative internal tool isn't just about sharing a database. It's about sub-100ms synchronization across thousands of global users. Here's how we built the Apotza real-time engine.
The WebSocket Mesh
Simple WebSocket servers don't scale vertically. We implemented a distributed Pub/Sub architecture using Redis and specialized edge workers. This ensures that an edit in London is visible in San Francisco in less time than it takes to blink.
Handling Conflict Resolution
When two people edit the same automation node simultaneously, who wins? We use Operational Transformation (OT) combined with Last-Write-Wins (LWW) for less critical metadata, ensuring a seamless "Google Docs" style experience for tool building.
// Our internal sync hook logic
const useSync = (nodeId) => {
const [state, setState] = useState(null);
useEffect(() => {
const socket = connect(nodeId);
socket.on('diff', applyPatch);
return () => socket.close();
}, [nodeId]);
}
Result? A platform that feels local even when it's massively distributed.


