I like to keep up to date with technology, especially the kind I don't get to do much of in my day-to-day, which is front-end development. Creating yet another TODO app did not quite tickle my fancy, so I was on the lookout for a new side project.
I turned to my girlfriend and asked her "Hey, are there any boring tasks at work, which with a little help from an app could make your life easier?" She almost immediately replied: "Yeah, I have to come up with a weekly schedule for our team and patients. It's a time-consuming process because there are quite some rules to be kept into account." And just like, the idea for an app was born!
The first and most crucial part of the app was coming up with an algorithm to generate timetables while keeping the following rules in mind:
A session can only be planned when both parties are available.
There are 2 sessions per day for each patient, one in the morning and one in the afternoon.
A therapist should not see the same patient twice a day.
A therapist may also have a special session, this should occur max once a day.
The preferences below also had to be kept in mind:
When a therapist has a dedicated patient, they must see them once a day.
When a therapist has an excluded patient, they must not see them at all.
Scheduling problems are not uncommon, so I picked up my copy of Grokking Algorithms by Aditya Y. Bhargava. I knew there was a chapter on scheduling problems in there and re-read it, which proved to be of great help.
I decided to go for a hybrid algorithm, the generation of a single possible solution would be done in a heuristic manner, based on the rules and preferences. This process would then be repeated 100 times. Each possible solution would then be rated through a fitness function, a common thing in Genetic Algorithms. Ultimately, the highest-scoring solution will be displayed in the app.
I had my mind set on building the algorithm in TypeScript and ended up using it in combination with the Ramda library for array manipulation.
The second part of the app was building the necessary components, to collect input for the algorithm. I needed 3 main components for receiving input:
A patient preferences component
A therapist preferences component
A timetable visualizer component
I meddled with svelte kit when it was still in beta, but I was keen on trying it out now that it's released officially. For styling, I like tailwindcss, but wanted to go for a UI framework. I coincidentally found out about skeleton and wanted to give it a shot.
I had forgotten how smooth and easy svelte kit is and would recommend it for back-end developers with some interest in front-end development.
Skeleton is also a UI framework I thoroughly enjoyed. It has quite a bit of useful svelte components as well as a pretty logical list of pre-defined classes to make everything look consistent. I did have some struggles with figuring out the theme generator and ended up doing some manual tweaking of values and overriding some basic styles.
Overall, I'm quite happy with the result, feel free to check it out on GitHub: https://github.com/brecht-vde/timetabler.
My girlfriend now spends about 10 minutes making the weekly schedules, instead of roughly an hour before, so it's quite a time-saver!
I got to explore new technologies and build something with at least a little bit of purpose.
The moral of the story is simple: if you don't have inspiration for an app, ask your partner, friends or family for things that would make their life easier by using technology. You'll find out there is always a problem that needs solving and if you're lucky it might even be a problem many people need a solution for.