ai-assisted-todolist

Domain model#

Ubiquitous language#

Term Meaning
Task A single thing its owner means to get done. With its attachments, the only thing this application stores on anyone's behalf. At most 500 per user; the next is refused, a draft added too (#607).
Owner The user a task belongs to. Every task has exactly one, and it never changes.
User Someone who owns tasks, identified by the verified email claim in their OIDC token.
State Whether a task is open (TODO) or done (DONE). WORKING, "in progress", is no longer offered (#334): the tasks that had it became open, and it stays in the API only until #345, because apps installed before then can still send it. The API accepts it and stores it as TODO, so no task is in progress again.
Importance How much a task matters to its owner: LOW, MEDIUM or HIGH.
Due date The day a task is meant to be finished. Always set, once the task is no draft. It keeps that meaning when the task also has a due time.
Due time The time of day, to the minute, a task is due at on its due date (#474). Optional: a task without one is all day, as every task was before. A time already past today is allowed.
Time zone The IANA zone a due time is meant in, such as Europe/Berlin (#474). Optional, and only with a due time. A due time without one is floating: it follows whoever's clock reads it, like "take the pills at 08:00", wherever the owner is. A due time with one is zoned: one moment, like a meeting at 10:00 in Berlin, which is 04:00 in New York.
Due at The moment a zoned task is due at. Worked out on every read and never stored; an all-day or a floating task has none. A time that falls in a daylight-saving gap moves later, and one that falls in an overlap is its earlier moment, as ZonedDateTime.of, RFC 5545 and Temporal all resolve it.
Draft A task the app's add form attaches files to before Add, so they upload while the form is filled in (#381). A task with a draft marker, not a state: it has made no progress, and has no description or due date yet. Nowhere a task is seen -- not on the board, not to an update or delete -- until it is added; discarded with its files on Cancel, gone with them once abandoned for an hour. At most five are open per user; a sixth is refused (#434).
Board A user's tasks, as they see them: ordered by due date, and within a day by importance, high first.
Attachment A file or a link on a task. A file is a PDF or an image, its content in object storage and its name, type and size here; a link (#414) is its address and title here, and nothing in storage.
Link An attachment that is a web address, titled by its page where the app that shared it gave the title. Available as soon as it is added: there is nothing to upload.
Pending An attachment announced but not yet confirmed: its upload link is handed out, the file may or may not have arrived. Never listed.
Available An attachment the board lists and opens: a file once it has arrived as announced, a link as soon as it is added.
Thumbnail A small JPEG of an image attachment, made by the browser when the image is uploaded; what the board shows on the row. Part of its attachment, not a thing of its own.
Detached An attachment whose task was deleted, kept for the undo window in case the deletion is undone.
Account deletion A user deleting their own account: every task, every attachment and the user go at once, with no undo.
Device One installation of the TaskFest app on a phone, which gets its user's push notifications (#277): its platform (IOS or ANDROID), its push token at Apple's or Google's push service, and the language its notifications are written in (de or en). Registered by the app once signed in, and lasts as long as the app session that registered it: signing out, the session's end after 30 days, or deleting the account ends it.
Installation id The UUID an app generates once, when it is installed, and keeps: what names its device. Installed again, it is a new device.
Push A notification of a change to a task on its owner's devices but the one that made it (#277): added, changed, done, reopened or deleted, with the task's description, in each device's language. A later push for the same task replaces one still showing.
Deletion record What an account deletion leaves behind: a hash of the email and the time, kept outside the table, in the attachment bucket, so a restored backup cannot bring the account back.

Note the deliberate absence of "todo" as a noun. The code says task throughout, and the REST resource is /api/tasks. An earlier iteration used /api/todos; the rename is complete in the code and any remaining "todo" in prose means the product, not the entity.

Aggregates#

Task is the aggregate root. It holds a reference to its owner but nothing else refers to it, and it is always loaded, changed and deleted as a whole. There is no partial update endpoint: a change sends the whole task back. The one exception is the due time: an update that leaves out both dueTime and timeZone keeps the task's, so an app that knows neither cannot erase them (#497); null clears them.

User is a separate aggregate, and a thin one. It exists to give tasks something to belong to and to give the application a stable identity for the email arriving in a token. It is not an item but a partition: every item of a user is keyed USER#<SHA-256 of the email> (store.OwnerKey), the email lower-cased (#622) -- or, for an account begun before that under an email with capitals, the email as sent (Accounts.AccountEmail) -- and a task names no owner because its key already does. The user's own state is the partition's META item: the counts that hand out task and attachment ids, the open drafts and the versions that keep their limits, when the account began and whether it is being deleted (serverless.md).

Attachment is its own aggregate, not part of Task's, although it is meaningless without one. Two things force that. A file's content lives in S3, which cannot join a database transaction, so uploading is three steps -- announce, PUT straight to S3, confirm -- that each change the attachment and never the task. And it outlives its task for the undo window: deleting a task detaches its attachments (taskId removed, detachedAt set), and the undo, which re-creates the task, names them in attachmentIds to attach them again. What stays detached past the window, and an upload never confirmed, is gone to every read at its expiresAt, deleted by DynamoDB's TTL, and its file by the table's stream (serverless.md).

Device is its own small aggregate (#277), an item in the user's partition, DEVICE#<installation id>, that no task refers to. It belongs to the app session that registered it as much as to its user: the session names its one device, and the device its session, so the session's end is the device's. Registering the same installation id from a new session, after signing in again on the same phone, moves the device to it, beyond the reach of the old session's end; from a session of another account, it moves the device to that account. An installation is one device, of one account at a time (serverless.md).

Invariants, and where each is enforced#

Paths are under serverless/internal/: the domain's rules are in board, and a device's in device, which hold no AWS package, the requests in api, and the items and their conditions in store.

Invariant Enforced by
A task always has an owner Every task is an item in its owner's partition (store.OwnerKey), which comes from the verified token (api.Caller), never from the request
A task's description is present and at most 255 characters board.Check, blank as Java's String.isBlank says and counted in UTF-16 code units (board/rules.go), and maxLength in the published contract, which the frontend enforces on every response. A draft has none yet
A draft is never seen as a task A draft is a DRAFT#<id> item and a task a TASK#<id> one: the board reads only TASK# items (Store.Tasks), a replace or a delete is conditional on the TASK# item, and only the drafts' and attachments' routes reach a DRAFT# one (store/drafts.go)
A user has at most five open drafts (#434) board.MaxOpenDrafts (board/drafts.go), held by Writes.StartDraft, which counts the open drafts on META and writes the new one in a transaction conditional on the count's version; a sixth is a 422
A new task's due date is today or later, in someone's zone: no earlier than today in UTC-12 (#425) board.TodaySomewhere, checked for a create and for adding a draft only (readNew in api/tasks.go)
A time zone comes only with a due time (#474) board.Check; an update that leaves out both keeps the stored ones, and one that leaves out only the time reads it as none (#497)
A time zone is one the backend knows by its IANA name, never an offset: neither a bare one like +02:00 nor one by name like Etc/GMT-2 or EST, UTC and GMT excepted board.KnownZone: a name in the tzdata the binary embeds (zones.gen.go), exactly as written, and at most 64 characters. A stored zone the running binary does not know gives the task no dueAt rather than failing the board (board.DueAt)
A due time is to the minute board.Check, which takes only HH:mm, 00:00 to 23:59, the same pattern as the published contract; it is read only as text (optional in api/tasks.go) and stored as that text
State and importance are always set board.Check refuses a missing or unknown one; WORKING is stored as TODO (board.Open)
A user's email is present and unique verifyIDToken (auth/tokens.go) refuses a token without one; the partition is the SHA-256 of the email with A to Z lower-cased (identity.Canonical, identity.EmailHash), so one address is one user whatever case a provider sends it in; an account begun before that, under an email with capitals, keeps the partition of the email as sent (Accounts.AccountEmail, #622 (opens in a new tab))
A user's name and picture are not domain state Nothing stores them with the tasks; the website's session item keeps them for the session's life (authentication.md)
A user sees and changes only their own tasks Every read and write is keyed on the caller's partition, and a replace or delete is conditional on the item being there
An attachment is a PDF, JPEG, PNG, WebP or GIF file, or a link (#414) board.Kind; a file's declared type is read by board.KindOf on announce, and any other is refused by board.Admit
A link has a web address and no object; a file has an object and no address board.WebAddress, with the contract's pattern, for a link's address; Writes.Attach gives an object key to a file alone (store/attachments.go)
An attachment is at most 10 MB, at most 2 per task, at most 5 per user board.Admit (board/attachments.go), counting pending, detached and drafts' ones too, from the items read strongly consistent under a version on META; the size and type are also signed into the upload link, so S3 refuses any other, and confirming checks the file that arrived
A user can delete only their own account DELETE /api/account (api.DeleteApiAccount) acts on the caller and takes no id
A deleted account stays deleted after a restore replay (cmd/replay), run daily and once against a restored table before the API is switched to it, deletes again any account a deletion record names that began before the deletion (Accounts.Reapply)
A device belongs to a user and to one app session that lasts, and a session has one device at most (#277) Only an app session registers one (PUT /api/devices/{installationId}, auth.Service.AppSessionKey), never an ID token or the website's session; Devices.Register writes it into the partition the session names, in one transaction conditional on the session lasting, which deletes the session's earlier device (store/devices.go)
An installation is one device, of one account and one session at a time (#277) The installation's index, INSTALLATION#<installation id>, names the partition and the session that have it; Devices.Register sets it on the condition that it is as read, and deletes the device it named in another account in the same transaction (store/devices.go)
A device ends with its session Sessions.DeleteSession deletes the session item, then the session's device and its index, unless a newer session has registered it since; a device is pushed to only while its session item exists and has not ended (Devices.Registrations), so one a failed sign-out left behind gets no push; its expiresAt is the session's, so TTL takes both; deleting the account deletes it with the partition, but keeps the device of a session signed in since, as it keeps the session (followsSessionSince in store/accounts.go)
A push never goes to the device that made the change, nor to one whose token its push service no longer knows (#277) The API names the app session that made it (auth.CallersAppSessionKey), and the push function leaves out that session's device (push.Pusher); a token APNs or FCM calls gone deletes the device while it still has that token (Devices.Forget in store/devices.go)
An installation id is a UUID in lower case, a platform IOS or ANDROID, a language de or en, and a push token 1 to 4096 letters, digits, :, _ or - device.Check (device/device.go), with the same patterns and enums as the published contract
A user sees and opens only their own attachments Every lookup reads the attachment in the caller's partition and checks it is on the task or draft named (store/attachments.go), and a download link is only signed for one found so

The due-date rule once read "a task's due date is today or later", and the Quarkus backend enforced it on the stored task as well as the request. It was wrong, and quietly so: a stored task became invalid the day after it came due, and because the update endpoint replaces the whole task, every overdue task turned un-editable — including the state change that marks it done. The rule a board actually wants is "do not file something in the past", which is a create-time rule. See decisions/domain-and-backend.md.

The ownership one is worth dwelling on. Ownership is part of the key, not a check performed after loading. A task belonging to someone else is therefore indistinguishable from one that does not exist — both yield 404 — which leaks nothing about other users' data.

Rules that deliberately do not exist#

Persistence#

Tasks, drafts, attachments' records, devices, each user's META item and the sessions are items in the Go backend's one DynamoDB table; the keys and access patterns are in serverless.md, and an attachment's file is the S3 object its record names. Until #559 they were PostgreSQL tables, which the tag pre-serverless keeps.