Katlendar Developer manual GitHub

Data model

What Katlendar keeps, in which file, and which fields go to a server.

Everything lives in src/model/. The app keeps all of it in memory and writes it whole on every change.

Two files#

FileHoldsWritten by
data.jsonevents, tasks, calendars, task lists, frames, accounts, the outboxData::save
config.jsonsettings (Prefs)Data::save, beside it

Older copies kept the settings inside data.json. The prefs field there is still read so those files load, then settings move to config.json.

Neither file ever holds a password, a token or a private link. Those go to the keyring (see Secrets). A calendar whose link is private has url_secret set, and data.json holds keyring: (SECRET_URL) in place of the link.

Data#

FieldWhat it is
eventsevery event, from every calendar
tasksevery task, from every list
calendarsone's own calendars, subscribed feeds and synced calendars
liststask lists; list 0 is the Inbox
framesframes: time set aside for kinds of tasks
accountssynced accounts
outboxevents deleted here that a server still has (PendingDelete)
next_idthe last id handed out by Data::new_id

Ids are u64 and never reused. Events and frames point at a calendar by its id, and tasks at a list by its id.

Calendars and accounts#

A calendar is one of three kinds:

  • own: no url and no account.
  • subscribed: it has a url. Its events are read-only and are read whole each time.
  • synced: it has an account. remote_id is its address on the server, and sync_state and ctag let a pull ask only for what changed.

A frame always sits in a calendar of one's own, never in a subscribed one.

An Account names its kind with one flag: google, microsoft, nextcloud, proton or todoist. With none set it is a plain CalDAV account. client_id holds an ID the person brought for Google or Microsoft.

Fields that stay here#

Some fields are never sent to a server. Keep it that way, or the server copy of someone's calendar fills with things only Katlendar understands.

TypeKept here only
Eventskipped, side_notes, buffer, series
Taskcolor, due_order

raw holds the event or task as the server sent it. Writing back starts from it, so fields Katlendar doesn't know are not lost. dirty marks a change the server hasn't seen yet.

Worked out, never saved#

  • Buffers (buffer.rs): free minutes before and after events. Worked out from the events whenever they are needed.
  • Block colours (colors.rs): from a task's tags, its list or its calendar, in the order the person chose.
  • Plans (plan.rs): the simple planner that finds free time and fits tasks into it.

Other model files#

FileWhat it holds
repeat.rsrepeat patterns, the custom rule and how a repeat ends
quick.rsthe little language of the quick task field
tags.rstags, gathered from tasks, frames and the planner; renamed or merged everywhere at once
place.rsplaces, map providers and where a place opens
sample.rswhat a first start shows, and what screenshots and tests use
tests.rsthe model's tests

Changing the format#

data.json from any older copy must still load. When you rename or reshape a field:

  • give new fields #[serde(default)];
  • move old data in a migration such as Data::migrate or Data::migrate_places;
  • add a test in src/model/tests.rs that loads the old shape.

Improve this page on GitHub