oneie 3.3.4 → 3.3.6

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.
@@ -0,0 +1,195 @@
1
+ ---
2
+ allowed-tools: Bash(cd web && bun run build:*), Bash(cd web && wrangler pages deploy:*), Bash(echo:*), Bash(cat .env:*), Bash(grep CLOUDFLARE .env:*)
3
+ description: Deploy your website to Cloudflare Pages with automated setup
4
+ ---
5
+
6
+ # /deploy - Deploy to Cloudflare Pages
7
+
8
+ **Purpose:** Deploy your website to Cloudflare Pages with one command. This handles everything from checking credentials to building and deploying.
9
+
10
+ ## How It Works
11
+
12
+ This command will:
13
+ 1. Check if you have Cloudflare credentials configured
14
+ 2. If not, provide step-by-step instructions to get them
15
+ 3. Build your website
16
+ 4. Deploy to Cloudflare Pages
17
+ 5. Give you the live URL
18
+
19
+ ## Your Task
20
+
21
+ Follow these steps in order:
22
+
23
+ ### Step 1: Check for Cloudflare Credentials
24
+
25
+ Run this command to check if credentials are configured:
26
+
27
+ ```bash
28
+ grep -E "CLOUDFLARE_GLOBAL_API_KEY|CLOUDFLARE_ACCOUNT_ID|CLOUDFLARE_EMAIL" .env 2>/dev/null || echo "No Cloudflare credentials found"
29
+ ```
30
+
31
+ ### Step 2: If Credentials Are Missing
32
+
33
+ If the user doesn't have credentials, provide these instructions:
34
+
35
+ **"To deploy to Cloudflare, you need to add three environment variables to your `.env` file. Here's how to get them:**
36
+
37
+ **1. Get Your Cloudflare Global API Key:**
38
+ - Go to https://dash.cloudflare.com/profile/api-tokens
39
+ - Scroll to "API Keys" section
40
+ - Click "View" next to "Global API Key"
41
+ - Copy the key (you'll need to enter your Cloudflare password)
42
+
43
+ **2. Get Your Account ID:**
44
+ - Go to https://dash.cloudflare.com/
45
+ - Select any website
46
+ - On the right side, you'll see "Account ID" - copy it
47
+
48
+ **3. Get Your Email:**
49
+ - This is the email you use to log into Cloudflare
50
+
51
+ **4. Add to Your `.env` File:**
52
+
53
+ Open or create a `.env` file in your project root and add:
54
+
55
+ ```bash
56
+ CLOUDFLARE_GLOBAL_API_KEY=your-global-api-key-here
57
+ CLOUDFLARE_ACCOUNT_ID=your-account-id-here
58
+ CLOUDFLARE_EMAIL=your-cloudflare-email@example.com
59
+ ```
60
+
61
+ **IMPORTANT SECURITY NOTES:**
62
+ - The Global API Key provides **FULL CONTROL** over your Cloudflare account
63
+ - Never commit your `.env` file to git (it should already be in `.gitignore`)
64
+ - Never share these credentials with anyone
65
+ - This gives complete access to create, modify, and delete resources
66
+
67
+ Once you've added these to `.env`, run `/deploy` again to deploy your site!"
68
+
69
+ ### Step 3: If Credentials Exist, Deploy
70
+
71
+ If credentials are found, proceed with deployment:
72
+
73
+ ```bash
74
+ # 1. Build the website
75
+ cd web
76
+ echo "Building your website..."
77
+ bun run build
78
+
79
+ # 2. Deploy to Cloudflare Pages
80
+ echo ""
81
+ echo "Deploying to Cloudflare Pages..."
82
+ wrangler pages deploy dist --project-name=web --commit-dirty=true
83
+
84
+ # 3. The output will show the deployment URL
85
+ ```
86
+
87
+ ### Step 4: Report Success
88
+
89
+ After deployment completes, tell the user:
90
+
91
+ **"✅ Deployment Complete!**
92
+
93
+ Your website is now live at:
94
+ - **Production**: https://web.one.ie (if custom domain configured)
95
+ - **Preview**: [URL from wrangler output]
96
+
97
+ **What Just Happened:**
98
+ 1. Built your website (optimized for production)
99
+ 2. Uploaded to Cloudflare Pages
100
+ 3. Deployed to edge servers worldwide (330+ locations)
101
+
102
+ **Next Steps:**
103
+ - Test your live site
104
+ - Set up a custom domain (if desired)
105
+ - Configure CI/CD for automatic deployments
106
+
107
+ **Deployment Dashboard:**
108
+ https://dash.cloudflare.com → Pages → web
109
+
110
+ **To redeploy after changes:**
111
+ Just run `/deploy` again anytime!"
112
+
113
+ ## Error Handling
114
+
115
+ ### If Build Fails
116
+
117
+ Tell the user:
118
+ "❌ Build failed. Please fix the errors above and try again.
119
+
120
+ Common issues:
121
+ - TypeScript errors: Run `bunx astro check`
122
+ - Missing dependencies: Run `bun install`
123
+ - Configuration issues: Check `astro.config.mjs`"
124
+
125
+ ### If Wrangler Not Authenticated
126
+
127
+ If you see an error about wrangler authentication, tell the user:
128
+
129
+ "You need to authenticate wrangler CLI:
130
+
131
+ ```bash
132
+ npx wrangler login
133
+ ```
134
+
135
+ This will open a browser to log into Cloudflare. Once logged in, run `/deploy` again."
136
+
137
+ ### If Project Doesn't Exist
138
+
139
+ If the project doesn't exist on Cloudflare Pages:
140
+
141
+ "The 'web' project doesn't exist yet. Let's create it:
142
+
143
+ 1. Go to https://dash.cloudflare.com → Pages
144
+ 2. Click "Create a project"
145
+ 3. Name it 'web'
146
+ 4. Skip the git connection for now
147
+ 5. Run `/deploy` again
148
+
149
+ Or change the project name in the deploy command to match an existing project."
150
+
151
+ ## Important Notes
152
+
153
+ **Security:**
154
+ - The `.env` file is excluded from git by default
155
+ - Your Global API Key gives full control - keep it secure
156
+ - Never log or display the actual key values
157
+
158
+ **Deployment:**
159
+ - First deployment may take 2-3 minutes
160
+ - Subsequent deployments are faster (~30 seconds)
161
+ - Changes are live on the edge network within seconds
162
+
163
+ **Custom Domains:**
164
+ - Add custom domains in Cloudflare Pages dashboard
165
+ - HTTPS is automatic and free
166
+ - DNS can be managed in Cloudflare
167
+
168
+ ## Example Session
169
+
170
+ **User runs `/deploy` without credentials:**
171
+
172
+ ```
173
+ ❌ No Cloudflare credentials found in .env
174
+
175
+ To deploy, you need three values from Cloudflare:
176
+ [...instructions above...]
177
+ ```
178
+
179
+ **User adds credentials and runs `/deploy` again:**
180
+
181
+ ```
182
+ ✅ Cloudflare credentials found
183
+ 🔨 Building website...
184
+ ✓ Build complete (2.3s)
185
+ 🚀 Deploying to Cloudflare Pages...
186
+ ✨ Upload complete
187
+ 🌍 Deploying globally...
188
+ ✅ Deployment complete!
189
+
190
+ Your site is live at: https://abc123.pages.dev
191
+ ```
192
+
193
+ ---
194
+
195
+ **Simple, secure, and powerful deployment in one command! 🚀**
@@ -1,45 +1,54 @@
1
1
  ---
2
- allowed-tools: Bash(./scripts/release.sh:*), Bash(./scripts/pre-deployment-check.sh:*), Bash(./scripts/cloudflare-deploy.sh:*), Bash(cd web && bun run build:*), Bash(cd web && wrangler pages deploy:*), Bash(cd cli && npm publish:*), Bash(git status:*), Bash(git add:*), Bash(git commit:*), Bash(git push:*), Bash(git tag:*), Bash(npm view oneie:*)
3
- description: Execute full ONE Platform release with automated Cloudflare deployment via API
2
+ allowed-tools: Task(agent-ops:*)
3
+ description: Execute full ONE Platform release via agent-ops specialist
4
4
  ---
5
5
 
6
6
  # /release - Full ONE Platform Release
7
7
 
8
- **Purpose:** Execute the complete 13-step release process including npm publish, GitHub pushes, and Cloudflare Pages deployment.
8
+ **Purpose:** Delegate to `agent-ops` specialist to execute the complete 13-step release process including npm publish, GitHub pushes, and Cloudflare Pages deployment.
9
9
 
10
- ## Context
10
+ ## How It Works
11
11
 
12
- Before starting the release, gather this information:
13
- 1. Run `pwd` to verify current directory
14
- 2. Check `ls -lah scripts/release.sh` to verify release script exists
15
- 3. Run `git status --short` to check for uncommitted changes
16
- 4. Check `ls -lah web/dist/` to see if a build already exists
12
+ This command **MUST** delegate to the `agent-ops` specialist agent, which has the expertise and tools to handle:
13
+ 1. Pre-deployment validation
14
+ 2. Version bumping
15
+ 3. File synchronization
16
+ 4. Git operations
17
+ 5. npm publishing
18
+ 6. Cloudflare deployments (using CLOUDFLARE_GLOBAL_API_KEY)
19
+ 7. Verification and reporting
17
20
 
18
- ## Release Options
21
+ ## Release Types
19
22
 
20
- ### Option 1: Patch Release (Recommended for Hotfixes)
21
- ```
22
- /release patch
23
- ```
23
+ - `/release patch` - Bug fixes (3.3.5 → 3.3.6)
24
+ - `/release minor` - New features (3.3.5 → 3.4.0)
25
+ - `/release major` - Breaking changes (3.3.5 → 4.0.0)
26
+ - `/release sync` - Sync files without version bump
24
27
 
25
- ### Option 2: Minor Release (New Features)
26
- ```
27
- /release minor
28
- ```
29
-
30
- ### Option 3: Major Release (Breaking Changes)
31
- ```
32
- /release major
33
- ```
28
+ ## Your Task
34
29
 
35
- ### Option 4: Sync Only (No Version Bump)
36
- ```
37
- /release sync
30
+ **CRITICAL:** You MUST delegate this entire release to the `agent-ops` specialist by using the Task tool:
31
+
32
+ ```typescript
33
+ Task({
34
+ subagent_type: "agent-ops",
35
+ description: "Execute full release",
36
+ prompt: `Execute a ${releaseType} release for ONE Platform:
37
+
38
+ 1. Run pre-deployment validation
39
+ 2. Execute release script: ./scripts/release.sh ${releaseType}
40
+ 3. Publish to npm: cd cli && npm publish --access public
41
+ 4. Verify deployment:
42
+ - npm: npx oneie@latest --version
43
+ - Web: Check Cloudflare deployment URL
44
+ - GitHub: Verify tags created
45
+ 5. Report summary with all live URLs
46
+
47
+ IMPORTANT: The CLOUDFLARE_GLOBAL_API_KEY is set in .env and provides FULL ACCESS to Cloudflare API for automated deployments.`
48
+ })
38
49
  ```
39
50
 
40
- ## Your Task
41
-
42
- Based on the release type requested:
51
+ ## Agent-Ops Responsibilities
43
52
 
44
53
  ### Step 1: Pre-Deployment Validation
45
54
  1. Run `./scripts/pre-deployment-check.sh`
@@ -199,7 +208,16 @@ Before running `/release`, ensure:
199
208
  - ✅ Wrangler is authenticated
200
209
  - ✅ Release scripts exist in `scripts/`
201
210
 
202
- **For Automated Cloudflare Deployment (Optional):**
211
+ **For Automated Cloudflare Deployment:**
212
+
213
+ **Option 1: Global API Key (FULL ACCESS - Recommended for automated deployments):**
214
+ - ✅ Set `CLOUDFLARE_GLOBAL_API_KEY` in root `.env`
215
+ - ✅ Set `CLOUDFLARE_ACCOUNT_ID` in root `.env`
216
+ - ✅ Set `CLOUDFLARE_EMAIL` in root `.env`
217
+ - ✅ Provides complete programmatic access to Cloudflare API
218
+ - ✅ Zero manual intervention needed
219
+
220
+ **Option 2: API Token (Scoped access):**
203
221
  - ✅ Set `CLOUDFLARE_API_TOKEN` environment variable
204
222
  - ✅ Set `CLOUDFLARE_ACCOUNT_ID` environment variable
205
223
 
@@ -207,6 +225,8 @@ Before running `/release`, ensure:
207
225
  - The script falls back to interactive wrangler CLI deployment
208
226
  - Still fully functional, just requires manual confirmation
209
227
 
228
+ **CRITICAL:** The `CLOUDFLARE_GLOBAL_API_KEY` in `.env` provides **FULL ACCESS** to the Cloudflare API. This is required for fully automated deployments via `/release` command.
229
+
210
230
  ## Post-Release Tasks
211
231
 
212
232
  After `/release` succeeds, remind user to:
package/CLAUDE.md CHANGED
@@ -701,6 +701,21 @@ const entities = await convex.query(api.queries.entities.list, {
701
701
 
702
702
  ### Environment Variables
703
703
 
704
+ **Root (.env) - CRITICAL FOR DEPLOYMENTS:**
705
+
706
+ ```bash
707
+ # Cloudflare Global API Key - FULL ACCESS to Cloudflare API
708
+ # This provides complete programmatic access for automated deployments
709
+ CLOUDFLARE_GLOBAL_API_KEY=your-cloudflare-global-api-key
710
+ CLOUDFLARE_ACCOUNT_ID=your-cloudflare-account-id
711
+ CLOUDFLARE_EMAIL=your-cloudflare-email
712
+
713
+ # Alternative: Cloudflare API Token (scoped access)
714
+ CLOUDFLARE_API_TOKEN=your-cloudflare-api-token
715
+ ```
716
+
717
+ **IMPORTANT:** The `CLOUDFLARE_GLOBAL_API_KEY` in `.env` provides **FULL ACCESS** to the Cloudflare API. This enables automated deployments via `./scripts/cloudflare-deploy.sh` and the `/release` command without manual intervention. Keep this key secure and never commit `.env` to version control.
718
+
704
719
  **Web (.env.local):**
705
720
 
706
721
  ```bash
package/folders.yaml CHANGED
@@ -87,6 +87,6 @@ exclude_patterns:
87
87
  deployment:
88
88
  github_repo: one-ie/one
89
89
  npm_package: oneie
90
- version: 3.3.2
90
+ version: 3.3.6
91
91
  homepage: https://one.ie
92
92
  license_url: https://one.ie/free-license
@@ -0,0 +1,138 @@
1
+ ### Attracting New Customers 🎯
2
+
3
+ **Goal:** Drive qualified traffic by becoming the most helpful padel resource online.
4
+
5
+ 1. **AI-Powered Content Generation for SEO:**
6
+
7
+ - **How it works:** A `marketing_agent` `Thing` is tasked to increase organic traffic. It analyzes `Knowledge` labels like `skill_level:beginner`, `racket_style:control`, and `brand:Bullpadel`. It then automatically generates a `guide` `Thing` titled, "The 2025 Guide: Best Bullpadel Control Rackets for Beginners."
8
+
9
+ - **Powerful Result:** Instead of generic blog posts, Nine Padel creates dozens of hyper-specific articles that rank #1 on Google for long-tail searches. This attracts players who have high purchase intent, establishing the store as an expert before the customer even sees a product.
10
+
11
+ 2. **Smarter Social Media Advertising:**
12
+
13
+ - **How it works:** The system logs a high number of `product_viewed` `Events` on advanced, power-style rackets. The `intelligence_agent` identifies this as a trend. It then instructs the `marketing_agent` to create a targeted ad campaign on social media featuring these specific rackets, aimed at users who match the `audience:advanced-player` profile.
14
+
15
+ - **Powerful Result:** Ad spend is drastically reduced and more effective. Instead of broadly targeting "padel players," Nine Padel targets a specific, validated interest group with the exact products they are already looking at, leading to higher click-through rates and lower acquisition costs.
16
+
17
+
18
+ ---
19
+
20
+ ### Converting Shoppers into Buyers 🛒
21
+
22
+ **Goal:** Create a frictionless, personalized path from browsing to checkout.
23
+
24
+ 1. **The Hyper-Personalized Racket Quiz:**
25
+
26
+ - **How it works:** A customer completes the quiz, which triggers a `quiz_completed` `Event`. This creates a `quiz_result` `Thing` permanently connected to that `customer`. When the customer returns to the site, a `sales_agent` immediately retrieves this `Thing` and customizes the homepage to showcase their top 3 recommended rackets.
27
+
28
+ - **Powerful Result:** The customer feels understood and valued. The store isn't just selling rackets; it's acting as a personal consultant. This builds trust and removes the paradox of choice, making the customer confident enough to click "Add to Cart."
29
+
30
+ 2. **Intelligent Abandoned Cart Recovery:**
31
+
32
+ - **How it works:** A customer adds a racket to their cart but doesn't complete the purchase. This is logged as a `product_added_to_cart` `Event` without a corresponding `order_placed` `Event`. After an hour, a `service_agent` analyzes the abandoned `shopping_cart` `Thing`. It sees a beginner racket and checks the `customer`'s history for `guide_viewed` events. It then sends a highly specific email: "Hi, I'm the Nine Padel assistant. I see you were looking at the Head Evo Sanyo, a great choice for improving control. Did you have any questions before you buy? Just reply to this email."
33
+
34
+ - **Powerful Result:** This replaces a generic, annoying "You forgot something!" email with a helpful, conversational intervention. It addresses potential hesitations, provides value, and has a much higher chance of recovering the sale.
35
+
36
+ 3. **Dynamic Bundling at Checkout:**
37
+
38
+ - **How it works:** When a customer proceeds to checkout, the `sales_agent` analyzes the `product_racket` `Thing` in their cart. It queries all past `order` `Things` to see what other items are most frequently bought with that specific racket. It then generates a one-time offer: "Wait! Players who bought the Nox AT10 also bought these high-performance grips and balls. Add them now for 15% off."
39
+
40
+ - **Powerful Result:** This is an upsell that feels like a helpful suggestion, not a pushy sales tactic. It increases the average order value by leveraging the collective intelligence of the entire customer base.
41
+
42
+
43
+ ---
44
+
45
+ ### Growing Customers for Life 🤝
46
+
47
+ **Goal:** Turn one-time buyers into a loyal community and repeat customers.
48
+
49
+ 1. **Proactive, Personalized Ownership Experience:**
50
+
51
+ - **How it works:** A `customer` is linked via a `Connection` to the specific `product_racket` they purchased. Six months after the `order_shipped` `Event`, the `marketing_agent` automatically sends them an email: "It's been 6 months with your Bullpadel Vertex. To maintain its peak performance, it's time to consider a new grip. Here are the top-rated grips that fit your racket."
52
+
53
+ - **Powerful Result:** The customer relationship doesn't end at the sale. The store becomes a long-term partner in their padel journey, building immense loyalty and creating natural opportunities for repeat purchases of accessories and future upgrades.
54
+
55
+ 2. **Automated Community Building:**
56
+
57
+ - **How it works:** When a customer buys a racket from the "Nox" `brand`, a `Connection` is automatically created making them a `member_of` the "Nox Players Club" `community` `Thing`. This private hub contains exclusive guides, tips from pros who use Nox, and a forum for other Nox owners.
58
+
59
+ - **Powerful Result:** The store builds a powerful moat against competitors. Customers are no longer just buying a product; they are joining an identity and a community. This fosters an emotional connection to the brand and the store, making them the default choice for all future padel needs.
60
+
61
+ # Most Valuable Customers
62
+ ### 1. The Whale 🐋
63
+
64
+ **Who they are:** The customer with the highest Lifetime Value (LTV). They buy expensive rackets and frequently purchase top-tier gear.
65
+
66
+ How the Ontology Finds Them:
67
+
68
+ The intelligence_agent queries all customer Things. For each one, it follows the places Connection to find every order Thing they've ever created. It then sums the total_price property from all their orders to calculate a precise LTV.
69
+
70
+ Actionable Insight:
71
+
72
+ These customers should receive a "white glove" experience. The system can automatically flag them to receive:
73
+
74
+ - A personal thank you email from the founder.
75
+
76
+ - Early access to new, high-end product releases.
77
+
78
+ - An exclusive invitation to a `community` `Thing` called the "Nine Padel Platinum Club."
79
+
80
+
81
+ ---
82
+
83
+ ### 2. The Loyalist 👑
84
+
85
+ **Who they are:** The repeat buyer. They may not have the highest LTV, but their purchase frequency is high. They consistently buy accessories like balls, grips, and apparel.
86
+
87
+ How the Ontology Finds Them:
88
+
89
+ The system analyzes the Events log for each customer. It counts the number of order_placed Events over time. A customer with a high count and a short time between events is identified as a Loyalist, especially if their order Things contain product_accessory Things.
90
+
91
+ Actionable Insight:
92
+
93
+ Loyalists are the foundation of your business. The ontology enables you to automate a loyalty program:
94
+
95
+ - After their third purchase, the system automatically sends them a 15% discount code for their next accessory purchase.
96
+
97
+ - The `marketing_agent` can create a subscription-style offer: "Never run out of grips again. Get a 3-pack delivered every 3 months and save 20%."
98
+
99
+
100
+ ---
101
+
102
+ ### 3. The Evangelist 📣
103
+
104
+ **Who they are:** The brand advocate. They might not be your biggest spenders, but they are your most powerful marketers. They leave positive reviews and drive new traffic to your site.
105
+
106
+ How the Ontology Finds Them:
107
+
108
+ The system finds customers who have multiple writes Connections to customer_review Things, especially those with a 5-star rating. If you implement a referral program, it can also track customers who have the most referred_by Connections, linking them to new customers they brought in.
109
+
110
+ Actionable Insight:
111
+
112
+ Evangelists should be empowered and rewarded for their advocacy.
113
+
114
+ - The system can automatically email them: "We love your reviews! Would you be willing to provide a video testimonial in exchange for a £50 gift card?"
115
+
116
+ - They can be given a unique, shareable discount code. The `intelligence_agent` can track its usage and reward the Evangelist with store credit for every new customer acquired.
117
+
118
+
119
+ ---
120
+
121
+ ### 4. The Profit Driver 💰
122
+
123
+ **Who they are:** The customer who consistently buys high-margin products. They don't wait for sales; they buy full-price items, bundles, and premium accessories.
124
+
125
+ How the Ontology Finds Them:
126
+
127
+ The intelligence_agent analyzes the contents of every order Thing. It filters for orders that contain product Things with the on_sale:false property or are linked to Knowledge labels like category:bundle or type:premium_accessory. It then identifies the customers who most frequently place these types of orders.
128
+
129
+ Actionable Insight:
130
+
131
+ These customers are your most profitable segment. You can maximize their value without offering discounts.
132
+
133
+ - Instead of price reductions, the system can offer them value-added bonuses like free, expedited shipping on their next order.
134
+
135
+ - When a new, high-margin product arrives, they are the first group to be notified.
136
+
137
+
138
+ This isn't just data; it's a dynamic playbook for customer relationship management. The ontology allows you to see the _story_ behind each customer and engage with them in the most intelligent and effective way possible.
@@ -0,0 +1,167 @@
1
+ ## The Six-Dimension Data Structure for Nine Padel
2
+
3
+ This is the blueprint for all your data, from static content files in your Astro project to dynamic data handled by Cloudflare.
4
+
5
+ ### 1. The `Group`: Your Business Core
6
+
7
+ This is the root of everything. It's a single, foundational object that defines the entire application's context.
8
+
9
+ - **The Thing:** A single `group` `Thing` named **"Nine Padel Store"**.
10
+
11
+ - **Implementation:** This can be a simple JSON object in your project's configuration (`src/config.ts`) that holds site-wide metadata like the store name, currency (GBP), and domain.
12
+
13
+
14
+ ### 2. The `People`: Your Users
15
+
16
+ This dimension defines the actors interacting with your site.
17
+
18
+ - **The Things:**
19
+
20
+ - `customer`: Represents any visitor. They start as an **anonymous user** (identified by a session ID) and become a **known customer** upon login or purchase.
21
+
22
+ - `staff`: Represents an administrator who can manage content.
23
+
24
+ - **Implementation:**
25
+
26
+ - **Customers:** Stored in persistent storage. A user's session ID and authentication state are managed via Cloudflare Workers and browser cookies.
27
+
28
+ - **Staff:** Can be a simple list of users in your config for a basic setup, or a table in the database for a multi-user admin panel.
29
+
30
+
31
+ ### 3. The `Things`: Your Content and Commerce Objects
32
+
33
+ These are the "nouns" of your website. In Astro, most of these will live in your `src/content/` directory as content collections.
34
+
35
+ - **The Things:**
36
+
37
+ - `product`: Rackets, bags, shoes, etc. **This is your core collection.**
38
+
39
+ - `guide`: Buying guides, blog posts, and technique articles.
40
+
41
+ - `brand`: Brand-specific pages with their story and associated products.
42
+
43
+ - `review`: User-submitted reviews.
44
+
45
+ - `shopping_cart`: A temporary object holding the items a user intends to buy.
46
+
47
+ - `order`: A permanent record of a completed purchase.
48
+
49
+ - **Implementation:**
50
+
51
+ - **Static Content (`src/content/`):**
52
+
53
+ - `/products/*.md`: Each file is a `product` `Thing`.
54
+
55
+ - `/guides/*.md`: Each file is a `guide` `Thing`.
56
+
57
+ - `/brands/*.md`: Each file is a `brand` `Thing`.
58
+
59
+ - **Dynamic Data (handled by Cloudflare):**
60
+
61
+ - **`shopping_cart`:** A JSON object stored in **Cloudflare KV**, keyed by the user's session ID. It's fast, cheap, and perfect for transient data.
62
+
63
+ - **`order` & `review`:** Records created via API calls to a **Cloudflare Worker**, which then saves them to a **Cloudflare D1** database.
64
+
65
+
66
+ ### 4. The `Connections`: How Everything Relates
67
+
68
+ These relationships bring your content to life, allowing you to build a rich, interconnected site.
69
+
70
+ - **The Relationships:**
71
+
72
+ - `product` **`manufactured_by`** `brand`.
73
+
74
+ - `review` **`is_about`** `product`.
75
+
76
+ - `customer` **`places`** `order`.
77
+
78
+ - `order` **`contains`** `product`.
79
+
80
+ - **Implementation:**
81
+
82
+ - These connections are defined directly within your content files using Astro's content relationships. For example, in a `product`'s frontmatter, you'd have a `brand: 'bullpadel'` slug that links to the corresponding `brand` file.
83
+
84
+
85
+ ### 5. The `Events`: The Story of User Interaction
86
+
87
+ This is the real-time stream of every action taken on your site. It's the fuel for all your analytics and automation.
88
+
89
+ - **The Actions:**
90
+
91
+ - `page_viewed`, `product_viewed`, `filter_applied`, `add_to_cart`, `order_placed`.
92
+
93
+ - **Implementation:**
94
+
95
+ - A lightweight JavaScript snippet on your Astro pages sends these events to a dedicated **Cloudflare Worker endpoint** (e.g., `/api/log-event`).
96
+
97
+ - This worker validates the event and writes it to a table in your **Cloudflare D1** database. This process is incredibly fast and doesn't slow down the user experience.
98
+
99
+
100
+ ### 6. The `Knowledge`: Your Site's Brain (The Frontmatter)
101
+
102
+ This is the metadata that makes your site intelligent and dynamic. In Astro, this is almost entirely handled by the **frontmatter** of your markdown files.
103
+
104
+ - **The Labels:**
105
+
106
+ - For a `product`: `skill_level`, `racket_style`, `player_trait`, `shape`.
107
+
108
+ - For a `guide`: `topic`, `relates_to_skill`.
109
+
110
+ - **Implementation:**
111
+
112
+ - Inside `src/content/products/bullpadel-vertex.md`:
113
+
114
+ YAML
115
+
116
+ ```
117
+ ---
118
+ name: "Bullpadel Vertex 04"
119
+ price: 250
120
+ brand: 'bullpadel' # This creates the Connection
121
+ knowledge:
122
+ skill_level: 'advanced'
123
+ racket_style: 'power'
124
+ shape: 'diamond'
125
+ player_trait: null # Not specifically for elbow pain
126
+ ---
127
+ Product description goes here...
128
+ ```
129
+
130
+
131
+ ---
132
+
133
+ ## The Loops: How Your Website Gets Smarter
134
+
135
+ This is how you turn your static site into a dynamic, self-improving engine.
136
+
137
+ ### The Attract Loop: From Search to Session 🔎
138
+
139
+ 1. **Action:** You create a new `guide` file: `src/content/guides/choosing-a-beginner-racket.md`.
140
+
141
+ 2. **Knowledge:** You fill its frontmatter: `topic: 'equipment_selection'`, `relates_to_skill: 'beginner'`.
142
+
143
+ 3. **Connection:** In the guide, you link to three specific `product` `Things` that have the `skill_level: 'beginner'` `Knowledge` label.
144
+
145
+ 4. **Result:** Astro builds a perfectly optimized static HTML page. A user searching Google finds this expert content. They click the link, landing on your site and logging a `page_viewed` `Event`. The loop completes when they click on a recommended racket, logging a `product_viewed` `Event` and starting their conversion journey.
146
+
147
+
148
+ ### The Convert Loop: From Browser to Buyer 🛒
149
+
150
+ 1. **Action:** A visitor is on your product gallery page. They use the UI to filter by `skill_level: 'intermediate'`.
151
+
152
+ 2. **Event:** A `filter_applied` `Event` is logged to your D1 database.
153
+
154
+ 3. **Knowledge:** Astro's front-end JavaScript instantly filters the displayed products by reading the `knowledge.skill_level` frontmatter from all `product` `Things`.
155
+
156
+ 4. **Result:** The user sees a perfectly curated list, finds the right racket, adds it to their cart (`add_to_cart` event), and completes the checkout via a Cloudflare Worker that creates a permanent `order` `Thing`. The loop completes as their anonymous session is now connected to a `customer` `Thing` with a purchase history.
157
+
158
+
159
+ ### The Grow Loop: From Buyer to Loyalist 👑
160
+
161
+ 1. **Action:** A scheduled Cloudflare Worker runs once a day to analyze the `events` table in your D1 database.
162
+
163
+ 2. **Intelligence:** The worker discovers an **insight**: "75% of customers who buy a `product` with `skill_level: 'advanced'` also view a `guide` with `topic: 'technique'`."
164
+
165
+ 3. **Automation:** The system now has a new rule. When a new `order_placed` `Event` occurs for an advanced racket, it triggers a 7-day countdown. After 7 days, another worker sends a personalized email: "Ready to master your new racket? Here are 3 advanced technique guides our pros recommend."
166
+
167
+ 4. **Result:** The customer is re-engaged with valuable content, pulling them back to the site. This builds immense loyalty and creates opportunities for follow-up purchases of accessories. The loop completes when they return and start a new session.