For reasons outlined in yesterday's post, I had to switch poketto.me from #CloudSQL (MySQL) to a completely different database architecture: Firebase 🔥

At that stage, the Python backend code base wasn’t huge, but it was already fairly substantial. It included CRUD operations for several entities, as well as some basic lookup logic. Rewriting the whole thing would have taken me at least half a day.

Instead, I asked my good friend #Claude to take care of things. And, to my surprise, the result worked straight away! 🎁The “dorp in” replacement generated by the AI immediately passed my unit tests, and also the chatbot’s instructions for how to set up and configure #Firebase were actually useful.

However, there are a few caveats to bear in mind:

➡️We're talking about a comparatively small codebase here – the original Python file was maybe 500 lines long.

➡️I designed the architecture upfront with basic 'separation of concerns' in mind. Therefore, the database layer was neatly separated from any business logic. Therefore, all Claude had to do was understand the input and output requirements of a few Python functions and recreate their logic using a different database API.

➡️Automated tests matter; I wouldn’t blindly trust #AI-generated code here, but with a basic testing harness in place… What could possibly go wrong? 🤷

Summing up: What can we learn from this? #Refactoring, #rewriting and potentially upgrading legacy code bases could be an area in which AI excels! It could also save valuable human developers countless hours, allowing them to focus on more engaging work.