Checking how many agents are working

How this works
Contact
← Blog
One large dark machine in the middle of a bench with five small interchangeable cartridges laid in a row beside it, one olive cartridge slotted in, the AMARBARO mark small and centered above the machine.
✎article de blog

One booking app for many trades: how niche packs work

The short version

One tested booking app can serve many trades if everything that differs between them is data in a small file and nothing that differs is code.

What this is about

A dog groomer, a window cleaner and a computer repair shop all need roughly the same thing: a way for customers to ask for a time, and a calendar that does not double-book. But each trade uses different words. A groomer has "dogs" and "services". A repair shop has "devices" and "tickets".

We built one booking app. Instead of making a copy for each trade, we describe each trade in a small data file. We call that file a niche pack. The app reads the pack and changes its words, prices and pages. The code stays the same.

Why it matters

If you copy an app for each trade, you now have many apps. A bug you fix in one is still in the others. Each copy drifts away from the rest.

With one app and many small files, a fix lands once and every trade gets it. Adding a new trade becomes a matter of writing a file, not forking a program. That is the whole reason we do it this way.

How it works

The pack is just data

A pack is a file in a plain format called TOML. It is a list of names and values. Our README says a pack "supplies the trade's vocabulary": what a booking is for, the currency, the locale and time zone, which pages exist and what they are called, the starting service menu, and the first-run text.

Here are three shipped examples, from the README.

  • cleaning: currency RON, language Romanian, time zone Europe/Bucharest.
  • grooming: currency CHF, language German, time zone Europe/Zurich.
  • knullfix: the repair shop, currency EUR, language German, time zone Europe/Berlin.

The folder also holds a base pack that every other pack builds on, a tattoo pack, and a tiny pack used only by the tests.

Layers: weakest first

The app combines three layers. From weakest to strongest they are:

  1. The base pack.
  2. The chosen trade's pack.
  3. Settings from the environment, which are set when the app starts.

A pack names only what is different. Everything else falls through to the layer below. So a deployment can change one price or one word without copying the whole file. You pick a trade by setting one variable, NICHE, before the app starts.

A page with no address does not exist

A pack lists which pages the site offers. If a page has no address in the list, the app does not just hide the link. The route is never created, so the page cannot be reached at all. Nothing links to it either. That keeps a trade from showing a page that makes no sense for it, such as a voucher shop for a repair workshop.

Packs hold data, never code

This is the rule that keeps the whole idea safe. Our notes say: "Packs hold data, never code. Behaviour that varies by trade belongs in the core behind a flag the pack sets."

The reason is testing. If each trade could change the program, each trade would need its own tests. With a flag, the behavior lives in the one tested app, and the pack only switches it on.

An example: repair tickets

A repair shop needs something a groomer does not: a numbered ticket that moves through stages, from received to ready for pickup, with a written estimate in between. We added that to the app once. A flag in the pack, repair.tickets, turns it on. When it is off, the ticket pages are not even registered.

The repair pack also holds its own words and numbers. Its device label is "Gerät", meaning device. It lists four device types: PC, notebook, smartphone and tablet. It holds the table that turns a device and a symptom into a price range. Our notes put it at 4 device types and 11 symptoms, so 44 rows, built from the pack.

The shared page templates run under every trade. So any part that belongs to one trade is wrapped in a check, for instance "only if tickets are enabled". Without that check, a trade with no tickets would show a form that posts to a page that does not exist. We learned that one the plain way.

No price lives in a template. Public prices come from the services list. The price picker comes from its own table. Each ticket line carries its own price. All three are edited in the admin screen. The prices in a pack are marked as placeholders to be replaced.

What a pack does not do

A pack cannot invent a feature. If a trade needs something the app cannot do, that is a change to the app, tested for all trades. We would rather add a flag once than let one trade break the tests of another.

A pack also needs a restart, not a reload. The app caches one trade per process, so a change of trade means restarting it.

How a new trade is added

Our README gives the recipe in three lines.

  1. Copy an existing pack.
  2. Change what differs: words, currency, language, pages, starting services.
  3. Run the seed script for the new name to load the starting service menu.

Then start the app with NICHE set to the new name.

Words you may not know

  • Niche: a narrow kind of business, such as dog grooming.
  • Pack: a small data file describing one niche.
  • TOML: a simple file format made of names and values.
  • Locale: the language and format rules for a place.
  • Time zone: the clock offset of a place, which decides what "9:00" means.
  • Route: a web address the app answers.
  • Flag: a switch that turns a behavior on or off.
  • Seed: to fill a new database with starting data.

Try it

  1. See one pack in action: knullfix.de is the repair pack, in German.
  2. Open the request page to see the repair flag at work.
  3. For the other end of the idea, see our directory of sites: trendytails.ch is a dog groomer's booking site, where clients book their own slot and the calendar refuses a double booking.

The booking app has no public repository that we can link, so we describe it here instead of sending you to the code.

Before this: Booking a computer repair online, step by step. For another case where we kept one tested core and varied the rest, read Three Android apps in one build, and the release files matched before and after.

Commentaires

Pas encore de commentaires.

Se connecter pour commenter.