wineater-bot 4.5.0 → 4.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md ADDED
@@ -0,0 +1,97 @@
1
+ # Wineater Bot — Claude Context
2
+
3
+ ## What is this?
4
+
5
+ This is **wineater-bot** — an embeddable wine recommendation widget that is part of the larger Wineater project. It gets either embedded into client websites via a `<script>` tag or offered as a standalone page hosted by Wineater.
6
+
7
+ It renders a wine grid with search, hover/click popups, and analytics, all in a self-contained JS bundle.
8
+
9
+ ## Tech Stack
10
+
11
+ - **Svelte 5** (runes-based reactivity: `$state`, `$derived`, `$effect`)
12
+ - **TypeScript**
13
+ - **Vite** (build tool, dev server on :3001)
14
+ - Output: `dist/wineater-chatbot.mjs` (ESM) + `dist/wineater-chatbot.umd.js` (UMD)
15
+
16
+ ## How to Run
17
+
18
+ ```bash
19
+ pnpm dev # dev server at localhost:3001
20
+ pnpm build # produces dist/ bundles
21
+ pnpm test # unit + e2e
22
+ pnpm test:unit # Vitest (browser via Playwright/Chromium)
23
+ pnpm test:e2e # Playwright
24
+ pnpm lint # Prettier + ESLint
25
+ ```
26
+
27
+ ## Project Structure
28
+
29
+ ```
30
+ src/
31
+ ├── index.js # Entry: mounts App.svelte to #wineater-widget-conteiner
32
+ ├── App.svelte # Root component (419 lines, core logic)
33
+ ├── components/
34
+ │ ├── Header.svelte
35
+ │ ├── Footer.svelte
36
+ │ ├── Search.svelte # Animated placeholder cycling search bar
37
+ │ ├── WineTile.svelte # Wine card: hover popup (desktop), click modal (mobile)
38
+ │ ├── WinePopup.svelte # Full wine detail modal
39
+ │ ├── Loader.svelte
40
+ │ ├── ui/Action.svelte # Reusable button/link
41
+ │ └── icons/ # SVG icon components (Budget, Diamond, Fish, Meat, Heart)
42
+ └── services/
43
+ ├── api/api.ts # WineaterApi class → Wineater backend
44
+ ├── api/deserialize.ts # API response → Wine / RecommendedWine types
45
+ ├── analytics/analytics.ts # Event tracking → admin-api.wineater.com
46
+ ├── analytics/constants.ts # Widget event type constants
47
+ ├── store/app-store.svelte.ts # Global state (Svelte runes)
48
+ ├── i18n/i18n.ts # Translations + OpenAI wine description translation
49
+ └── ui-config/ # Per-project branding/CSS/translations
50
+ ```
51
+
52
+ ## Key Concepts
53
+
54
+ ### Initialization
55
+ Client page sets `window.wineaterData = { CLIENT_TOKEN, WIDGET_TYPE, COUNTRY_CODE }` before loading the script. The widget reads this on mount.
56
+
57
+ ### Widget Modes
58
+ - `store` — retail wine shop, hover popups
59
+ - `bar` — bar/restaurant, enables AI translation of wine descriptions
60
+
61
+ ### Multi-tenancy (Per-Project Config)
62
+ Hardcoded in `src/services/ui-config/projects-config.ts` for projects 0, 21, 25, 26. Each project can have: custom brand color, logo, CSS, translations, button styling.
63
+
64
+ CSS variables at runtime: `--wr-brand-color`, `--wr-wineater-color`, `--wineater-font-primary`
65
+
66
+ ### API Endpoints Used
67
+ | Service | Endpoint |
68
+ |---|---|
69
+ | Wineater Backend | `https://wineater-backend.vercel.app/` |
70
+ | Admin API (analytics) | `https://admin-api.wineater.com/api/widget-events` |
71
+ | OpenAI | `https://api.openai.com/v1/chat/completions` (gpt-3.5-turbo, wine translation) |
72
+
73
+ ### Languages Supported
74
+ `en, de, fr, es, it, ja, zh, ru, kk, pt`
75
+
76
+ ### DOM Mount Point
77
+ ```html
78
+ <div id="wineater-widget-conteiner"></div>
79
+ ```
80
+ Note the intentional typo in "conteiner" — it is used in production, do not fix it.
81
+
82
+ ## Important Gotchas
83
+
84
+ - `#wineater-widget-conteiner` — this typo is intentional and load-bearing
85
+ - Wine translations use OpenAI and require `open_ai_key` from store config (only in `bar` mode)
86
+ - Analytics tracker is OpenReplay, project key `PA8j9fAi49i6g2QnvpNs`
87
+ - Per-project configs are hardcoded (not fetched) — changes require rebuild + redeploy
88
+ - `dist/` files are committed to the repo (clients reference them directly or via npm)
89
+ - Package manager: **pnpm**
90
+
91
+ ## Release Process
92
+
93
+ ```bash
94
+ pnpm release:patch # bump patch, publish to npm
95
+ pnpm release:minor # bump minor, publish to npm
96
+ pnpm release:beta # beta tag
97
+ ```