How kaidesalo/spellbranch works
Spellbranch is a social Magic deck-building app. Players authenticate, find cards through Scryfall, build and organize decks, then share independent forks, compare branches, and comment; friends, favorites, and personal collections support that workflow. Server pages and actions use query/action modules and a backend-selected repository, with local JSON storage or Supabase. The README documents the major capabilities and backend split; source excerpts confirm selected search, deck-action, session, query, and rate-limit relationships. Several feature implementations were not sampled, so their documented links are shown from README evidence.
Main entry points: card-search.tsx Card search UI · page.tsx Deck pages · decks.ts Deck operations · index.ts Backend repository
Components 23
Identity and community
- Sign-in and profiles
src/lib/actions/auth.ts - Friend requests
src/lib/actions/friends.ts
Cards and collection
- Favorite cards
src/lib/actions/favorites.ts - Card search UI
src/components/cards/card-search.tsx - Personal collection
src/lib/collection.ts
Deck building and sharing
- Deck pages
src/app/decks/[id]/page.tsx - Deck operations
src/lib/actions/decks.ts - Deck reads
src/lib/queries/decks.ts - Deck import and export
src/lib/decklist - Branch comparison
src/app/decks/[id]/compare/page.tsx - Deck comments
src/lib/actions/comments.ts - Browse and dashboard
src/app/browse/page.tsx
Application services
- Scryfall search route
src/app/api/scryfall/search/route.ts - Scryfall API client
src/lib/scryfall/client.ts - Session and access
src/lib/auth/session.ts - Feature queries
src/lib/queries - Server actions
src/lib/actions - Rate limiting
src/lib/rate-limit/index.ts - MTG news
src/lib/news/mtg-news.ts
Persistence
- Backend repository
src/lib/data/index.ts - Local JSON store
src/lib/data/store.ts - Supabase data and auth
src/lib/data/supabase.ts
Other components
- Player
Connections 26
- Player → Sign-in and profiles: signs in
- Player → Card search UI: searches cards
- Card search UI → Scryfall search route: requests results
- Scryfall search route → Scryfall API client: queries cards
src/app/api/scryfall/search/route.ts - Scryfall API client → Player: returns card data
- Card search UI → Deck operations: adds a card
src/components/cards/card-search.tsx - Card search UI → Favorite cards: favorites a card
src/components/cards/card-search.tsx - Player → Friend requests: manages friends
- Player → Personal collection: tracks cards
- Player → Deck pages: builds and views
- Deck pages → Deck operations: edits deck
- Deck pages → Deck reads: loads deck
src/app/decks/[id]/page.tsx - Deck pages → Deck import and export: imports or exports
- Player → Branch comparison: compares branches
- Player → Deck comments: comments on decks
- Player → Browse and dashboard: browses decks
- Deck reads → Backend repository: reads through
src/lib/queries/decks.ts - Deck operations → Backend repository: writes through
src/lib/actions/decks.ts - Sign-in and profiles → Session and access: uses sessions
src/lib/actions/auth.ts - Backend repository → Local JSON store: selects local backend
- Backend repository → Supabase data and auth: selects Supabase backend
- Session and access → Local JSON store: reads local users
src/lib/auth/session.ts - Session and access → Supabase data and auth: checks Supabase claims
src/lib/auth/session.ts - Deck operations → Rate limiting: checks limits
src/lib/actions/decks.ts - Sign-in and profiles → Rate limiting: checks limits
src/lib/actions/auth.ts - Browse and dashboard → MTG news: shows MTG news