tide

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: MIT

README

Tide

Tide is a markdown note-taking app, a bit like Obsidian: notes filed in folders, connected by their [[links]] and #tags.

A Go server on PostgreSQL serves the API and the web app. A CLI and an MCP server let scripts and agents use that API. The web app is meant to be opened from a phone or a tablet, for example through Tailscale.

Documentation

The wiki details the web app screen by screen, titles and tags, themes, data and the version history.

This README covers the server, the tide CLI, the API, the configuration and the backup. Besides it:

  • web/README.md: the web app, its shortcuts and its settings.
  • MCP.md: the MCP for agents, in French.

Features

  • Notes and folders: a rich markdown editor (with a source mode), folders in a tree, pinning, favorites and a trash.
  • Links: [[links]], backlinks, including a note in another (![[Note]]), a graph of the notes and the list of broken links.
  • Tags: #tags written in the text, with a page per tag.
  • Search: a ⌘K palette that searches titles and text, smart folders, and replacing a text in one note or in all of them.
  • History: the versions of each note, which you can compare, restore or copy into a new note, then merge back into the original.
  • Images and files: stored in Silo (S3-compatible).
  • Accounts: several accounts per server, by invitation, API tokens, and notes encrypted in the database.
  • Customization: themes, light or dark mode, snippets, an adjustable sidebar and three plans (Standard, Advanced, Ultra). The settings follow the account from one device to another.
  • Import and export: a zip of markdown files.

Installation and usage

Tide is developed with the latest version of Go. Locally, the stack runs in Docker thanks to compose.yaml.

git clone https://github.com/cyril-fl/tide.git
cd tide
cp .env.example .env                     # then fill in the passwords
make setup                               # installs the git hooks (lefthook)
make up                                  # Postgres, Silo and the API in Docker, the web app on :3000
echo '<password>' | docker exec -i note-api /tide-server user add <name> --password-stdin

The web app answers on http://localhost:3000 (open localhost, not 127.0.0.1), and its logs go to .build/web.log. To stop it, make down (Colima stays running).

Two binaries come out of this module:

  • tide, the CLI and the MCP server: a client of the API, with no access to Postgres or Silo, to install on the Mac;
  • tide-server, the only one that talks to the database: the API and the web app (serve) and the admin's commands. It runs in the Docker image (see Server).
go install github.com/cyril-fl/tide/cmd/tide@latest   # the latest version of main
tide login https://notes.example.ts.net

In the repo, the CLI on the API of make up:

go build -o "$(go env GOPATH)/bin/tide" ./cmd/tide
make connect TO=local    # tide login on the API of make api

tide-server creates the schema before each of its commands, and serve empties the trash at startup then every hour. The CLI never touches the database: a CLI of a different version than the server cannot create its schema there.

Requirements
Docker environment

compose.yaml defines the development services:

  • postgres (note-postgres): PostgreSQL 18, on 127.0.0.1:5432.
  • silo (note-silo): image storage, on 127.0.0.1:9000 (console on 9001).
  • api (note-api): tide-server serve, on http://localhost:8080, and its MCP over HTTP on http://localhost:8081/mcp (profile api, started by make up).
  • libredb (note-libredb): LibreDB Studio, a web interface to explore the database, on http://localhost:3001.
  • app (note-app): a Go container, to run Go against the stack.

The environment variables are described in Configuration.

Server

Each v* tag publishes the ghcr.io/cyril-fl/tide image (amd64 and arm64), which serves the API and the web app on the same origin. On the server, you need compose.prod.yaml and, next to it, a .env copied from .env.prod.example:

docker compose -f compose.prod.yaml up -d                                    # Postgres, Silo, Tide and LibreDB Studio
echo '<password>' | docker exec -i tide-api /tide-server user add <name> --password-stdin
docker compose -f compose.prod.yaml pull && docker compose -f compose.prod.yaml up -d   # update

The image only contains tide-server, the only binary that talks to Postgres and Silo. It runs the API and the web app, and carries the admin's commands (user add, user reset-password, rotate-secret), which you run in the container with docker exec. The tide CLI is a client of the API.

Tide listens over HTTP on TIDE_LISTEN (127.0.0.1:8080 by default). The session cookie requires HTTPS: the proxy in front provides it. WEB_ORIGIN is the exact address the browser types. The MCP for agents listens on TIDE_MCP_LISTEN (127.0.0.1:8081): only /mcp and its OAuth sign-in are there, an API token or a sign-in required, so a tunnel can open it to the Internet for the Claude app or ChatGPT while the rest stays private (see MCP.md). LibreDB Studio listens on LIBREDB_LISTEN (127.0.0.1:3001): connect to note-postgres:5432 with the POSTGRES_USER user.

