feat: Add Directus schema setup script and documentation
This commit is contained in:
206
DIRECTUS_SETUP_NEEDED.md
Normal file
206
DIRECTUS_SETUP_NEEDED.md
Normal file
@@ -0,0 +1,206 @@
|
||||
# 🔧 DIRECTUS SETUP - WHAT'S NEEDED
|
||||
|
||||
## ✅ **What's Already Done**
|
||||
|
||||
1. ✅ **Directus is running** and healthy
|
||||
2. ✅ **Collections created**:
|
||||
- `sites` - WordPress sites
|
||||
- `posts` - Generated content
|
||||
- `pages` - Static pages
|
||||
- `leads` - Lead capture
|
||||
- `avatar_intelligence` - Avatar data
|
||||
|
||||
3. ✅ **JSON Data Files** in container at `/directus/data/`:
|
||||
- avatar_intelligence.json (5.4K)
|
||||
- avatar_variants.json (8.5K)
|
||||
- geo_intelligence.json (2.1K)
|
||||
- spintax_dictionaries.json (1.1K)
|
||||
- cartesian_patterns.json (2.1K)
|
||||
- offer_blocks_universal.json (14.1K)
|
||||
- offer_blocks_avatar_personalized.json (72.3K)
|
||||
- offer_blocks_cartesian_engine.json (1.1K)
|
||||
- master_meta.json (2.3K)
|
||||
|
||||
4. ✅ **API Token**: `oGn-0AZjenB900pfzQYH8zCbFwGw7flU`
|
||||
|
||||
---
|
||||
|
||||
## ❌ **What Needs to Be Done in Directus UI**
|
||||
|
||||
The API token doesn't have permission to create fields, so you need to finish the schema setup manually.
|
||||
|
||||
### **Step 1: Log into Directus**
|
||||
- URL: https://spark.jumpstartscaling.com/admin
|
||||
- Email: `somescreenname@gmail.com`
|
||||
- Password: `Idk@2025lol`
|
||||
|
||||
---
|
||||
|
||||
### **Step 2: Add Fields to Collections**
|
||||
|
||||
#### **For `sites` collection:**
|
||||
1. Go to Settings → Data Model → `sites`
|
||||
2. Add these fields:
|
||||
- `id` (UUID, Primary Key, Auto-generate)
|
||||
- `name` (String, Required)
|
||||
- `url` (String, Required)
|
||||
- `wp_username` (String)
|
||||
- `wp_app_password` (String, Hidden)
|
||||
- `status` (Dropdown: active, paused, archived)
|
||||
- `created_at` (Timestamp, Auto-create)
|
||||
|
||||
#### **For `posts` collection:**
|
||||
1. Go to Settings → Data Model → `posts`
|
||||
2. Add these fields:
|
||||
- `id` (UUID, Primary Key, Auto-generate)
|
||||
- `title` (String, Required)
|
||||
- `content` (WYSIWYG/Rich Text)
|
||||
- `excerpt` (Text)
|
||||
- `status` (Dropdown: draft, published)
|
||||
- `site_id` (Many-to-One relationship to `sites`)
|
||||
- `avatar_key` (String)
|
||||
- `created_at` (Timestamp, Auto-create)
|
||||
|
||||
#### **For `pages` collection:**
|
||||
1. Go to Settings → Data Model → `pages`
|
||||
2. Add these fields:
|
||||
- `id` (UUID, Primary Key, Auto-generate)
|
||||
- `title` (String, Required)
|
||||
- `slug` (String, Required, Unique)
|
||||
- `content` (WYSIWYG/Rich Text)
|
||||
- `site_id` (Many-to-One relationship to `sites`)
|
||||
- `status` (Dropdown: draft, published)
|
||||
|
||||
#### **For `leads` collection:**
|
||||
1. Go to Settings → Data Model → `leads`
|
||||
2. Add these fields:
|
||||
- `id` (UUID, Primary Key, Auto-generate)
|
||||
- `email` (String, Required)
|
||||
- `name` (String)
|
||||
- `phone` (String)
|
||||
- `source` (String)
|
||||
- `site_id` (Many-to-One relationship to `sites`)
|
||||
- `created_at` (Timestamp, Auto-create)
|
||||
|
||||
#### **For `avatar_intelligence` collection:**
|
||||
1. Go to Settings → Data Model → `avatar_intelligence`
|
||||
2. Add these fields:
|
||||
- `id` (Integer, Primary Key, Auto-increment)
|
||||
- `avatar_key` (String, Required, Unique)
|
||||
- `base_name` (String)
|
||||
- `wealth_cluster` (String)
|
||||
- `business_niches` (JSON)
|
||||
- `data` (JSON) - Full avatar data
|
||||
|
||||
---
|
||||
|
||||
### **Step 3: Import JSON Data**
|
||||
|
||||
#### **Option A: Via Directus UI (Recommended)**
|
||||
1. Go to each collection
|
||||
2. Click "Import" button
|
||||
3. Upload the corresponding JSON file from your local `backend/data/` folder
|
||||
|
||||
#### **Option B: Via SSH (Advanced)**
|
||||
```bash
|
||||
# SSH into the server
|
||||
ssh root@72.61.15.216
|
||||
|
||||
# Access the Directus container
|
||||
docker exec -it directus-i8cswkos04c4s08404ok0ws4-022108320046 bash
|
||||
|
||||
# Files are at /directus/data/
|
||||
ls -la /directus/data/
|
||||
|
||||
# Use Directus CLI or API to import
|
||||
# (You'll need to write a custom import script)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### **Step 4: Set Permissions**
|
||||
|
||||
1. Go to Settings → Access Control → Public Role
|
||||
2. Enable read access for:
|
||||
- `posts` (published only)
|
||||
- `pages` (published only)
|
||||
- `sites` (basic info only)
|
||||
|
||||
3. For the API token role:
|
||||
- Enable full CRUD access to all collections
|
||||
- This allows the frontend to create/read/update/delete
|
||||
|
||||
---
|
||||
|
||||
### **Step 5: Test the API**
|
||||
|
||||
After setup, test with:
|
||||
|
||||
```bash
|
||||
# List sites
|
||||
curl -H "Authorization: Bearer oGn-0AZjenB900pfzQYH8zCbFwGw7flU" \
|
||||
https://spark.jumpstartscaling.com/items/sites
|
||||
|
||||
# List posts
|
||||
curl -H "Authorization: Bearer oGn-0AZjenB900pfzQYH8zCbFwGw7flU" \
|
||||
https://spark.jumpstartscaling.com/items/posts
|
||||
|
||||
# Create a test site
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer oGn-0AZjenB900pfzQYH8zCbFwGw7flU" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "Test Site", "url": "https://example.com", "status": "active"}' \
|
||||
https://spark.jumpstartscaling.com/items/sites
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 **After Setup is Complete**
|
||||
|
||||
Once the schema is set up and data is imported:
|
||||
|
||||
1. ✅ **Jumpstart Wizard** will be fully functional
|
||||
- https://launch.jumpstartscaling.com/admin/sites/jumpstart
|
||||
|
||||
2. ✅ **Command Station** will show real data
|
||||
- https://launch.jumpstartscaling.com/admin
|
||||
|
||||
3. ✅ **Content Factory** will generate with real avatars
|
||||
- https://launch.jumpstartscaling.com/admin/factory
|
||||
|
||||
4. ✅ **All admin pages** will connect to Directus
|
||||
|
||||
---
|
||||
|
||||
## 📚 **Quick Reference**
|
||||
|
||||
### **Directus Admin**
|
||||
- URL: https://spark.jumpstartscaling.com/admin
|
||||
- Email: `somescreenname@gmail.com`
|
||||
- Password: `Idk@2025lol`
|
||||
|
||||
### **API Token**
|
||||
```
|
||||
oGn-0AZjenB900pfzQYH8zCbFwGw7flU
|
||||
```
|
||||
|
||||
### **Collections Created**
|
||||
- ✅ sites
|
||||
- ✅ posts
|
||||
- ✅ pages
|
||||
- ✅ leads
|
||||
- ✅ avatar_intelligence
|
||||
|
||||
### **Data Files Ready**
|
||||
- ✅ All 9 JSON files in `/directus/data/`
|
||||
|
||||
---
|
||||
|
||||
## ⏭️ **Next Steps**
|
||||
|
||||
1. **Log into Directus UI** and add fields to collections (15 minutes)
|
||||
2. **Import JSON data** via UI or API (5 minutes)
|
||||
3. **Set permissions** for API token (5 minutes)
|
||||
4. **Test the Jumpstart Wizard** (it will work!)
|
||||
|
||||
**Total time: ~25 minutes to complete setup** ⏱️
|
||||
237
setup-directus-schema.sh
Executable file
237
setup-directus-schema.sh
Executable file
@@ -0,0 +1,237 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Directus Schema Setup and Data Import Script
|
||||
# This script creates all necessary collections and imports JSON data
|
||||
|
||||
DIRECTUS_URL="https://spark.jumpstartscaling.com"
|
||||
TOKEN="oGn-0AZjenB900pfzQYH8zCbFwGw7flU"
|
||||
|
||||
echo "🚀 Setting up Directus Schema and Importing Data..."
|
||||
echo ""
|
||||
|
||||
# Function to create a collection
|
||||
create_collection() {
|
||||
local collection_name=$1
|
||||
local schema=$2
|
||||
|
||||
echo "📦 Creating collection: $collection_name"
|
||||
|
||||
curl -k -X POST "$DIRECTUS_URL/collections" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$schema" 2>/dev/null
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Function to create a field
|
||||
create_field() {
|
||||
local collection=$1
|
||||
local field_data=$2
|
||||
|
||||
curl -k -X POST "$DIRECTUS_URL/fields/$collection" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$field_data" 2>/dev/null
|
||||
}
|
||||
|
||||
# 1. Create avatar_intelligence collection
|
||||
echo "Creating avatar_intelligence collection..."
|
||||
create_collection "avatar_intelligence" '{
|
||||
"collection": "avatar_intelligence",
|
||||
"meta": {
|
||||
"icon": "person",
|
||||
"note": "Avatar intelligence data for content personalization"
|
||||
}
|
||||
}'
|
||||
|
||||
create_field "avatar_intelligence" '{
|
||||
"field": "id",
|
||||
"type": "integer",
|
||||
"meta": {"interface": "input", "special": ["auto-increment"]},
|
||||
"schema": {"is_primary_key": true, "has_auto_increment": true}
|
||||
}'
|
||||
|
||||
create_field "avatar_intelligence" '{
|
||||
"field": "avatar_key",
|
||||
"type": "string",
|
||||
"meta": {"interface": "input", "required": true},
|
||||
"schema": {"is_unique": true}
|
||||
}'
|
||||
|
||||
create_field "avatar_intelligence" '{
|
||||
"field": "data",
|
||||
"type": "json",
|
||||
"meta": {"interface": "input-code", "options": {"language": "json"}}
|
||||
}'
|
||||
|
||||
# 2. Create sites collection
|
||||
echo "Creating sites collection..."
|
||||
create_collection "sites" '{
|
||||
"collection": "sites",
|
||||
"meta": {
|
||||
"icon": "language",
|
||||
"note": "Managed WordPress sites"
|
||||
}
|
||||
}'
|
||||
|
||||
create_field "sites" '{
|
||||
"field": "id",
|
||||
"type": "uuid",
|
||||
"meta": {"interface": "input", "readonly": true},
|
||||
"schema": {"is_primary_key": true}
|
||||
}'
|
||||
|
||||
create_field "sites" '{
|
||||
"field": "name",
|
||||
"type": "string",
|
||||
"meta": {"interface": "input", "required": true}
|
||||
}'
|
||||
|
||||
create_field "sites" '{
|
||||
"field": "url",
|
||||
"type": "string",
|
||||
"meta": {"interface": "input", "required": true}
|
||||
}'
|
||||
|
||||
create_field "sites" '{
|
||||
"field": "status",
|
||||
"type": "string",
|
||||
"meta": {"interface": "select-dropdown", "options": {"choices": [
|
||||
{"text": "Active", "value": "active"},
|
||||
{"text": "Paused", "value": "paused"},
|
||||
{"text": "Archived", "value": "archived"}
|
||||
]}}
|
||||
}'
|
||||
|
||||
# 3. Create posts collection
|
||||
echo "Creating posts collection..."
|
||||
create_collection "posts" '{
|
||||
"collection": "posts",
|
||||
"meta": {
|
||||
"icon": "article",
|
||||
"note": "Generated content posts"
|
||||
}
|
||||
}'
|
||||
|
||||
create_field "posts" '{
|
||||
"field": "id",
|
||||
"type": "uuid",
|
||||
"meta": {"interface": "input", "readonly": true},
|
||||
"schema": {"is_primary_key": true}
|
||||
}'
|
||||
|
||||
create_field "posts" '{
|
||||
"field": "title",
|
||||
"type": "string",
|
||||
"meta": {"interface": "input", "required": true}
|
||||
}'
|
||||
|
||||
create_field "posts" '{
|
||||
"field": "content",
|
||||
"type": "text",
|
||||
"meta": {"interface": "input-rich-text-html"}
|
||||
}'
|
||||
|
||||
create_field "posts" '{
|
||||
"field": "status",
|
||||
"type": "string",
|
||||
"meta": {"interface": "select-dropdown", "options": {"choices": [
|
||||
{"text": "Draft", "value": "draft"},
|
||||
{"text": "Published", "value": "published"}
|
||||
]}}
|
||||
}'
|
||||
|
||||
create_field "posts" '{
|
||||
"field": "site_id",
|
||||
"type": "uuid",
|
||||
"meta": {"interface": "select-dropdown-m2o", "display": "related-values"}
|
||||
}'
|
||||
|
||||
# 4. Create pages collection
|
||||
echo "Creating pages collection..."
|
||||
create_collection "pages" '{
|
||||
"collection": "pages",
|
||||
"meta": {
|
||||
"icon": "description",
|
||||
"note": "Static pages"
|
||||
}
|
||||
}'
|
||||
|
||||
create_field "pages" '{
|
||||
"field": "id",
|
||||
"type": "uuid",
|
||||
"meta": {"interface": "input", "readonly": true},
|
||||
"schema": {"is_primary_key": true}
|
||||
}'
|
||||
|
||||
create_field "pages" '{
|
||||
"field": "title",
|
||||
"type": "string",
|
||||
"meta": {"interface": "input", "required": true}
|
||||
}'
|
||||
|
||||
create_field "pages" '{
|
||||
"field": "content",
|
||||
"type": "text",
|
||||
"meta": {"interface": "input-rich-text-html"}
|
||||
}'
|
||||
|
||||
# 5. Create leads collection
|
||||
echo "Creating leads collection..."
|
||||
create_collection "leads" '{
|
||||
"collection": "leads",
|
||||
"meta": {
|
||||
"icon": "contacts",
|
||||
"note": "Lead capture data"
|
||||
}
|
||||
}'
|
||||
|
||||
create_field "leads" '{
|
||||
"field": "id",
|
||||
"type": "uuid",
|
||||
"meta": {"interface": "input", "readonly": true},
|
||||
"schema": {"is_primary_key": true}
|
||||
}'
|
||||
|
||||
create_field "leads" '{
|
||||
"field": "email",
|
||||
"type": "string",
|
||||
"meta": {"interface": "input", "required": true}
|
||||
}'
|
||||
|
||||
create_field "leads" '{
|
||||
"field": "name",
|
||||
"type": "string",
|
||||
"meta": {"interface": "input"}
|
||||
}'
|
||||
|
||||
create_field "leads" '{
|
||||
"field": "source",
|
||||
"type": "string",
|
||||
"meta": {"interface": "input"}
|
||||
}'
|
||||
|
||||
create_field "leads" '{
|
||||
"field": "created_at",
|
||||
"type": "timestamp",
|
||||
"meta": {"interface": "datetime", "special": ["date-created"]}
|
||||
}'
|
||||
|
||||
echo ""
|
||||
echo "✅ Schema created successfully!"
|
||||
echo ""
|
||||
echo "📊 Now import the JSON data files manually via Directus UI or use the import script."
|
||||
echo ""
|
||||
echo "Data files location in container: /directus/data/"
|
||||
echo " - avatar_intelligence.json"
|
||||
echo " - avatar_variants.json"
|
||||
echo " - geo_intelligence.json"
|
||||
echo " - spintax_dictionaries.json"
|
||||
echo " - cartesian_patterns.json"
|
||||
echo " - offer_blocks_universal.json"
|
||||
echo " - offer_blocks_avatar_personalized.json"
|
||||
echo " - offer_blocks_cartesian_engine.json"
|
||||
echo " - master_meta.json"
|
||||
echo ""
|
||||
echo "🎉 Setup complete!"
|
||||
Reference in New Issue
Block a user