- Published on
Court Reserve
- Authors
- Name
- Zafar Bhayat
Problem
In Center City, Philadelphia, there is one public place to play tennis/pickleball. 200,000 people. One facility.
A glaring misallocation of resources - something many older metros are struggling with due to the rise of pickleball. Last year, it was not uncommon to wait for three hours for a court. During that wait, you could watch a steady stream of people arrive, scan the area to see how many were ahead in line, and then, with disappointment, turn back, knowing that there was no chance of getting a spot before the lights turned off.
The park recognized this issue and decided to implement a new system this spring. A $100 donation to the park would give access to the CourtReserve platform, where a user could book courts in advance. This seemed like a great solution, so I eagerly made my donation on the very first day. A few days later, I got my confirmation email and logged into the platform, excited to finally avoid the long waits.
It was not long before I realized the system was less than ideal. Court reservations opened 3 days in advance at 6 a.m., a time I don't typically find myself awake at. By the time I did wake up, all the prime slots were already gone.
No big deal, I will just wake up earlier. So I did- only to find out that even if I was awake there was a high likelihood I still couldn't get my preferred time due to how much competition there was with people trying to do the same.
Solution
With a background in designing and implementing workflow automations, I quickly realized what needed to be done. I built a process using Python for the scripting, Telegram for the UI and input collection, and SQLAlchemy as the database. I stored my credentials, programmatically generated a list of possible date and time slots to display as dropdowns in Telegram, and logged the responses in SQLAlchemy. I then set up a timer to trigger the script to run exactly at 6 a.m.
The debugging process was long and frustrating because I couldn’t fully test the program in real-time while developing. The only way to verify its effectiveness was by waiting until 6 a.m. each day, when new court slots became available. This was the only high-fidelity test to ensure the program was working as expected and could outpace the other human users. It meant waiting several hours after deploying new code to see if the changes I made were effective. After several days of this process, I finally had the program dialed in. It was faster than any human (sub 2 seconds), sending requests directly to the server. Now I could sleep in and still guarantee a prime-time court slot whenever I wanted!
I’ve often found myself caught in the trap of spending hours automating tasks just to save a few minutes here and there. More often than not, I don’t see the time savings I hoped for, and I can’t help but question if the effort was really worth it. But in the end, what usually keeps going is knowing that I am learning something new or practicing my skills for other applications.
This project has turned out to be one of the most useful and practical automation I've built. I made sure the solution was scalable and capable of handing multiple users, though I am still keeping it under wraps bar my one friend for now. If I start sharing it with others, I would only be creating competition for myself- and more importantly potentially exposing my methods, which could stir up some unwanted drama.
Since project completion, I have occasionally opened up the codebase to make some incremental changes and improvements. I recently added an error-handling protocol: if the reservations fails for any reason, the script will automatically attempt to reserve the next court for the same time slot, ensuring that a fallback mechanism is always in place.
For now, I am content with the satisfaction of hearing people's comments on how I always manage to snag a prime time court slot, without fail.
Setting up a task in the Telegram interface
Technology and Build
The tech stack I used for this project was chosen for practicality and efficiency. Python is the ideal language for my own scripting due to its flexibility, and extensive libraries. SQLAlchemy made managing database interactions simple, storing everything from login credentials to user response in a structured, scalable way.
For the user interface I chose Telegram as I had never used it before and wanted to expand my technology horizons. I had known about libraries like 'python-telegram-bot' and figured it would be a straightforward platform that would allow me to scale to multiple users and give real time responses. Most of all it allowed for me to learn a new library and skillset.
The most important feature I added was the error-handling protocol. Given the competitiveness of court bookings, I implemented a system that would retry the reservation process automatically if a request failed—ensuring a backup plan for when things didn't go as expected. This addition made the system more robust and reliable.
With the system in place, I was able to sleep in and still secure my ideal time slots, demonstrating how automation, when applied thoughtfully, can provide practical, everyday solutions to persistent problems.