At startup, Tide adds the tables and columns of new versions to the database. A rename or a type change is still done by hand; the commit message says so.

⚠️ TIDE_SECRET encrypts the notes. Keep a copy in a password manager, never in a backup: without this key, the notes are unreadable.

Accounts

The first account in the database is admin. Only it invites, lists and deletes the others, from the app's settings (Users section). This first account is created in three ways:

  • on an empty database, the app leads straight to the account creation page;
  • if TIDE_HOST_NAME and TIDE_HOST_PASSWORD are set in the .env, Tide creates it at startup; those two lines should then be emptied;
  • the tide-server user add command above works in every case.

After that, TIDE_ADD_USER_MODE decides who can create an account:

  • invitation (default): the admin creates an invitation link in the settings and sends it. The link works once and expires after 7 days. The invitee chooses their own name and password. Without an invitation, the account creation page is closed.
  • public: anyone who can reach the app can create an account. Reserve this mode for a trusted network (Tailscale), since nothing limits the number of creations.

Deleting an account permanently erases its notes, folders, tags and images. An admin can neither delete themselves nor delete the last admin.

CLI

Accounts

Each note, folder and tag belongs to an account, and an account never sees those of the others. The first account in the database is admin: only it invites, lists and deletes the others from the app (see Server in the root README). tide-server, on the server, creates an account whatever the server's mode:

tide-server user add cyril     # asks for the password twice (8 characters at least)
tide-server user reset-password cyril  # forgotten password: new password, all devices logged out
tide-server rotate-secret      # re-encrypts the accounts' keys with a new TIDE_SECRET (see Encryption)
tide login https://notes.example.ts.net  # name and password on this server, then every command acts for this account
tide logout                    # also ends the session on the server
tide whoami                    # the account and the server the CLI acts for
make connect TO=fedora          # in the repo: login on TIDE_FEDORA_URL from the .env, or TO=local on the API of make api
tide account purge             # empties the logged-in account (notes, folders, tags, images), after typing its name
  • On the server: in the container, docker exec -it tide-api /tide-server user add cyril (-i alone with --password-stdin).
  • Scripts: --password-stdin reads the password from standard input, for user add and user reset-password.
  • Admin: the flag is set by the first account created in an empty database, however it is created. To move it or add one, you have to touch the database: UPDATE users SET admin = true WHERE name = '<name>'.
  • CLI session: the server URL and the token are kept in ~/.config/tide/session.json, readable by the user only. The session lasts 30 days, extended at each use. TIDE_URL and TIDE_SESSION, if set, take precedence over this file: tide login <url> --print-token creates a separate session and prints only its token, for an agent that cannot log in where it runs (see MCP.md). tide logout with the variable only ends that session. The token opens the whole account, it goes in no versioned file.
API tokens
tide add token "backup script"               # prints the token once, on stdout
tide add token "Claude phone" --expires 30d   # 7d, 30d, 90d (default), 1y or never
tide add token "reader" --read-only           # reads the notes, changes nothing
tide show token                              # name, uuid, API or OAuth, access, creation, last use, expiry
tide remove token <uuid>                     # revokes: the token stops working at once

An API token (notes_…) is sent as Authorization: Bearer <token>. It does everything the account does on notes, folders, tags and files, but does not manage the account: its tokens, its password, its settings, the purge, the logout and the admin routes answer 403. The database only keeps its fingerprint (SHA-256). Once expired, it is refused (401) then purged by the server's hourly cleanup. They can also be managed in Settings > Account of the app.

The note and folder commands, as well as move, finder and graph, accept a UUID or a path:

tide show note 3f2a...               # by UUID
tide show note /Projets/Go/Idées     # by path

A path must match exactly, capitals included. If several items have the same path, the error lists their UUIDs.

Notes and folders
tide add folder --title Projets
tide add note --content "# Idées" --tag go,sql --parent /Projets
cat idees.md | tide add note --content - --parent /Projets

tide show note /Projets/Idées
tide show folder /Projets

tide edit note /Projets/Idées --tag go --untag sql
tide edit note /Projets/Idées --pin       # --unpin to remove
tide edit note /Projets/Idées --lock      # read-only, --unlock to remove
cat idees.md | tide edit note /Projets/Idées --content -
tide edit folder /Projets --title Travail
tide edit folder /Projets --pin            # as a favorite, --unpin to remove

tide move /Projets/Idées --parent /Archives

If a value is missing, a form opens. Without a terminal (cron, CI), pass everything through flags.

