Recipe

Score little league games from your phone

For league organisers and volunteer scorekeepers: give each game to one parent by email, and only that parent can score it, from their phone at the field.

Apps
Topics

Your little league plays every Saturday, and a different parent keeps score at each game. The scores end up on paper, in group chats and in somebody’s memory. In this recipe you have the agent build a scorebook: a database of the games, an API that holds the rules, and a scoring page that works on a phone. You give each game to one scorekeeper by their email address, and only that person can score it.

What you need

  • XataWorks, open, with the agent answering. If it is not yet, Getting started covers the one decision to make first.
  • The desktop view. This recipe is shown on it: a dock along the bottom, the chat in its own window, and each program in a window beside it. Choose View ▸ Desktop View and then Restart Now. The same menu item switches back.
  • XataWorks Pro, for connecting the database to the API and for sharing the scorebook. Your scorekeepers need only a XataWorks account to sign in with.
  • The season’s schedule, in a spreadsheet or just typed into the chat, and each scorekeeper’s email address.

How the pieces fit

  • The database keeps the games: the date, the field, the two teams, the score, and the email of the parent scoring it.
  • The API is the only way in. Its endpoints run on your computer, and each request tells them the email of the person signed in. XataWorks fills that in, so nobody can pretend to be somebody else. The API lets a scorekeeper change a game only when it is theirs.
  • The creation is the page the scorekeeper sees on their phone: their games, and a big scoreboard with a button per team.

The scorekeepers never get the database itself. They get the creation, and the creation can only ask the API.

1. Ask for it in one sentence

In the Chat window, say what you want, the way you would say it to a person:

Make an app called Scorebook for our little league’s Saturday games at Riverside Park and Elm Street Field, starting Saturday 7 November, with the games in a database called Little_League. Each parent sees and keeps score of only their own game, from their phone, with a big + Run button for each team. I add the games and see every one. Grandparents can follow every game but not change anything.

XataWorks has a skill for this kind of app — several people, the same records, and rules that differ per person — and the agent follows it. Before it builds anything, it sends you a plan: what each game holds, which field says whose game it is, and who can see and change what. Whatever your sentence leaves open, it asks about, three questions at most. Read the plan: it is the app’s rules, in plain words. Answer its questions, or, when its guesses suit you, just say so:

That’s right. Go ahead and build it.

The XataWorks desktop. On the left, the Chat window: the agent’s plan, “Scorebook — how it works”. The records: one Games table in a new database, Little_League — Date, Field (Riverside Park or Elm Street Field), Time, Team A, Team B, Runs A, Runs B, and a Scorer field holding the email of the parent who keeps score for that game. You, the owner: add games, see every one, change anything. Parents, at Can use: from their phone they see only their own game, with a big + Run button for each team. Grandparents, at Can view: follow every game’s score, change nothing. Its default: one scorer per game. Samples: a few made-up games for two example parents, so it can prove every rule before anyone is invited. Then three questions before it builds — whether Saturday 7 November means 2026, how many games each Saturday, and whether you have the team names — and “Action needed: answer the three questions above.” On the right, an empty Browser window. Along the bottom, the dock.
A real turn, asked with the sentence above, in the desktop view, signed in to a XataWorks Pro account. The plan names the owner field: the email that says whose game it is. Captured on Linux; your window’s frame and fonts may differ.

Planning comes first for any new creation, not just this one: a second skill has the agent settle who it is for and whether one of XataWorks’ templates already does most of it. You can see both skills, and turn them off, in File ▸ Preferences… ▸ Skills.

2. The agent builds the database, the API and the page

Making the database and the API each ask you first. The agent fills the database with sample games for two made-up parents, so that it can later try the rules on somebody else’s game. Then it writes the API: every endpoint checks who is calling. You can do anything; a parent sees and scores only the games with their email on them; a grandparent can only read. It writes the scoring page too, which talks only to the API. Then it opens the API’s page in the Creations window and stops: only you can connect the database to the API. If the page isn’t in front, ask:

Open the Scorebook API’s page so I can connect it.

The API’s page lists its endpoints and the logic behind each one. You don’t edit the logic there. To change it, ask the agent: “what happens if someone scores a game that’s already Final?” Later you will find the same page under View ▸ Creations ▸ Open Creations, then APIs and Scorebook.

