Prefer server side work even if more http calls

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the architecture category.

Last Updated: 2024-11-23

In Project S, I had an architecture whereby the client phone app called the /appointments endpoint and got a list of appointments. The idea was that the doctor would get all the appointments they need to handle for the next hour with one call. One of the main uses in the phone app was to give yes/no answers as to whether the patient in front of them was due at the exact time.

With time the /appointments endpoint needed a lot of join data. And the tables were getting bigger etc. This meant that the endpoint got steadily slower.

What we should have done instead is scan the appointment of each individual patient and then validate against the backend one by one. With that architecture, scaling would have been much easier.