AdvancedLesson 12 of 129 min read

Capstone: The Food Bank App, Built from a Specification and Tested

Assemble the whole app from one specification: tables, a sign-up form with rules, automations, views and permissions, interpreted by a small engine, then run a scenario of twenty events and verify every result against an independent recount.

In this lesson you will

  • Describe an app as data
  • Run a scenario through tables, form rules, automations and permissions
  • Check invariants such as capacity and alerts
  • Verify the result independently

About 28 minutes

The whole app in one page of data

The capstone shows that a no-code app really is data interpreted by an engine. The specification below lists everything Tomás’s app needs: four tables, a sign-up form with its rules, two automations, two views and the permissions of two roles. A small interpreter, about eighty lines of Python, creates the database from the tables, validates every sign-up against the form rules and the stored data, fires the automations when records change, and answers views through the permissions. A real platform does the same with a much larger engine and a friendly editor, and writing the small one makes each setting of a platform concrete.

The scenario then plays twenty events: sign-ups, some of which are wrong on purpose, stock counts that move up and down, and requests for views by a volunteer and by the coordinator. The checks come from outside the interpreter: an independent recount of what the scenario should have produced, using plain lists, and invariants that must hold whatever happens, such as a shift never holding more people than its capacity, and an alert being sent only when a stock count crosses its threshold. A specification that passes both is a specification you can hand over.

{
 "tables": {
  "volunteers": "id INTEGER PRIMARY KEY, name TEXT, role TEXT",
  "shifts": "id INTEGER PRIMARY KEY, day TEXT, place TEXT, capacity INTEGER CHECK (capacity > 0)",
  "signups": "volunteer_id INTEGER, shift_id INTEGER, PRIMARY KEY (volunteer_id, shift_id)",
  "stock": "item TEXT PRIMARY KEY, qty INTEGER, threshold INTEGER"
 },
 "form": {
  "name": "signup",
  "rules": [
   "volunteer must exist",
   "shift must exist",
   "not already signed up",
   "shift must have a free place"
  ]
 },
 "automations": [
  {
   "name": "low stock",
   "on": "stock update",
   "when": "qty crosses below threshold",
   "do": "alert coordinator"
  },
  {
   "name": "shift full",
   "on": "signup created",
   "when": "signups == capacity",
   "do": "mark shift full"
  }
 ],
 "views": {
  "open shifts": "shifts with signups < capacity",
  "my signups": "signups of the current user (coordinator: all)"
 },
 "permissions": {
  "volunteer": [
   "read open shifts",
   "read own signups",
   "create own signup"
  ],
  "coordinator": [
   "read all",
   "update stock"
  ]
 }
}
import sqlite3, json
db = sqlite3.connect(":memory:")
SPEC_TABLES = {'volunteers': 'id INTEGER PRIMARY KEY, name TEXT, role TEXT', 'shifts': 'id INTEGER PRIMARY KEY, day TEXT, place TEXT, capacity INTEGER CHECK (capacity > 0)', 'signups': 'volunteer_id INTEGER, shift_id INTEGER, PRIMARY KEY (volunteer_id, shift_id)', 'stock': 'item TEXT PRIMARY KEY, qty INTEGER, threshold INTEGER'}
for name, cols in SPEC_TABLES.items(): db.execute("CREATE TABLE %s (%s)" % (name, cols))
db.executemany("INSERT INTO volunteers VALUES (?,?,?)", [(1, "Tomas", "coordinator"), (2, "Ana", "volunteer"), (3, "Ben", "volunteer"), (4, "Chi", "volunteer")])
db.executemany("INSERT INTO shifts VALUES (?,?,?,?)", [(1, "sat", "Hall A", 2), (2, "sun", "Hall B", 1), (3, "mon", "Hall A", 3)])
db.executemany("INSERT INTO stock VALUES (?,?,?)", [("rice", 30, 10), ("beans", 12, 10)])
outbox, full = [], set()
def signup(user, volunteer, shift):
    if user != 1 and user != volunteer: return "refused: you may only sign yourself up"                      # permission
    if not db.execute("SELECT 1 FROM volunteers WHERE id = ?", (volunteer,)).fetchone(): return "invalid: no such volunteer"
    cap = db.execute("SELECT capacity FROM shifts WHERE id = ?", (shift,)).fetchone()
    if not cap: return "invalid: no such shift"
    if db.execute("SELECT 1 FROM signups WHERE volunteer_id = ? AND shift_id = ?", (volunteer, shift)).fetchone(): return "invalid: already signed up"
    n = db.execute("SELECT COUNT(*) FROM signups WHERE shift_id = ?", (shift,)).fetchone()[0]
    if n >= cap[0]: return "invalid: shift is full"
    db.execute("INSERT INTO signups VALUES (?,?)", (volunteer, shift))
    if n + 1 == cap[0]: full.add(shift); outbox.append(("shift full", shift))                           # automation: shift full
    return "ok"