The desktop. In the Chat window, the agent’s summary — the Scorebook page on a phone-sized layout, with an Add a game form for the organizer, Edit and Remove on every game and + Run on both teams; a parent sees only their own game with a big + Run button; a grandparent sees every game with no buttons — then “Waiting on you”: press Connections… and connect Little_League with Can change, after which it will prove every rule, check the page and give you the steps to share it. Then the request “Open the Scorebook API’s page so I can connect it.” and the agent’s reply that the API’s page is open in the Creations window. On the right, the Creations window on its APIs tab, showing the Scorebook API — “Little League games: the organizer adds and sees every game; each scorer parent keeps score of only their own; viewers follow read-only.” — with Lock, Run, Design, Versions… and Connections…, and six endpoints: GET /games, POST /games (organizer only), GET /games/:id, PATCH /games/:id, DELETE /games/:id (organizer only) and GET /me. Beside them, GET /games’s logic, and the shared code: loadGame reads the records with aaf.database('Little_League').records('Games'); canRead lets the owner and viewers read every game and anyone else only the games whose scorer is their email; canChange lets the owner change anything and a person at Can use only their own game.
The Scorebook API from the same chat, open in Creations. The shared code decides who may change a game from request.caller, which XataWorks fills in.

3. Connect the database to the API

Only you can do this. On the API’s page in the Creations window, press Connections…. Pick Database, Little_League and Can change, and press Connect. Before you do, the dialog warns you: “Whoever uses this API — including people you share a creation with — gets what you allow here, even if they can’t open the data themselves.” That is the point here, and it is why the API’s rule matters. Then tell the agent:

I’ve connected Little_League to the API.

The same desktop with the dialog “Data “Scorebook” can use” over the Scorebook API’s page. Its list reads “Little_League — database — can change” with a Remove button. Below, the warning “Whoever uses this API — including people you share a creation with — gets what you allow here, even if they can’t open the data themselves. Connect only what this API needs.”, then Database, a list, Can change and Connect, and Done.
Connected: Little_League, can change. In this capture the clicks were the owner’s, played by a script — no agent can press Connect.

4. The agent proves the rules

The agent asks to let the page call the API. That asks you every time, even later in the same chat. To do it yourself, press APIs… on the creation’s bar, pick Scorebook and press Allow.

Then it tries the rules itself: as you, as a parent on their own game, as the same parent on somebody else’s game, and as a grandparent. Each try asks you first, so it tells you how many are coming; allow them for this chat. A try that changes a score is put back afterwards. It checks that the page shows the same games the API gave you, and finishes with the steps that are yours: web access, sharing, and the parents’ real emails. Then have a look at the page yourself:

Open the Scorebook page so I can see it.

The desktop. In the Chat window, the agent: “Scorebook is built, tested, and ready for you to share.” All rules proven — parents only see and score their own games, grandparents are read-only, you manage everything; the tests caught and it fixed two API bugs along the way; the database holds the 4 sample games for 7 and 14 November, all scores back to 0–0. Action needed: turn on web access in File ▸ Preferences… ▸ Web access; Share… the Scorebook page, Can use for scorer parents and Can view for grandparents; set each game’s Scorer to the real parent’s email. Then the request “Open the Scorebook page so I can see it.” On the right, a window titled Creations — Scorebook with the creation’s bar (Run, Design, Undo last change, Versions…, Share…, Databases…, APIs…) and the Scorebook page in the organizer’s view: “You see and manage every game. Add new games below.”, an Add a game form with Date, Time, Field, Team A, Team B and Scorer’s email, and the first game — Sat, Nov 7, 09:00 at Elm Street Field, Parkview Pirates 0 and Elm Street Orioles 0, each with a green + Run button and a −, and Edit and Remove.
The scoring page from the same chat, and the agent’s report: each rule it tried, and what is left for you. At your desk you are the owner, so the page lists every game.

When the page does what you want, press Run on its bar so no chat changes it by accident.

5. Keep it on your dock