Two folders in the same folder cannot have the same name, capitals included: creating, renaming, moving or restoring a folder next to a namesake is refused (409 in the API). A database created before this rule has its duplicates renamed at startup, Name (2), Name (3)… Notes, on the other hand, can share a title.

A note has no separate title: it is its first markdown heading (#, ##…, whatever the level), otherwise the first 50 characters of its first line of text, without formatting, code or lines made only of #tags. A note without text stays untitled. The title follows the content at each change, and the path of a note (/Projets/Idées) with it.

notes finder [folder]     # explore, open, edit, create, delete
notes graph [note]        # navigate between notes that share tags
tide search recette      # search titles and content
tide search recette --limit 0   # every note found, 50 without --limit
tide recent              # the last 20 modified notes
Tags
tide add tag go sql
tide show tag go
tide show tag --list
tide edit tag go golang
tide remove tag sql

The tags of a note are the #words of its text, code and links excluded: #idée in the content creates the tag and links it to the note, and erasing it removes it. --tag writes #tag at the end of the text and --untag erases it. Renaming or deleting a tag fixes the text of all its notes, and a note that ends up empty goes to the trash. A tag with no note left disappears. A tag contains letters, digits, _ or -, with at least one letter.

Write [[Title]] in a note to link it to the note with that title, capitals or not, outside code. On save, a [[Title]] that designates a single note becomes [Title](note:<uuid>): the link now follows that note by its id, even if another takes its title, and the text between brackets updates when it changes title. If no note, or several, have that title, [[Title]] waits: it will be linked as soon as a single note bears that title. To break a tie, write its path, [[/Projets/Idées]].

[[Title#Section]] targets a heading of the note: it becomes [Title#Section](note:<uuid>#Section), keeps the section when the note changes title, and becomes [[Title#Section]] again on export. In the app, typing # after a note's name offers its headings, and a click opens the note at that heading. [[#Section]] targets a heading of the note itself: it stays as is, [[ then # offers the note's headings, and a click scrolls to it.

![[Title]], like in Obsidian, includes the note: it becomes ![Title](note:<uuid>) like a link, and becomes ![[Title]] again on export. In the app, the included note is displayed read-only under a link that opens it; its own inclusions stay links, so that a note that includes itself, or includes a note that includes it, stops there.

GET /api/notes/{id}/neighbors gives its links (links) and its backlinks (backlinks), and the graph also connects linked notes. In the app, typing [[ offers the notes, and a click on a link opens it. GET /api/links/broken lists the links of live notes that lead nowhere: unresolved (no other note with that title or path, or a #Section link to a heading the note does not have), ambiguous (several), missing (link to a note put in the trash or purged) or file (image or attachment /api/files/<id> that the account does not have: imported from another account, purged).

Trash
tide remove note /Projets/Idées
tide remove folder /Projets      # with all its content
tide trash
tide restore <uuid>

restore only accepts UUIDs, displayed by tide trash. Items are deleted for good when the CLI starts, once the account's retention period has passed (30 days by default, adjustable in Settings > Trash of the app, "Never erased" to not purge).

Export and import
tide export ~/notes-md              # all the notes
tide export ~/projets /Projets      # a folder
tide import ~/notes-md --parent /Archive
tide import ~/Obsidian/vault        # at the root

export writes into a new or empty folder, never over files: a folder becomes a directory, a note a <title>.md file with its text as is (title and #tags included). [Title](note:<uuid>) links become [[Title]] again, since ids mean nothing outside this database. Two notes with the same title in the same folder give Title.md and Title (2).md.

import does the opposite, all or nothing: a folder name already taken at the same place stops the whole import, leaving nothing behind. Hidden files (.obsidian, .git…) and those that are not .md are ignored. A text without a markdown title gets its file name at the top, # Name, like in Obsidian. [[links]] are linked at import, as when typing.

Images follow the notes. On export, those a note cites are copied into _files/ at the root of the export, and the note cites them by a relative path (../_files/<uuid>.png). On import, an image cited by a relative path (![](photo.png), ![](<photo de mer.png>)) becomes an image of the note, wherever it is in the folder. _files/ does not become a folder. An image that is missing or not PNG, JPEG, GIF or WebP keeps its link as is. A link to a file of the folder ([rapport](rapport.docx)) or a ![[son.mp3]] that is not an image makes it an attachment, cited by a link; a link to a note or to a refused type stays as is. On export, a zip keeps the extension of its name (.docx, .xlsx…). Obsidian's ![[image.png]] and ![[image.png|300]] too: the image is looked up by name in the whole folder (the one in the note's folder first), their width becomes the closest editor size ("small" up to 300 px, "medium" up to 600, nothing beyond).

Images

Pasting or dragging an image into the app's editor sends it to the API, which stores it in Silo (an S3 storage, a MinIO fork, started by make up) and describes it in the files table. The note cites it in markdown: ![name](/api/files/<uuid>). Another file (PDF, zip, hence also Office documents, MP3, WAV, Ogg, MP4, WebM; 20 MB at most) becomes an attachment, cited by a link [name](/api/files/<uuid>): the API sends it as a download under its name, and it follows the same purge and export rules as an image. The avatar stays an image. GET /api/files lists the account's files (name, type, size), the heaviest first, without those of a purged note or erased data.

  • PNG, JPEG, GIF and WebP only (no SVG, which can contain scripts), 20 MB at most. The type is read from the file, not from what the browser sends.
  • An image follows its note into the trash: when the note is erased for good (period elapsed, trash emptied, or its folder purged), its images go with it at the next hourly purge, unless another note still cites them.
  • An image removed from a note's text waits for the account's trash period, counted from when it is no longer cited (never if the trash keeps everything): until then, undoing or pasting the link back brings it back.
  • The browser never talks to Silo: it goes through GET /api/files/{id}, protected by the session. Silo's console is on http://localhost:9001 (credentials S3_ACCESS_KEY / S3_SECRET_KEY).
Scripts

search, recent, trash and show folder accept --json, as does show tag --list, which also accepts --yaml:

tide search recette --json | jq -r '.[].id'

The detail of each command is in tide <command> --help.

MCP (agents)

tide mcp   # speaks MCP on stdin/stdout, on behalf of the CLI session (tide login)

tide mcp gives an agent twenty-three tools on the account's notes: reading (search_notes, recent_notes, read_note, list_folder, tags, note_history, note_links, read_file, export_notes), writing (create_note, edit_note, create_folder, rename_folder, move_item, rename_tag, replace_notes, delete_tag, attach_file, import_notes) and trash (delete_note, delete_folder, list_trash, restore_item). A client of the API like the rest of the CLI, it listens on no port and has nothing to authenticate: it is the machine's CLI session that decides the server and the account, with all its rights.

An MCP is not read like an API: you do not run it by hand, the client starts it, and the account question is not settled in the request but by tide login. Everything is in MCP.md: declaring the server in the client, the account it acts for and how to share it between machines, the twenty-three tools, and what to know before letting an agent loose on your notes.

For an agent that cannot run a command (the Claude app on a phone or ChatGPT call from their cloud), tide-server serve --mcp-addr :8081 serves the same tools over streamable HTTP at /mcp, on an address of its own that a tunnel (Tailscale Funnel, Cloudflare Tunnel) or a proxy opens to the Internet without the API. Each request carries Authorization: Bearer notes_…: an API token of the account, or the access token of an OAuth connection. Notes is the OAuth 2.1 authorization server of that address (metadata, open dynamic client registration, a sign-in and consent page, PKCE, refresh tokens rotated), so ChatGPT, Claude's "Connect" or any MCP client that signs in needs only the URL; each connection is listed and revoked with the API tokens. A session token, an expired or revoked one gets 401. A read-only token or connection gets the reading tools only, and the API refuses it any change. The tools carry readOnlyHint, destructiveHint and idempotentHint, so the client asks before deleting or overwriting. Setup in MCP.md.

API

make api                                     # in Docker, with WEB_ORIGIN set in .env
go run ./cmd/tide-server serve --origin http://localhost:3000   # or directly on the machine

--addr chooses the listening address (127.0.0.1:8080 by default) and --origin the allowed origin of the web app, --web a folder of the generated app (bun run generate) served at the same address as the API. --add-user-mode decides who creates an account from the app: invitation (default, by an admin's link) or public (anyone). On a database with no account, TIDE_HOST_NAME and TIDE_HOST_PASSWORD create the first one at startup. When the API is only reachable from the machine (127.0.0.1), it takes each device's address from the proxy's X-Forwarded-For (tailscale serve), so that the delay after wrong passwords only blocks the faulty device. In a container, --published gives the address published on the machine side (TIDE_LISTEN), instead of --addr. --mcp-addr (none by default) also serves the MCP tools over HTTP at /mcp on that address, with its OAuth, for agents holding an API token or signed in (see MCP); --mcp-published is its address on the machine side (TIDE_MCP_LISTEN), on the loopback the client's address is read from X-Forwarded-For.

Resource Routes (prefix /api) JSON body
Accounts (admin) GET, DELETE /users/{id}, GET, POST /invites, DELETE /invites/{id}
Account creation GET /add-user[?invite=<token>], POST /signup name, password, invite (the link's token)
Account POST /login, POST /logout, GET, PATCH /me, PATCH /me/password name, password (login); settings: locale, theme, color_mode, view, trash_retention_days (0 to 3650, 0 to never purge), name, avatar (id of an image of the account, "" for none); password: current, new
Notes POST /notes, GET, PATCH, DELETE /notes/{id}, GET /notes/{id}/neighbors, GET /pinned content, tags, parent_id (creation), pinned, readonly
Folders GET, POST /folders, GET, PATCH, DELETE /folders/{id} title, parent_id (creation), pinned
Browse GET /items?parent=<uuid> (root without parent), POST /move ids, parent_id (root without parent_id)
Tags GET, POST /tags, GET, PATCH, DELETE /tags/{value} values (creation), value (rename)
Graph GET /graph (tags counted), GET /graph/notes (notes and the tags that link them, laid out; ?layout=false without the layout)
Search GET /search?q=<text>, GET /recent
Trash GET, DELETE /trash (everything), DELETE /trash/{id} (one deletion and what left with it), POST /restore ids (restore)
Export / import GET /export (zip; ?files=false leaves the images of _files/ empty, only named), POST /import?parent=<uuid> (zip as body, Content-Type: application/zip, or multipart/form-data form of files named by their path, folder/note.md; root without parent)
Images and attachments POST /files?name=<name> (the file as body), GET /files/{id}
  • Everything, except POST /login, GET /add-user and POST /signup, requires a session, otherwise 401. The /users and /invites routes also require an admin account, otherwise 403. POST /signup is only open on a database with no account, with a valid invitation token, or in public mode, where the same address waits longer and longer after each account created (429, beyond four); the token works once and expires after 7 days, the database only keeps its fingerprint. Deleting an account erases its notes, folders, tags and images (bytes included), but neither the logged-in account nor the last admin. Login sets a tide_session cookie (HttpOnly, Secure, SameSite=Strict), which lasts 30 days extended at each request. Scripts can send the token in Authorization: Bearer <token>. Expired sessions are erased from the database at the server's hourly purge.
  • After consecutive wrong passwords (per address for POST /login, per account for PATCH /me/password), the route answers 429 with Retry-After (in seconds): nothing up to 3 failures, then 30 s, 1 min, 5 min, 15 min, and 1 h from 8. A success resets the counter. The counts are kept in the database (throttles), so a restart forgets none, and the OAuth consent page of the MCP address shares the count of an address with the login; a day after the last try, an address starts over.
  • The title of a note comes from its content, as in the CLI: the API refuses a title field for a note.
  • PATCH /notes/{id} only changes the fields sent. {"pinned": true} alone pins the note without touching its text or its modification date. Without tags, the tags are the #words of the content. With tags, this list rewrites the content: "tags": [] erases all its #words. It answers the complete note, like GET (saved text, tags, path). {"readonly": true} locks the note: content and tags are then refused (409), unless with "readonly": false in the same request. With updated_at (the one read by GET, or created_at for a note never modified), content and tags are refused (409) if the note has changed since: a device left open does not overwrite what another wrote.
  • GET /notes/{id}/versions lists the note's versions, from the most recent to the oldest, without their text (id, conflict, created_at); GET /notes/{id}/versions/{version} reads one with its content. A PATCH (or tide edit note) that changes the text keeps the old one at the first save of a writing session (the note not modified for 15 minutes), and at least once an hour in a long session; a save without change does not count. Versions are not limited in number. Restoring a version is a PATCH of its content; versions go with the note when it is deleted for good.
  • POST /notes/{id}/versions with {"content": "..."} keeps a text refused by a 409 as a version marked conflict (201), so as not to lose it; nothing if it is already the note's text (204).
  • PATCH /folders/{id} with {"pinned": true} makes the folder a favorite. GET /pinned lists the pinned notes and the favorite folders, with their kind.
  • Errors have the form {"error": "..."}, with status 400, 401, 403, 404, 409, 413, 415, 429 or 500. Only an unknown route (404) and an unhandled method (405) answer in plain text, because the router writes them.
  • PATCH /me with name renames the account (409 if the name is taken). PATCH /me/password checks current, then logs out the other devices: the one that sends it stays logged in. The image of avatar is not purged as long as it serves as an avatar.
  • DELETE /me/data erases for good all the account's notes, folders, tags and images, trash included. The account, its settings and its sessions stay. It is the "Danger zone" of the web app's settings.
  • Deleted items go through the trash. The server purges it every hour. DELETE /trash empties it right away and for good.
  • GET /export and POST /import work like tide export and tide import, as a zip; the import also takes a form of files, their paths giving the folders. The import goes into the parent folder, at the root without it. It answers {"folders": n, "notes": n}, or 409 if a folder of the zip already exists at that spot, 400 if two files of the form have the same path.
  • POST /files answers the created file (id, name, content_type, size), 415 if it is not an accepted image. GET /files/{id} returns the image, cached by the browser: an image never changes.
  • make openapi generates the OpenAPI contract in docs/swagger.yaml, from the @ comments of the routes.
Security

Every request must come from a logged-in account. Still keep the API on 127.0.0.1 behind Tailscale or an HTTPS proxy: the password and the cookie must never travel in clear over a network.

  • A request whose Origin header differs from --origin is refused (403). Without --origin, no web page can call it. The SameSite=Strict cookie adds protection against other sites.
  • A request without Origin (curl, scripts) is accepted if it carries a session.
  • The Host header must be localhost, 127.0.0.1, [::1] or the host of --origin, which blocks DNS rebinding.
Encryption

The text and titles of notes, the names of folders, the tags, the snippets and the names of images are encrypted in the database, and the images in Silo (AES-256-GCM). Each account has its own key, drawn at random at its first login and stored in users.data_key, itself encrypted by the server secret TIDE_SECRET. A stolen database, backup or disk stays unreadable without this secret. A compromised server, on the other hand, holds it: encryption does not protect against that.

  • Generate the key with openssl rand -base64 32 and put the same one in .env (tide-server run by go run, the tests) and .env.docker (API).
  • Keep a copy of the key in a password manager, never in a backup. If you lose it, the notes become unreadable, even with a backup.
  • A forgotten password loses nothing: the admin resets it in Settings > Users (or tide-server user reset-password on the server, the only recourse for their own account), since the keys do not depend on the password.
  • Changing the secret: make backup, put the new one in TIDE_SECRET (.env), then TIDE_OLD_SECRET=<old> tide-server rotate-secret (in the container: docker exec -e TIDE_OLD_SECRET=<old> -e TIDE_SECRET=<new> note-api /tide-server rotate-secret). Only the accounts' keys are re-encrypted, not the notes. Then put the new secret in .env.docker and run make api. A second pass does nothing.
  • tide export outputs clear text.
  • To find a tag, a folder or a note by its name, and keep those names unique, the database keeps an HMAC fingerprint of the lowercase name (title_hash, value_hash). It cannot be read, but two identical names have the same fingerprint. Paths, sorting and search are done in the API, after decryption.
  • Not encrypted: the dates and the tree (which item is in which folder).

Configuration

These variables are those of tide-server; the CLI needs none of them, its session comes from tide login.

Variable Role Default
POSTGRES_USER, POSTGRES_PASSWORD Database credentials
POSTGRES_DB Database name tide
POSTGRES_HOST Host localhost
PORT PostgreSQL port 5432
CONFIG_FILE Replaces the embedded configuration config/config.yaml, built into the binary
WEB_ORIGIN Origin of the web app for make api none
S3_ENDPOINT Address of Silo, without http:// (note-silo:9000 in .env.docker)
S3_ACCESS_KEY, S3_SECRET_KEY Silo credentials, which also create it at the first make up
S3_BUCKET Bucket for images, created at first launch
S3_SECURE true to talk to Silo over HTTPS no
TIDE_SECRET Encryption key of the notes, 32 bytes in base64 (see Encryption) none: required to write

The commands, their help texts and their flags are defined in config/config.yaml. This file is built in at compile time: rebuild after changing it, or point CONFIG_FILE to your file.

Backup

make backup    # writes backups/tide-<date>.sql and the images in backups/tide-<date>.files/ (ignored by git)

To restore:

docker compose exec -T postgres sh -c 'psql -U "$POSTGRES_USER" "$POSTGRES_DB"' < backups/<file>.sql
docker compose cp backups/<file>.files silo:/tmp/restore
docker compose exec silo sh -c 'mcli alias set local http://127.0.0.1:9000 "$MINIO_ROOT_USER" "$MINIO_ROOT_PASSWORD" && mcli mirror /tmp/restore local/notes'

To erase everything, all accounts combined, after a backup: make purge (you have to type purge to confirm). The accounts and their settings stay.

The dump starts by dropping the existing tables: restoring therefore replaces the whole content of the database. The images are added to those in Silo, without erasing anything.

Makefile

Target Description
make up Starts Colima, Postgres, Silo and the API in Docker, then the web app on :3000
make down Stops the web app and the containers (Colima stays running)
make e2e Runs the browser tests (Playwright) against the stack
make perf Measures the API and the pages on an account of 50,000 generated notes
make setup Installs the git hooks (lefthook)
make test Runs the Go tests in the <POSTGRES_DB>_test database (ARGS=./core/... to target a folder)
make api Rebuilds and restarts the API container
make openapi Regenerates docs/swagger.yaml (then bun run types in web/)
make backup Backs up the database and the images into backups/
make purge Erases the notes, folders, tags and images of every account, after a backup
make pgsql Opens psql, or runs a query with QUERY="..."
make connect Connects the CLI to an API (TO=local or TO=fedora)

Development

The tests run in a separate database, <POSTGRES_DB>_test, created at the first make test, each in a rolled-back transaction. They create the schema: a migration being written therefore never reaches the database the API serves.

LibreDB Studio, an interface to explore the database, is on http://localhost:3001. On the command line: make pgsql opens psql, make pgsql QUERY="SELECT ..." runs a query and stops at the first error.

Folder Content
cmd/ The tide and tide-server binaries, the declaration of the Cobra commands
config/ Configuration and command texts
cli/ Entry point and display of each command of tide, its MCP (cli/cmd-mcp/) and the client of the API
core/api/ API routes, one per folder
core/server/ tide-server serve, the admin's commands, the MCP over HTTP (mcphttp/) and its OAuth
core/services/process/ Business logic and queries, used by the API
core/domain/ Data models
web/ The web app (Nuxt)
docs/ The OpenAPI contract, generated by make openapi

Quality

  • The lefthook hooks (make setup) run gofmt, Prettier and actionlint (for the workflows) before each commit. They also check the message prefix (feat:, fix:…).
  • The GitHub Actions CI (.github/workflows/ci.yml) runs on every push and every PR:
    • format, vet and the Go tests;
    • lint, format, tests, typecheck and build of the app;
    • the check that swagger.yaml and api.d.ts are up to date;
    • the e2e tests on the Docker stack;
    • the build of the server image, without publishing it.

Acknowledgments

Libraries
Services
  • Silo: image storage, S3-compatible
  • LibreDB Studio: a web interface for the database

License

MIT

Directories

Path Synopsis
cli
cmd-account
Package cmdaccount logs the CLI in and out and empties the account, through the API.
Package cmdaccount logs the CLI in and out and empties the account, through the API.
cmd-mcp
Package cmdmcp serves the account's notes to an agent over MCP, a client of the API like the rest of the CLI: the rules (titles, tags, links, trash, encryption) are those of the server.
Package cmdmcp serves the account's notes to an agent over MCP, a client of the API like the rest of the CLI: the rules (titles, tags, links, trash, encryption) are those of the server.
services/apiclient
Package apiclient provides primitives to interact with the openapi HTTP API.
Package apiclient provides primitives to interact with the openapi HTTP API.
services/apiclient/apitest
Package apitest serves the real API to the tests of the CLI commands that are clients of it.
Package apitest serves the real API to the tests of the CLI commands that are clients of it.
cmd
tide command
tide-server command
tide-server is the only binary on the base and Silo: the API and the web app, and the commands of its admin.
tide-server is the only binary on the base and Silo: the API and the web app, and the commands of its admin.
core
api
Package api is the HTTP API: one folder per route, each calling the same processes as the CLI.
Package api is the HTTP API: one folder per route, each calling the same processes as the CLI.
api/read-search
Package readsearch is the API route running a saved search.
Package readsearch is the API route running a saved search.
api/services/auth
Package auth lets through the requests of a logged-in account only, and tells the routes which one.
Package auth lets through the requests of a logged-in account only, and tells the routes which one.
api/services/compress
Package compress sends the big JSON answers of the API as gzip: on Tailscale from a phone, weight costs more than the server's time.
Package compress sends the big JSON answers of the API as gzip: on Tailscale from a phone, weight costs more than the server's time.
api/services/guard
Package guard keeps the web pages of other sites away from the API: they could use the session cookie.
Package guard keeps the web pages of other sites away from the API: they could use the session cookie.
api/services/plan
Package plan refuses the routes of a paid feature to the accounts whose plan lacks it.
Package plan refuses the routes of a paid feature to the accounts whose plan lacks it.
api/services/respond
Package respond is what every route shares: reading the request, writing JSON, turning process errors into statuses.
Package respond is what every route shares: reading the request, writing JSON, turning process errors into statuses.
api/services/throttle
Package throttle makes a key wait longer after each try in a row: wrong passwords at the login and on the OAuth consent page, accounts created from one address at the sign-up.
Package throttle makes a key wait longer after each try in a row: wrong passwords at the login and on the OAuth consent page, accounts created from one address at the sign-up.
api/users
Package users is the account routes an admin uses, and the self-service sign-up: the rest of an account's own routes are in login/.
Package users is the account routes an admin uses, and the self-service sign-up: the rest of an account's own routes are in login/.
server/cmd-admin
Package cmdadmin holds the commands of the server's admin, on the base: create accounts, reset their password and change the server's secret.
Package cmdadmin holds the commands of the server's admin, on the base: create accounts, reset their password and change the server's secret.
server/oauth
Package oauth makes the MCP address an OAuth 2.1 authorization server, as the MCP specification describes, for the clients that take no fixed token (ChatGPT) or prefer to sign in (Claude): the metadata, an open dynamic client registration, the consent page and the token endpoint.
Package oauth makes the MCP address an OAuth 2.1 authorization server, as the MCP specification describes, for the clients that take no fixed token (ChatGPT) or prefer to sign in (Claude): the metadata, an open dynamic client registration, the consent page and the token endpoint.
services/fold
Package fold sorts strings as people read them, for the processes and the CLI alike.
Package fold sorts strings as people read them, for the processes and the CLI alike.
services/forcelayout
Package forcelayout places the notes of a graph and their tags, as d3-force did in the browser: a repulsion between every node (Barnes-Hut), springs along the edges, collisions on a small graph, a pull to the center.
Package forcelayout places the notes of a graph and their tags, as d3-force did in the browser: a repulsion between every node (Barnes-Hut), springs along the edges, collisions on a small graph, a pull to the center.
services/hashtag
Package hashtag reads the #tags of a note's markdown: they are what makes the tags of the note.
Package hashtag reads the #tags of a note's markdown: they are what makes the tags of the note.
services/huhform
Package huhform gives every CLI form the same keys and SCNe-like help line.
Package huhform gives every CLI form the same keys and SCNe-like help line.
services/navigator
Package navigator is a navigable list screen shared by graph and search: rows lead to other pages or to notes, with history, filter and the same keys as the finder.
Package navigator is a navigable list screen shared by graph and search: rows lead to other pages or to notes, with history, filter and the same keys as the finder.
services/noteindex
Package noteindex keeps on each note what finds it without opening it (#145): the blinds of the grams of its title and content for searchnotes, the blinds of the titles its [[links]] wait for for linknotes, whether it has a link or a file and the blinds of its headings for listbrokenlinks, the blinds of the grams of its headings (#169).
Package noteindex keeps on each note what finds it without opening it (#145): the blinds of the grams of its title and content for searchnotes, the blinds of the titles its [[links]] wait for for linknotes, whether it has a link or a file and the blinds of its headings for listbrokenlinks, the blinds of the grams of its headings (#169).
services/notetitle
Package notetitle reads the title of a note from its markdown, as Apple Notes does: nobody types it apart.
Package notetitle reads the title of a note from its markdown, as Apple Notes does: nobody types it apart.
services/password
Package password hashes the passwords of accounts with argon2id, and makes the session tokens.
Package password hashes the passwords of accounts with argon2id, and makes the session tokens.
services/process/readsavedsearch
Package readsavedsearch finds a saved search by id among the account's, then replays its criteria.
Package readsavedsearch finds a saved search by id among the account's, then replays its criteria.
services/process/runsavedsearch
Package runsavedsearch replays a domain.SavedSearch's criteria: never a stored result, always run again.
Package runsavedsearch replays a domain.SavedSearch's criteria: never a stored result, always run again.
services/screen
Package screen prints command output the way the forms show: as tall as the terminal.
Package screen prints command output the way the forms show: as tall as the terminal.
services/secret
Package secret encrypts what the base keeps of the notes (AES-256-GCM): a stolen base, backup or disk is unreadable without the server's key TIDE_SECRET.
Package secret encrypts what the base keeps of the notes (AES-256-GCM): a stolen base, backup or disk is unreadable without the server's key TIDE_SECRET.
services/silo
Package silo keeps the bytes of the files in Silo, the S3 storage of compose.yaml.
Package silo keeps the bytes of the files in Silo, the S3 storage of compose.yaml.
services/style
Package style is the CLI look: one palette, named styles and the shared header and table.
Package style is the CLI look: one palette, named styles and the shared header and table.
services/testaccount
Package testaccount gives tests an account to act for, inside their rolled-back transaction.
Package testaccount gives tests an account to act for, inside their rolled-back transaction.
services/wikilink
Package wikilink reads the links of a note's markdown to other notes.
Package wikilink reads the links of a note's markdown to other notes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL