"Vibe-coded" PHP + SQLite relational DB for a bike mechanic?!

bikegremlinbikegremlin ModeratorOG

Introduction

When I was a kid, my parents took the family (one and only :) ) car to a mechanic (Sava was the name) who kept a track of all work he had previously done on the car. Also, he would inspect everything and stay on top - doing real preventive maintenance.

A decade later, when I bought my first car, I realized that such service does not exist anymore.

When I started fixing bikes for people, it only made sense to do what the late Sava used to do: keep a track of all the work previously done, stay on top of any wear and problems, and have a record so I don't have to do the same work twice.
I see my work as community service, so wasting time can not be compensated by any amount of money - money is just a, for now, innevitable consequence of doing what is right.

The build

Even though my day-job is more systems-administrator/tech-support centred, I did enjoy the Databases subjects/exams in university, and that stuck with me (though quite rusty I must admit). This bit is important, put a pin here as the modern managers would say.

I knew from the start that I'd need a computer in the workshop: for playing MP3 and Youtube music (no jewels like this on Spotify!), and too kep a track of all the bikes (customers are impotant only in terms of identifying bicycles - another pin here).

Starting small, not sure how it would fare (every day could be my last, I ride fast - this rhymes!), I used Excel. However, I was smart and far-sighted enough to make unique ID fields for each:

  • bicycle ID - a number counter (because there are no universal unique number plate as it exist for cars and motorcycles).
  • customer ID - phone number.
  • service ID - a number counter.

A bit later, I made a separate Excel table for wheel builds - with no unique ID for each wheel, but fortunately I kept the customer info there too and built my wheels so well that I never got to re-build the same wheel twice (patting myself on the shoulder now).

For GDPR fangirls: I let every customer know that I will write down and keep track of their name and their phone, to keep the service history tabs. Fewer than a handful over the past decade had any objections, and for those that did, I had a placeholder customer and a placeholder bicycle.

That made it possible to convert to a CSV and import in a relational database when I find the time.

Unlike me, my best man Gox is a true programmer. However, he's quite crazy too, doing a bunch of community service stuff, so it really made no sense to bother him for a still hobby project that may lift off if I get greedy (to employ more people, pay them minimum wage and skim profits) or live long enough to retire from my day-job. So that option was off the table for me, until further ado. Simply couldn't justify to myself the time and effort needed - it is as simple as that, not a lack of will on Gox's part.

Then I saw the great, smart use of "AI" by people I respect in the IT line of work. AI is great at doing the legwork, for the stuff that's been beaten to death. My use case (in terms of databases, not the quality or way of work) is as plain as it gets.

I used paid Google Gemini to get this done:

  • Convert my Excel tables into CSV for database import.
  • Make tables with foreign & unique keys (and searches) as I defined.
  • Configure safeguards from making nonsense entries and relations (if I missed an edge case, I will find out though use :) ).

As a man falling from a 10-storey building would say: so far so good.

Tech stack

I wanted an SQLite database so that it is tiny and can be run from my workshop stove easily, with trivial copy/paste backups. What I went with:

  • Stack: Plain server-rendered PHP 8 (PDO) + SQLite 3 + plain HTML/CSS - 'cause frameworks are for the weak - also no Composer, JS/SPA caching or Docker.
  • Database: One .sqlite file with 4 relational tables (Customers, Bicycles, Services, Wheelbuilds), strict foreign keys/unique constraints, and triggers protecting the C-000/B-000 placeholders (see the two cyberpunk references in screenshots below).
  • Portability & backups: About a dozen small PHP files plus one database file - can run on any basic shared hosting or locally on a workshop PC, with built-in CSV, SQL, and raw .sqlite export.
  • Security (thinking aloud): Locked behind Cloudflare Zero Trust (or Tailscale) plus a simple PHP login/cookie gate, added after cPanel Directory Privacy (.htpasswd) proved buggy on iOS Safari.

TL/DR: With Tailscale or Cloudflare Zero trust, combined with a PHP-implemented password, this could run even online - at least for my personal use, I feel confident enough.

Jennifer Lawrence Thumbs Up GIF

Screenshots

Here are some early screenshots of this work-in-progress:

  1. Info for a given customer:

A single customer view

  1. Info for a given bicycle (of the same customer in this screenshot) - with the info after the latest service visble on top commenting the bike's general condition:

Info for a given bicycle

A digression - video I made about the brake overhaul on this particular bike:

  1. A wheel build note (the same customer and the same bike too):

Info about a wheel build

  1. Now, cyberpunk genre fans may get a laugh from this, but this is my placeholder customer for the bikes and wheel builds that are not related to any real person willing to have their phone and (nick)name stored for eternity (or simply unassigned for other reasons):

A customer placeholder

  1. Another placeholder - for a bicycle in this case - this one may remind some folks of William Gibson's Virtual Light (my Amazon affiliate link - 'cause yachts won't pay for themselves!).

A wheel placeholder

That sums it up.
Stay cool - finishing this with another neighbourhood band jewel from Youtube music:

Relja

Sign In or Register to comment.