def update_stock(user, item, qty):
    if user != 1: return "refused: only the coordinator updates stock"
    old, thr = db.execute("SELECT qty, threshold FROM stock WHERE item = ?", (item,)).fetchone()
    db.execute("UPDATE stock SET qty = ? WHERE item = ?", (qty, item))
    if old >= thr and qty < thr: outbox.append(("low stock", item, qty))                                # automation: edge-triggered
    return "ok"
def open_shifts():
    return [r[0] for r in db.execute("SELECT s.id FROM shifts s WHERE (SELECT COUNT(*) FROM signups g WHERE g.shift_id = s.id) < s.capacity ORDER BY s.id")]
def my_signups(user):
    q = "SELECT volunteer_id, shift_id FROM signups ORDER BY volunteer_id, shift_id" if user == 1 else "SELECT volunteer_id, shift_id FROM signups WHERE volunteer_id = %d ORDER BY shift_id" % user
    return db.execute(q).fetchall()
steps = [("signup", 2, 2, 1), ("signup", 3, 3, 1), ("signup", 4, 4, 1), ("signup", 2, 2, 2), ("signup", 3, 3, 2), ("signup", 2, 3, 3), ("signup", 1, 9, 1), ("signup", 1, 2, 1), ("signup", 4, 4, 9), ("signup", 2, 2, 3),
         ("stock", 1, "rice", 25), ("stock", 1, "rice", 9), ("stock", 1, "rice", 8), ("stock", 2, "rice", 99), ("stock", 1, "beans", 11), ("stock", 1, "beans", 5), ("stock", 1, "rice", 40), ("stock", 1, "rice", 7),
         ("view", 3), ("view", 1)]
log = []
for st in steps:
    if st[0] == "signup": r = signup(*st[1:])
    elif st[0] == "stock": r = update_stock(*st[1:])
    elif st[1] == 1: r = {"open": open_shifts(), "signups": my_signups(1)}
    else: r = {"open": open_shifts(), "signups": my_signups(st[1])}
    log.append([list(st), r])
res = [x[1] for x in log]
print("20 events, results:"); [print(" ", i + 1, st, "->", r) for i, (st, r) in enumerate(log)]
print("alerts and notices in the outbox:", outbox)
print("invariant: no shift over capacity ->", all(n <= c for n, c in db.execute("SELECT (SELECT COUNT(*) FROM signups g WHERE g.shift_id = s.id), s.capacity FROM shifts s")))
print("DATA " + json.dumps({"log": log, "outbox": outbox, "ok": all(n <= c for n, c in db.execute("SELECT (SELECT COUNT(*) FROM signups g WHERE g.shift_id = s.id), s.capacity FROM shifts s"))}))
20 events, results:
  1 ['signup', 2, 2, 1] -> ok
  2 ['signup', 3, 3, 1] -> ok
  3 ['signup', 4, 4, 1] -> invalid: shift is full
  4 ['signup', 2, 2, 2] -> ok
  5 ['signup', 3, 3, 2] -> invalid: shift is full
  6 ['signup', 2, 3, 3] -> refused: you may only sign yourself up
  7 ['signup', 1, 9, 1] -> invalid: no such volunteer
  8 ['signup', 1, 2, 1] -> invalid: already signed up
  9 ['signup', 4, 4, 9] -> invalid: no such shift
  10 ['signup', 2, 2, 3] -> ok
  11 ['stock', 1, 'rice', 25] -> ok
  12 ['stock', 1, 'rice', 9] -> ok
  13 ['stock', 1, 'rice', 8] -> ok
  14 ['stock', 2, 'rice', 99] -> refused: only the coordinator updates stock
  15 ['stock', 1, 'beans', 11] -> ok
  16 ['stock', 1, 'beans', 5] -> ok
  17 ['stock', 1, 'rice', 40] -> ok
  18 ['stock', 1, 'rice', 7] -> ok
  19 ['view', 3] -> {'open': [3], 'signups': [(3, 1)]}
  20 ['view', 1] -> {'open': [3], 'signups': [(2, 1), (2, 2), (2, 3), (3, 1)]}
alerts and notices in the outbox: [('shift full', 1), ('shift full', 2), ('low stock', 'rice', 9), ('low stock', 'beans', 5), ('low stock', 'rice', 7)]
invariant: no shift over capacity -> True

The twenty events produced 11 accepted actions, 5 invalid requests and 2 refusals, plus two views. The first ten events are sign-ups, and the rules reject the wrong ones for reasons that the output names. Ana and Ben take the two places on the first shift, and Chi’s request for it is invalid because the shift is full. Ana takes the only place on the second shift, and Ben’s request is invalid for the same reason. The coordinator’s request to sign up a volunteer who does not exist is invalid, a repeat of Ana’s sign-up for the first shift is invalid as already signed up, and Chi’s request for a shift number 9 is invalid because it does not exist. One request is a permission case: Ana tries to sign Ben up for the third shift, and the engine refuses, because a volunteer may only sign herself up. Ana then signs herself up for the third shift, which is accepted. The shift-full automation fired when the first shift reached its capacity of 2, and again for the second, whose capacity is 1.

