CLAUDE.md#
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview#
Blento is a Bluesky-powered customizable bento grid website builder. Users authenticate via ATProto OAuth and create draggable/resizable cards stored in their Bluesky PDS (Personal Data Server) using the app.blento.card collection.
Commands#
pnpm dev- Start development server (Vite)pnpm build- Build for productionpnpm preview- Build and preview with Wrangler (Cloudflare Workers)pnpm check- Run svelte-check for type checkingpnpm lint- Run Prettier check and ESLintpnpm format- Format code with Prettierpnpm deploy- Build and deploy to Cloudflare Workers
Code Quality Requirements#
Before submitting changes:
- Run
pnpm check- Must complete with 0 errors and 0 warnings - Run
pnpm format- Format all code with Prettier
Architecture#
Tech Stack#
- Framework: SvelteKit 2 with Svelte 5 (using runes:
$state,$derived,$props) - Styling: Tailwind CSS 4 with container queries (
@container) - Deployment: Cloudflare Workers via
@sveltejs/adapter-cloudflare - UI Components:
@foxui/core,@foxui/social(custom component libraries)
Grid System#
The site uses an 8-column grid layout (COLUMNS = 8 in src/lib/index.ts). Each card has:
- Desktop position/size:
x,y,w,h - Mobile position/size:
mobileX,mobileY,mobileW,mobileH
Grid margins: 16px desktop, 12px mobile.
Key Components#
Website Rendering:
src/lib/website/Website.svelte- Read-only view of a user's bento gridsrc/lib/website/EditableWebsite.svelte- Full editing interface with drag-and-drop, card creation, and save functionalitysrc/lib/website/Settings.svelteandsrc/lib/website/Profile.svelte- Editing panels and profile UI- Styling: two colors: base color (one the gray-ish tailwind colors:
gray,neutral,stone, ...) and accent color (one of the not-gray-ish tailwind color:rose,red,amber, ...)
Card System (src/lib/cards/):
CardDefinitiontype intypes.tsdefines the interface for card types- Each card type exports a definition with:
type,contentComponent, optionaleditingContentComponent,creationModalComponent,sidebarComponent,loadData,upload(see more info and description insrc/lib/cards/types.ts) - Card types include Text, Link, Image, Bluesky, Embed, Map, Livestream, ATProto collections, and special cards (see
src/lib/cards). AllCardDefinitionsandCardDefinitionsByTypeinindex.tsaggregate all card types- See e.g.
src/lib/cards/EmbedCard/andsrc/lib/cards/LivestreamCard/for examples of implementation. - Cards should be styled to work in light and dark mode (with
dark:class modifier) as well as when cards are colorful (= bg-color-500 for the card background) (withaccent:modifier).
ATProto Integration (src/lib/oauth/):
auth.svelte.ts- OAuth client state and login/logout flow using@atcute/oauth-browser-clientatproto.ts- ATProto API helpers:resolveHandle,listRecords,getRecord,putRecord,deleteRecord,uploadImage- Data is stored in user's PDS under collection
app.blento.card
Data Loading (src/lib/website/):
load.ts- Fetches user data from their PDS, with optional KV caching viaUserCachedata.ts- Defines which collections/records to fetchcontext.ts- Svelte contexts for passing DID, handle, and data down the component tree
Routes#
/- Landing page/[handle]/[[page]]- View a user's bento site (loads from their PDS)/[handle]/[[page]]/edit- Edit mode for a user's site page/edit- Self-hosted edit mode/api/links- Link preview API/api/geocoding- Geocoding API for map cards/api/instagram,/api/reloadRecent,/api/update- Additional data endpoints
Item Type#
Cards are represented by the Item type (src/lib/types.ts) with grid position, size, cardType, and cardData properties.
Collision/Layout Helpers#
src/lib/helper.ts contains grid layout algorithms:
fixAllCollisions- Push cards down when they overlapcompactItems- Move cards up to fill gapssimulateFinalPosition- Preview where a dragged card will land