Repository navigation
Library And Moodboards


Status: the Library store, the disk cache, the Moodboard page and the
saveandmoodboardtools are built (M3a, M3b). The examples were captured from the real server on 2026-12-02.
The Library is a folder of saved Refs. Each Board is a subfolder. Every saved image sits next to a JSON Sidecar that records where it came from, so you can credit the creator later. An index.json lists the boards. Saving is safe by design: nothing is written outside the Library, nothing is overwritten, and a half-finished save is rolled back. A separate disk cache holds search pages and thumbnails, and is not part of your Library.
By default the Library is refs/ in the current working directory (libraryRoot resolves <cwd>/refs). The library key in botticelli.config.json sets another folder (Configuration).
refs/
index.json
warm-light/
01_1128714725389331478.jpg
01_1128714725389331478.jpg.json
02_3f9a1c2b7d4e5f60.png
02_3f9a1c2b7d4e5f60.png.json
moodboard.html (written by the moodboard tool)
poster-typography/
...
Naming rules:
- A Board folder is the Board name as a slug: Unicode NFKC, lowercase, only
a-z,0-9,-and_, other runs become-, at most 60 characters. A name that leaves nothing usable is refused. - A file is
NN_<key>.<ext>.NNis the highest number already in that Board plus one, with at least two digits.<key>is the Ref'skeycleaned toA-Z a-z 0-9 - _, at most 60 characters. - The extension comes from the MIME type:
jpg,png,gif,webpormp4. Any other type is refused. - The Sidecar is the file name plus
.json.
Saving a Ref that is already in the Board (same source and key) writes nothing and returns the existing file.
A real Sidecar, written by save on 2026-12-02 for a pin that was saved by its URL:
{
"ref": {
"source": "pinterest",
"key": "1128714725389331478",
"imageUrl": "https://i.pinimg.com/originals/30/60/8b/30608b7df4499769fea5216ad87f1372.jpg",
"id": "1128714725389331478",
"pageUrl": "https://www.pinterest.com/pin/1128714725389331478/",
"title": "AI Learning App Onboarding Screens - Abdullah Zia",
"description": "31-Jan-2026 — Product Design, UI/UX, Web Design, Adobe Photoshop, Figma | Three smartphone screens displaying an educational app interface. The first screen welcomes users to EduMind and offers a \"Get Started\" button. App onboarding screens, Ux app design, Mobile app designs",
"width": 404,
"height": 316,
"lowRes": true,
"dominantColor": "#f5f1fd",
"sourceLink": "https://www.behance.net/gallery/251355231/The-Future-of-User-Experience/?ai-learning-app-onboarding-screens-abdullah-zia",
"sourceDomain": "behance.net",
"collection": {
"name": "Learning App UI Design",
"url": "https://www.pinterest.com/future_studiouiux/learning-app-ui-design/"
},
"author": "future_studiouiux",
"saves": 7,
"createdAt": "2026-08-09"
},
"file": "01_1128714725389331478.jpg",
"mimeType": "image/jpeg",
"bytes": 19340,
"savedAt": "2026-12-03T02:54:38.421Z",
"palette": ["#e7e3ef", "#fbfbfa", "#3c393f", "#9579c9", "#e8aa7c"],
"dhash": "3096acca8ecc7196",
"imageUrl": "https://i.pinimg.com/originals/30/60/8b/30608b7df4499769fea5216ad87f1372.jpg"
}| Field | Meaning |
|---|---|
ref |
The whole Ref as it was when saved. This is the origin and credit: pageUrl, sourceLink, sourceDomain, author, collection
|
file |
The image file name inside the Board folder |
mimeType, bytes
|
What was written |
savedAt |
ISO timestamp |
palette, dhash
|
Present when the caller gave them (the pipeline computes both) |
imageUrl |
The URL that actually answered the download, after size fallbacks. It can differ from ref.imageUrl
|
ref.author is the Pinterest account that pinned the image, often a collector and not the creator. ref.sourceLink is the page the pin points to. Use both when you credit, and see Credit your references.
{
"version": 1,
"boards": {
"warm-light": { "name": "warm light", "files": ["01_1128714725389331478.jpg"] }
}
}The key is the slug. name is the name you typed. files is the order of saving. It is plain data: you may edit it. The code does not trust it. A listed file name must be a bare name (no path), and its sidecar must resolve inside the Library, or it is skipped.
Reading functions: listBoards(root) returns every Board in the index. listBoard(root, board) returns the Sidecars of one Board in index order, and an empty list for an unknown Board.
An index.json that is not valid JSON, or has an unexpected shape, stops the save with an error that tells you to fix or delete it. It is never silently replaced.
Saving writes files, so it is built defensively. These rules are tested in test/library/.
| Rule | How |
|---|---|
| Nothing outside the Library |
assertInside refuses a path that leaves the root, by .. or an absolute path, and again after resolving symlinks of the nearest existing parent |
| A symlinked default root is refused | When library is not set in the config, the MCP server's save and moodboard refuse (outside the library) if refs/ itself is a symlink; a symlink at a library path you set yourself is allowed |
| No broken symlinks | A dangling symlink on the path is refused: the code never trusts where it points |
| No overwriting | Files are created with exclusive create (O_EXCL), which never follows a symlink. If the name is taken, a suffix is added (-2, -3, ...) |
| No half saves | The image and its sidecar are created together. If the sidecar or the index update fails, the files are removed |
| Atomic index |
index.json is written to a temporary file and renamed over the old one |
| Size limit | 30 MB per file by default (maxBytes option). A bigger file is refused |
| Safe board names | A board called __proto__ or constructor is an ordinary key, not a prototype hazard |
| Known types only | Only the five MIME types above are written |
One limit to know: saves inside one process take turns, so index.json does not lose updates. Two processes saving to the same Library at the same time are not coordinated.
Downloads are a separate step. fetchImage only accepts HTTPS URLs on the Source's own CDN hosts (Sources).
The cache is for pages and thumbnails you will likely fetch again. It is not the Library. Deleting it loses nothing you saved.
| Property | Value |
|---|---|
| Directory |
BOTTICELLI_CACHE_DIR, else ~/.cache/botticelli
|
| Layout |
<dir>/<namespace>/<sha256 of namespace+key>.json or .bin
|
| Permissions | Folders 0700, files 0600
|
| Namespace | Must match [A-Za-z0-9][A-Za-z0-9._-]*. Otherwise RefusedError
|
| TTL | Set by the caller on each write. JSON entries need one. Byte entries without a TTL never expire |
| Size cap | 200 MB across all namespaces |
| Pruning | After a write, at most once a minute: oldest files (by modification time) are removed until the total fits. Temporary files older than 60 s are removed |
| Bad entries | An expired, truncated or malformed entry is deleted and treated as a miss |
| Write errors | Logged to stderr as [botticelli] cache: …. They never fail the call |
The TTLs are not in the cache code. The server chooses them: 24 hours for search pages (namespace search) and 7 days for thumbnails (namespaces thumb-thumb, thumb-medium and thumb-large, one per size). A search page is keyed by the Source, the query, the limit, the cursor and the media filter. The Pinterest source does not use the cache by itself. Only the server does.
Status: built (M3b, #4).
A Moodboard is a static HTML page for one Board: the saved Refs, the consolidated palette and the credits. The moodboard tool writes it to refs/<board>/moodboard.html and returns { path, refs, palette }. Run the tool again after you save more Refs, and it replaces the page. It never touches the images, the Sidecars or index.json.

- The Refs and credits come from the Board's Sidecars. A Board with no saved Refs is an error (
Board "<name>" has no saved refs). - The consolidated palette (headed Palettæ) comes from
mergePalettes. It uses the palette in each Sidecar. - The look follows the identity in Visual identity: Charta paper, Sepia ink, one red rule under the title.
- The Refs sit in columns: 4 on a wide screen, 2 under 700 px and 1 under 400 px. Each has a number (
Tab. 01), its title, its author, a link to its source site and its own swatches. - The credits list (headed Fontes) is at the foot, numbered like the Refs. Each line has the author, the source link and the Pinterest page when the Ref has one:
<li value="1">candidasintbk · source <a href="https://trimrly.com/tajqH" rel="noopener noreferrer">https://trimrly.com/tajqH</a></li>- It is plain HTML and CSS, with no script. Images are linked by relative file name, so you can open the page from disk or host the whole Board folder anywhere.
- Text from a Sidecar is escaped. A link is made only for
http:andhttps:addresses. - It asks for two fonts, Cinzel and EB Garamond, from Google Fonts. Offline, or if the request is blocked, the page falls back to Georgia. The server itself makes no such request. Your browser does, when you open the page.
- The page is written to a temporary file and renamed, so a symlink at
moodboard.htmlis replaced, not followed. - The
savetool downloads the image of a Ref at its original size, so a video Ref is saved as its still image.
Path … is outside the library. You passed a path that leaves the Library, or one of its folders is a symlink pointing elsewhere. Use a path inside the Library.
index.json is not valid JSON. Fix the file by hand or delete it. Deleting it forgets the Board list, not the files. A saved file you want back in the index must be re-saved.
Cannot save "text/html": not a supported image or video type. The download was not an image. Check the URL. A CDN page that is not a picture usually stops earlier, with <url> answered with text/html, not an image.
A file has a -2 suffix. The first name was taken, maybe by a file you added by hand. The suffix is by design: nothing is overwritten.
Can I put the Library in git? Yes. The repo's own .gitignore ignores /refs/ only for local testing. Keep the sidecars with the images: they hold the credit.
Can I move or rename a Board folder? Do not. index.json lists the folder by its slug.
Where is my cache? ~/.cache/botticelli, or BOTTICELLI_CACHE_DIR. It is safe to delete.
More messages are in Troubleshooting. More questions are in the FAQ.
This wiki mirrors docs/ in the repository. Edit the docs there, not here. · MIT · Not affiliated with Pinterest or Are.na.
Use
Understand
Contribute
Project