The stock events show the edge-triggered rule. The rice count went 30, 25, 9, 8, 99 (refused: only the coordinator may update stock), 40 and 7, and the beans went 12, 11 and 5. The outbox holds exactly the alerts that crossed the threshold of 10: shift full for 1, shift full for 2, low stock for rice at 9, low stock for beans at 5, low stock for rice at 7. Rice below 10 happened twice, since it was restocked to 40 between, and the update from 9 to 8 did not repeat the alert. The final events request the views. The volunteer Ben sees the open shifts and only his own signups, and the coordinator sees all signups, as the permissions in the specification state. The invariant that no shift ever holds more people than its capacity holds, as the last printed line confirms.

Independent check: the whole scenario was replayed by a second program that uses only Python lists and dictionaries, with no database and none of the interpreter’s code, and the result of every one of the twenty events, including the two views, is identical to the interpreter’s, as is the outbox. The invariant on capacity was also checked against the database itself after the run. If the interpreter had checked capacity after inserting instead of before, or alerted on every low reading, the replay would have disagreed at a specific step, and the step number tells you which rule is wrong.

Check by hand with the first shift, capacity 2: Ana is accepted (1 of 2), Ben is accepted (2 of 2) and the shift-full notice fires, and Chi is refused because it is full. For the second shift, capacity 1, Ana is accepted and the notice fires, and Ben is refused as full. Ana asks to add Ben on the third shift and is refused by permission, and Ana’s own signup for the third shift is accepted, which makes four accepted signups, 1 + 1 + 1 + 1, and the seven accepted stock updates complete the 11 accepted actions.

Where to go next

  • Choose a platform and rebuild this specification in it, table by table, rule by rule, and compare its behaviour with the scenario.
  • Learn the platform’s limits and pricing by building a small real app for a club or a small business.
  • Add the pieces that real apps need: backups, a test copy of the app, change notes, and a person responsible for it.
  • Move on to the Back-end and API integration courses when a no-code tool reaches its limits.
  • Keep the habit of this course: write the rule, run a scenario, and check the result in a second way.
A specification is not an app until it is tested

Run scenarios with wrong inputs and unlucky sequences, not only the happy path. Most failures in no-code apps are rules that nobody tried to break.

Keep a test scenario with your app

A list of twenty events with the expected results is a regression test. Replay it after every change to the tables, rules or permissions.

About this course

No-code platforms, plans and limits change often, so the lessons describe categories of tools with generic names and you must check each vendor’s current website. The ideas of this course, data tables, forms, views, automations and permissions, are what the tools implement, so the lesson reproduces them in small programs, run in Python 3.13 or Node.js 22 on sample data, with a second independent calculation. You have now completed the No-code apps course.

Practice

Add a waiting list: when a shift is full, record the person and fill the place when someone cancels. Add a cancel event and test it. Add the scenario steps that exercise your new rules, and the expected results.

Check what you learned

Five quick questions. Pick an answer and you will see straight away whether it is right and why.

What is an app specification?

  1. The app described as data that an engine interprets
  2. A drawing
  3. A password list
  4. A backup

Tables, forms, automations, views, permissions.

Why was the alert sent only twice for the rice?

  1. The rice ran out
  2. Alerts are limited to two
  3. The coordinator was away
  4. It is edge-triggered: only when crossing the threshold

9 to 8 did not repeat it.

Why was Ana’s request to sign Ben up refused?

  1. Ben did not exist
  2. The shift was full
  3. The form was wrong
  4. A volunteer may only sign herself up

A permission rule.

What does the independent replay prove?

  1. The app is fast
  2. The app is pretty
  3. The interpreter agrees with a separate evaluation of the rules
  4. The data is private

Step by step.

What invariant did the app keep?

  1. Every shift is full
  2. Stock never changes
  3. No shift holds more people than its capacity
  4. Every user is a coordinator

Checked against the database.

Summary

  • A no-code app is data that an engine interprets.
  • Rules live in forms, automations and permissions; test them with a scenario.
  • Check invariants and replay the scenario independently.
  • Keep the specification and the scenario with the app.

Next lesson

You have finished the No-code apps course.

Questions

Can I build this in a real no-code platform?

Yes. Most platforms offer tables, forms with validation, automations, views and permissions. The specification tells you what to build, and the scenario tells you how to test it.

What if the platform cannot express a rule?

Then use an integration, a script or a different tool for that part, and keep the rest. Check what your platform offers before you commit.

How do I hand the app to someone else?

Give them the specification, the test scenario, the list of accounts and permissions, and a note of who pays for the plan and when it renews.

Progress is saved in this browser.