Architecture notes

Timoneo's custom recurrence engine, the task dependency graph and its cycle check, the asymmetric Google Calendar sync, and boot-time schema loading.

Updated Oct 16, 2026·4 min read
Live

Timoneo's core domain logic has no external dependencies. That's a deliberate constraint, and four components carry most of the engineering weight because of it.

1. The custom recurrence engine

Rather than pulling in a heavy iCalendar parsing library, Timoneo implements a subset of the RFC 5545 recurrence rule specification directly in Go. It resolves recurring schedules into concrete calendar occurrences.

Four properties of the evaluator are worth knowing.

Normalization. Date boundary operations are forced to UTC midnight before anything else happens. Without that, daylight savings transitions shift multi-day occurrences by an hour and the drift compounds.

Boundaries. An occurrence sequence ends either at a count limit or at an until timestamp. There is no third way to terminate one.

Infinity prevention. A bad configuration, such as an interval of zero evaluated against a far future query, would otherwise lock up the CPU. The expansion loop bounds itself at 10,000 steps.

Monthly clamping. A rule that recurs on the 31st has to do something sensible in February. Monthly occurrences clamp to the maximum valid day of the target month, and a day value of -1 means the final day of whatever month it lands in.

EVERY 31STa monthly rule31January28February31March30Aprilthe highlighted months have no 31st, so the rule lands on their last dayFebruary is 29 in a leap year
A rule that recurs on the 31st, across four months.

2. The task dependency graph

Tasks inside a project are modelled as a directed acyclic graph. Two invariants keep that graph valid.

No cycles. When a dependency edge is proposed, meaning task A blocks task B, a recursive cycle check runs in the database before the write commits. If B already blocks A anywhere down the chain, the request is rejected with a 409.

TASK AblocksTASK BblocksTASK Cproposed: C blocks AA already blocks C down the chain, so the request is rejected with a 409
The cycle check. The dashed edge is the one being proposed.

Blockage is visible. A task with uncompleted dependencies is flagged as blocked. The UI reads that flag to render a padlock and to lock editing.

The cycle detection runs inside PostgreSQL rather than in application code, using a recursive common table expression.

WITH RECURSIVE chain AS (
    SELECT depends_on_task_id AS id
    FROM task_dependencies
    WHERE task_id = $1

    UNION

    SELECT td.depends_on_task_id
    FROM task_dependencies td
    JOIN chain c ON td.task_id = c.id
)
SELECT EXISTS (SELECT 1 FROM chain WHERE id = $2)

Doing it this way means the check and the write happen against the same snapshot. Pulling the graph into Go and walking it there would open a window where another request could insert the edge that creates the cycle.

3. Asymmetric Google Calendar sync

Synchronizing two databases in both directions invites race conditions and conflict loops. Timoneo sidesteps that by making the sync deliberately asymmetric.

Pull is read-only. Google Calendar events are imported into Timoneo's interface when you query. They are never mutated locally, so your primary work calendar stays the source of truth for external events.

Push translates. Calendar events created inside Timoneo are pushed out to Google, and their local recurrence structures map to standard recurrence rule strings on the way.

TIMONEOGOOGLE CALENDARpull: Google's events are imported, and never changed herepush: events created in Timoneo, with their recurrence rules
The sync is asymmetric: read-only in one direction, write in the other.

Auth state is smuggled through the state parameter. During the OAuth handshake, Google's callback can't carry a custom authorization header. So Timoneo signs a short lived JSON Web Token containing the local user ID, puts it in the state parameter, and verifies it on the callback. The token is signed with the system's own secret, so a forged state can't authenticate anybody.

Tokens rotate on their own. The sync client watches access token expiry, refreshes expired tokens through Google's endpoint, and persists the updated credentials back to PostgreSQL.

4. Boot-time database initialization

Timoneo doesn't use an external migration tool. It keeps an additive only schema definition and applies it on boot.

The schema is compiled into the binary with Go's embed directive.

//go:embed schema.sql
var schemaSQL string

func initDB() *pgxpool.Pool {
    // ...
    if _, err := pool.Exec(context.Background(), schemaSQL); err != nil {
        log.Fatalf("schema migration failed: %v", err)
    }
    // ...
}

Every table is created with IF NOT EXISTS and every column is added with ADD COLUMN IF NOT EXISTS. So whenever the container boots or is updated, the schema is applied natively, with no version locks and no migrations that can fall out of sync.

The trade-off is worth naming. Additive only means there is no supported way to drop or rename a column through this mechanism. Anything destructive is a deliberate manual operation, which for a single tenant application is the right side of that trade.

5. Authenticated encryption at rest for API credentials

The settings table holds users' personal third-party credentials, such as their Gemini API keys. A leaked database dump must never expose these in plain text.

Timoneo encrypts sensitive credentials using AES-256-GCM, which provides confidentiality alongside cryptographic tamper detection:

  • Key derivation: A 32-byte key is derived from a server secret with a domain-separated SHA-256 hash, so the cipher key never coincides with the key that signs login tokens.
  • Prefix versioning: Each sealed value carries a version prefix and its own nonce, so the scheme can change later without downtime.