Pastecard C
In 2018, I finished a couple of major Pastecard projects that all started with S. This summer has been brought to you by the letter C.
Since its beginning, Pastecard has been a PHP script that takes text from a box on a web page and saves it to a text file on a server. I tried a couple times to convert it to a true web app with one central database and each time gave up in frustration. The biggest technical leap forward was when I stopped creating a duplicate copy of the entire web app for each new user, each running in its own directory in the server filesystem, and replaced that with one copy of the PHP script that combed through a directory of text files.
The server was initially an account with a shared web host, then the free tier of a basic Linux box at Google Cloud. Always a partition of a computer in a rack of servers somewhere. But it all still worked. It even supported an iPhone app that worked with the same directory of text files, though I did have to write special PHP scripts to enable that.
But now, miraculously, the little web app that could is finally a real web app. It’s a monolithic Javascript code base with standardized API methods and a real database, hosted on a global network used by Fortune 500 companies. Pastecard now runs on Cloudflare, using their Workers product for its compute and their KV product for data storage, still completely free. The web app (which should look and feel exactly the same as it did before) uses the same code to read and write data as the iPhone app and the admin interface, as will any future (Mac? Watch? Smart glasses?) app.
I had a lot of help with this. I gave in to the dark side and vibe-coded the new infrastructure with Claude, the AI chatbot that Apple has been rumored to be considering acquiring to turn into the new Siri. Initially I was simply curious to see what, if anything, made it different from ChatGPT. And the first impression was that it was a more organic, artisanal robot. With a hand-drawn asterisk as its avatar that squiggled around while it was thinking, warm earth tones, and a brand font not too far removed from the Chobani yogurt family. Then on a whim I asked it (in one long single prompt up front, a tip it gave me to stay within the free account limits) how it would write the entire Pastecard web app, with a description of all the functions I had previously written myself, as a Cloudflare Worker using KV. And it more or less nailed all the public-facing functions in its first reply.
My justification to myself, after the fact, is that this is how I’ve worked on code projects that were above my experience level anyway, just sped up. The usual routine is to try something until it doesn’t work, then Google the error message or a crude phrasing of what I’m trying to accomplish, browse the linked Stack Overflow results, and copy code from there. An AI bot is pretty much doing the same thing, down to copying (stealing) the work of someone else, and condensing it all into one step in the same interface as text messages. Of course there are still serious concerns about the environmental impact and obviating jobs off prior efforts of real people, and I don’t know how to justify that.
Claude wasn’t perfect or complete, to be fair. It invented a new visual design from scratch that I threw away and reverted to what was already there. It assumed that users would want to see all the metadata around their account (when was it created, what device(s) they’re using, etc.) because I wanted to make sure that was all saved to the database. It gave me the ground work for an admin area but I had to write the UI around it and most of the user experience or flow. It attempted to handle all of the non-app stuff (for example, the help page) within the Javascript for the app. I am still very much a guy who knows how to make web pages more than web apps and am comfortable in that realm, so I learned the routing logic to deal with functions and app stuff first, then serve static files second. That way, the web pages and style sheets get to stay separate, like I’ve always known them.
And that’s not all! As Steve Jobs would say, there was one more thing. Claude can connect to your Github account, where I had the full source code for the Pastecard iPhone app, so I figured I would hook it up and ask it if there were ways to make it more efficient. I didn’t want or need to change or add anything, just address things I had heard of but never understood, like “memory leaks.” And just like with the first Pastecard web app, where each user had their own copy of the code, Claude figured out that each feature of the iPhone app had its own copy of the functional code, so it centralized all the logic into a Swift package that each view could reference. It also cleaned up the networking logic and introduced me to the concept of “debouncing,” where consecutive retries slow down to avoid hammering the server. Only, for one of the debounce actions, it kept comparing the “time since last trying” to “now.” When I finally figured that out and mentioned it to Claude in a follow-up chat, it apologized and fixed the error.
So now I have a web app, iPhone app, and web infrastructure that all feel much more solid and quick. The cost to get there was zero, and the monthly costs are still zero as well. (The only thing I pay for is renewing the domain registration every year.) I do want to acknowledge that in the process of cleaning out old stuff, I deleted a bunch of inactive user accounts. The new admin interface made it easy to see at a glance when someone created an account, edited their text once or twice, and never returned to the website. I took extensive backups before switching over, and Claude built me a nice bulk import feature, so they can always be restored if requested. But I doubt they will because, as always, this is something I do mostly for myself, which is why it’s the most satisfying to take big leaps like these and have them work out.