In the list in Creations, choose ⋯ on Scorebook and then Install App. XataWorks says so: “Scorebook is installed. Find it in Apps, or keep it in the dock.” Press Keep in Dock to have it there every day. The scorebook is now an app of its own, also listed under My Creations when you press Apps on the dock. It opens in its own window, without the creation bar; to share it or change its APIs, right-click it and choose Edit in Creations.

6. Give each game to its scorekeeper

A game belongs to whoever’s email is in its Scorer field. Type it into the game in the Databases window, or ask:

Give the Riverside Park game on 7 November to sam@example.com.

Change the email and the game moves from one parent’s phone to another’s the next time their page loads.

7. Share the scorebook with the parents

The parents reach your computer through web access, so turn it on first: choose File ▸ Preferences…, open Web access, tick Turn on web access and give the computer a name the parents will recognise, like Coach’s laptop. Leave it off and Share… still saves, but says “Saved. No email was sent, because web access is off.”, and there is nothing for the parents to open.

Press Share… on the creation’s bar. In Share “Scorebook”, type each scorekeeper’s email, choose Can use and press Add. Leave Notify people by email ticked and press Save. Add anyone who only follows the scores, a coach or a grandparent, at Can view. Their page can only read, so every button that changes a score is refused for them.

At the field, the scorekeeper opens the link from the email in their phone’s browser and signs in to their XataWorks account. They see the scorebook on its own, not your desktop, and only their own games. Each tap on + Run goes through the API on your computer, which checks their email against the game before it changes a thing.

A phone’s browser, signed in to XataWorks as the scorekeeper, showing Scorebook on its own, marked Scorekeeper: “You are keeping score for the game below. Only you can see it.” One card — Sat, Nov 7 · 09:00, Riverside Park — Riverside Rockets 0 and Elm Street Eagles 0, each with a large green + Run button and a smaller −. The other games are not there. The same phone after one tap on + Run beside Riverside Rockets: Riverside Rockets 1, Elm Street Eagles 0.
The scorekeeper’s phone, from the same run: only the game whose Scorer is them, one of the four, and the score after one tap on + Run. The scorekeeper here is a second XataWorks demo account, signed in to the web app at a phone’s size; the desktop stayed on, with web access on.

The run lands in Little_League on your computer as it is tapped. Ask the agent how a game stands, or open it on your own Scorebook:

The desktop. In the Chat window, the request giving game 1 to the scorekeeper’s address and the agent’s confirmation — game 1, Sat 7 Nov at Riverside Park, Riverside Rockets vs Elm Street Eagles, now has that Scorer, everything else unchanged at 0–0 — then “What’s the score in game 1 right now? Read it from Little_League.” and the answer, read from the database: Riverside Rockets 1 – 0 Elm Street Eagles; it is up from 0–0, so someone pressed + Run for Riverside. On the right, the Creations window at its list of creations, with Scorebook in it.
Back at the desk, a moment later: the run the scorekeeper tapped is already in the database. The phone never reached Little_League itself, only the Scorebook API.

The email you share to is the email the API sees, and the one in each game’s Scorer field. Share to the address the parent signs in with: signed in with another account, they can’t open the scorebook at all.

8. Keep it reachable on Saturday

The scorebook runs from the computer that holds it: the creation, the API and the database are all there. That computer has to be on with XataWorks running while the games are played, so a desktop that sleeps through Saturday morning won’t do. An always-on computer at home — a Raspberry Pi, a Synology NAS or an old laptop — covers keeping what you share reachable.

Where this recipe stops

  • The rule is the API’s. XataWorks tells each endpoint who is calling; the API’s own logic decides what they may do. Read the endpoints, and have the agent try them as a scorekeeper and as someone else, before you share.
  • Check the page yourself. An agent’s summary can say all is well while the page shows an error or nothing at all. Look at the page, and have the agent try the API with it, before you share it.
  • Don’t hand out the database. Keep Little_League off the creation’s Databases… and don’t share it with the parents. Either would let them change any game directly, around the API’s rule.
  • Endpoints are boxed in. An endpoint’s logic cannot reach the internet or your files, only the data you connected, and it is stopped after 10 seconds.
  • The desktop view is new and still experimental. Everything here except step 5 also works in the classic window, where Creations is View ▸ Creations ▸ All Creations.

Read more

More recipes like this

Back to all recipes.