# cr1py/pokebinder architecture

> Architecture diagram of the GitHub repository cr1py/pokebinder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cr1py/pokebinder
- Repository: https://github.com/cr1py/pokebinder

## Overview

PokeBinder is a digital portfolio for painted Pokémon cards, presented as an interactive, page-turning binder. Visitors open the cover, browse card sleeves, pull out a card, and inspect it in a draggable 3D viewer. On load, the binder fetches card records and slot assignments from Supabase. An administrator can sign in and add, edit, or delete cards; adding assigns a card to an available binder slot. The graph follows the documented workflow and sampled calls; unsampled admin actions are included where the SOURCE INDEX shows their dependencies.

Main entry points: [`src/components/binder/Binder.tsx`](https://github.com/cr1py/pokebinder/blob/main/src/components/binder/Binder.tsx) (Binder state), [`src/components/admin/AdminButton.tsx`](https://github.com/cr1py/pokebinder/blob/main/src/components/admin/AdminButton.tsx) (Admin controls), [`src/lib/cardService.ts`](https://github.com/cr1py/pokebinder/blob/main/src/lib/cardService.ts) (Card service), [`src/components/binder/BinderPage.tsx`](https://github.com/cr1py/pokebinder/blob/main/src/components/binder/BinderPage.tsx) (Page spreads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Binder experience"]
  node_binder["Binder state<br/>[Binder.tsx]"]
  node_cover["Binder cover<br/>[BinderCover.tsx]"]
  node_spread["Page spreads<br/>[BinderPage.tsx]"]
  node_page_content["Page contents<br/>[PageContent.tsx]"]
  node_page_turn["Page turns<br/>[FlippingLeaf.tsx]"]
  node_page_corner["Turn controls<br/>[PageCorner.tsx]"]
  node_page_mapping["Page mapping<br/>[PageController.tsx]"]
end

subgraph group_card_viewing["Card viewing"]
  node_sleeve["Card sleeves<br/>[CardSleeve.tsx]"]
  node_viewer["3D viewer<br/>[CardViewer.tsx]"]
  node_card_3d["Draggable card<br/>[Card3D.tsx]"]
end

subgraph group_administration["Administration"]
  node_admin_button["Admin controls<br/>[AdminButton.tsx]"]
  node_auth["Admin authentication<br/>[AuthContext.tsx]"]
  node_login["Login form<br/>[Login.tsx]"]
  node_add_card["Add cards<br/>[AddCard.tsx]"]
  node_edit_card["Edit cards<br/>[EditCard.tsx]"]
  node_delete_card["Delete cards<br/>[DeleteCard.tsx]"]
end

subgraph group_data["Data access"]
  node_card_service["Card service<br/>[cardService.ts]"]
  node_binder_service["Slot service<br/>[binderService.ts]"]
  node_card_types["Card data model<br/>[card.ts]"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
end

node_visitor(("Visitor"))
node_supabase[("Supabase backend")]

node_visitor -->|"opens binder"| node_binder
node_binder -->|"renders"| node_cover
node_binder -->|"renders"| node_spread
node_binder -->|"calculates spreads"| node_page_mapping
node_binder -->|"fetches cards"| node_card_service
node_binder -->|"fetches slots"| node_binder_service
node_binder -->|"opens viewer"| node_viewer
node_spread -->|"renders pages"| node_page_content
node_spread -->|"renders flip"| node_page_turn
node_spread -->|"renders controls"| node_page_corner
node_spread -->|"maps page numbers"| node_page_mapping
node_page_content -->|"renders sleeves"| node_sleeve
node_sleeve -->|"accepts clicks"| node_visitor
node_viewer -->|"hosts card"| node_card_3d
node_visitor -->|"opens admin"| node_admin_button
node_admin_button -->|"checks session"| node_auth
node_admin_button -->|"opens login"| node_login
node_admin_button -->|"opens form"| node_add_card
node_admin_button -->|"opens editor"| node_edit_card
node_admin_button -->|"opens deletion"| node_delete_card
node_login -->|"signs in"| node_auth
node_auth -->|"uses auth"| node_supabase_client
node_add_card -->|"uploads and inserts"| node_card_service
node_add_card -->|"assigns slot"| node_binder_service
node_edit_card -->|"updates card"| node_card_service
node_delete_card -->|"deletes card"| node_card_service
node_card_service -->|"queries records"| node_supabase_client
node_binder_service -->|"queries slots"| node_supabase_client
node_supabase_client -->|"connects to"| node_supabase
node_card_service -->|"maps card rows"| node_card_types
node_binder_service -->|"uses slot types"| node_card_types

click node_binder "https://github.com/cr1py/pokebinder/blob/main/src/components/binder/Binder.tsx"
click node_cover "https://github.com/cr1py/pokebinder/blob/main/src/components/binder/BinderCover.tsx"
click node_spread "https://github.com/cr1py/pokebinder/blob/main/src/components/binder/BinderPage.tsx"
click node_page_content "https://github.com/cr1py/pokebinder/blob/main/src/components/binder/PageContent.tsx"
click node_page_turn "https://github.com/cr1py/pokebinder/blob/main/src/components/binder/FlippingLeaf.tsx"
click node_page_corner "https://github.com/cr1py/pokebinder/blob/main/src/components/binder/PageCorner.tsx"
click node_page_mapping "https://github.com/cr1py/pokebinder/blob/main/src/components/binder/PageController.tsx"
click node_sleeve "https://github.com/cr1py/pokebinder/blob/main/src/components/sleeve/CardSleeve.tsx"
click node_viewer "https://github.com/cr1py/pokebinder/blob/main/src/components/card/CardViewer.tsx"
click node_card_3d "https://github.com/cr1py/pokebinder/blob/main/src/components/card/Card3D.tsx"
click node_admin_button "https://github.com/cr1py/pokebinder/blob/main/src/components/admin/AdminButton.tsx"
click node_auth "https://github.com/cr1py/pokebinder/blob/main/src/components/admin/AuthContext.tsx"
click node_login "https://github.com/cr1py/pokebinder/blob/main/src/components/admin/Login.tsx"
click node_add_card "https://github.com/cr1py/pokebinder/blob/main/src/components/admin/AddCard.tsx"
click node_edit_card "https://github.com/cr1py/pokebinder/blob/main/src/components/admin/EditCard.tsx"
click node_delete_card "https://github.com/cr1py/pokebinder/blob/main/src/components/admin/DeleteCard.tsx"
click node_card_service "https://github.com/cr1py/pokebinder/blob/main/src/lib/cardService.ts"
click node_binder_service "https://github.com/cr1py/pokebinder/blob/main/src/lib/binderService.ts"
click node_card_types "https://github.com/cr1py/pokebinder/blob/main/src/types/card.ts"
click node_supabase_client "https://github.com/cr1py/pokebinder/blob/main/src/lib/supabase.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_binder,node_cover,node_spread,node_page_content,node_page_turn,node_page_corner,node_page_mapping toneBlue
class node_sleeve,node_viewer,node_card_3d,node_supabase toneAmber
class node_admin_button,node_auth,node_login,node_add_card,node_edit_card,node_delete_card toneMint
class node_card_service,node_binder_service,node_card_types,node_supabase_client toneRose
class node_visitor toneIndigo
```

## Components

### Binder experience

- [Binder state](https://github.com/cr1py/pokebinder/blob/main/src/components/binder/Binder.tsx): `src/components/binder/Binder.tsx`
- [Binder cover](https://github.com/cr1py/pokebinder/blob/main/src/components/binder/BinderCover.tsx): `src/components/binder/BinderCover.tsx`
- [Page spreads](https://github.com/cr1py/pokebinder/blob/main/src/components/binder/BinderPage.tsx): `src/components/binder/BinderPage.tsx`
- [Page contents](https://github.com/cr1py/pokebinder/blob/main/src/components/binder/PageContent.tsx): `src/components/binder/PageContent.tsx`
- [Page turns](https://github.com/cr1py/pokebinder/blob/main/src/components/binder/FlippingLeaf.tsx): `src/components/binder/FlippingLeaf.tsx`
- [Turn controls](https://github.com/cr1py/pokebinder/blob/main/src/components/binder/PageCorner.tsx): `src/components/binder/PageCorner.tsx`
- [Page mapping](https://github.com/cr1py/pokebinder/blob/main/src/components/binder/PageController.tsx): `src/components/binder/PageController.tsx`

### Card viewing

- [Card sleeves](https://github.com/cr1py/pokebinder/blob/main/src/components/sleeve/CardSleeve.tsx): `src/components/sleeve/CardSleeve.tsx`
- [3D viewer](https://github.com/cr1py/pokebinder/blob/main/src/components/card/CardViewer.tsx): `src/components/card/CardViewer.tsx`
- [Draggable card](https://github.com/cr1py/pokebinder/blob/main/src/components/card/Card3D.tsx): `src/components/card/Card3D.tsx`

### Administration

- [Admin controls](https://github.com/cr1py/pokebinder/blob/main/src/components/admin/AdminButton.tsx): `src/components/admin/AdminButton.tsx`
- [Admin authentication](https://github.com/cr1py/pokebinder/blob/main/src/components/admin/AuthContext.tsx): `src/components/admin/AuthContext.tsx`
- [Login form](https://github.com/cr1py/pokebinder/blob/main/src/components/admin/Login.tsx): `src/components/admin/Login.tsx`
- [Add cards](https://github.com/cr1py/pokebinder/blob/main/src/components/admin/AddCard.tsx): `src/components/admin/AddCard.tsx`
- [Edit cards](https://github.com/cr1py/pokebinder/blob/main/src/components/admin/EditCard.tsx): `src/components/admin/EditCard.tsx`
- [Delete cards](https://github.com/cr1py/pokebinder/blob/main/src/components/admin/DeleteCard.tsx): `src/components/admin/DeleteCard.tsx`

### Data access

- [Card service](https://github.com/cr1py/pokebinder/blob/main/src/lib/cardService.ts): `src/lib/cardService.ts`
- [Slot service](https://github.com/cr1py/pokebinder/blob/main/src/lib/binderService.ts): `src/lib/binderService.ts`
- [Card data model](https://github.com/cr1py/pokebinder/blob/main/src/types/card.ts): `src/types/card.ts`
- [Supabase client](https://github.com/cr1py/pokebinder/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`

### Other components

- **Visitor**
- **Supabase backend**

## Connections

- Visitor → Binder state: opens binder (evidence: `README.md`)
- Binder state → Binder cover: renders (evidence: `src/components/binder/Binder.tsx`)
- Binder state → Page spreads: renders (evidence: `src/components/binder/Binder.tsx`)
- Binder state → Page mapping: calculates spreads (evidence: `src/components/binder/Binder.tsx`)
- Binder state → Card service: fetches cards (evidence: `src/components/binder/Binder.tsx`)
- Binder state → Slot service: fetches slots (evidence: `src/components/binder/Binder.tsx`)
- Binder state → 3D viewer: opens viewer (evidence: `src/components/binder/Binder.tsx`)
- Page spreads → Page contents: renders pages (evidence: `src/components/binder/BinderPage.tsx`)
- Page spreads → Page turns: renders flip (evidence: `src/components/binder/BinderPage.tsx`)
- Page spreads → Turn controls: renders controls (evidence: `src/components/binder/BinderPage.tsx`)
- Page spreads → Page mapping: maps page numbers (evidence: `src/components/binder/BinderPage.tsx`)
- Page contents → Card sleeves: renders sleeves (evidence: `src/components/binder/PageContent.tsx`)
- Card sleeves → Visitor: accepts clicks (evidence: `README.md`)
- 3D viewer → Draggable card: hosts card (evidence: `src/components/card/CardViewer.tsx`)
- Visitor → Admin controls: opens admin (evidence: `README.md`)
- Admin controls → Admin authentication: checks session (evidence: `src/components/admin/AdminButton.tsx`)
- Admin controls → Login form: opens login (evidence: `src/components/admin/AdminButton.tsx`)
- Admin controls → Add cards: opens form (evidence: `src/components/admin/AdminButton.tsx`)
- Admin controls → Edit cards: opens editor (evidence: `src/components/admin/AdminButton.tsx`)
- Admin controls → Delete cards: opens deletion (evidence: `src/components/admin/AdminButton.tsx`)
- Login form → Admin authentication: signs in (evidence: `src/components/admin/Login.tsx`)
- Admin authentication → Supabase client: uses auth (evidence: `src/components/admin/AuthContext.tsx`)
- Add cards → Card service: uploads and inserts (evidence: `src/components/admin/AddCard.tsx`)
- Add cards → Slot service: assigns slot (evidence: `src/components/admin/AddCard.tsx`)
- Edit cards → Card service: updates card (evidence: `src/components/admin/EditCard.tsx`)
- Delete cards → Card service: deletes card (evidence: `src/components/admin/DeleteCard.tsx`)
- Card service → Supabase client: queries records (evidence: `src/lib/cardService.ts`)
- Slot service → Supabase client: queries slots (evidence: `src/lib/binderService.ts`)
- Supabase client → Supabase backend: connects to (evidence: `src/lib/supabase.ts`)
- Card service → Card data model: maps card rows (evidence: `src/lib/cardService.ts`)
- Slot service → Card data model: uses slot types (evidence: `src/lib/binderService.ts`)
