SEPARATE DATABASE SETUP
Comprehensive guidelines for AI-assisted development within the Editor platform
🔥 Separate Database Setup Guide
Perfect isolation: Icons database separate from your main app data
🎯 Why Separate Database?
Creating a dedicated "icons" database within your existing GoGrab-space project gives you:
✅ Complete isolation - Icon data won't interfere with existing collections
✅ Same project benefits - Share auth, billing, and management
✅ Optimized for icons - Custom indexes and rules for icon operations
✅ Risk-free experimentation - Test features without affecting main app
📊 Database Structure
📁 GoGrab-space Project:
├── 🗄️ (default) database
│ ├── ✅ button-presets/ (existing)
│ ├── ✅ widgets/ (existing)
│ └── ✅ btn-papi-1/ (existing)
│
└── 🗄️ icons database (NEW!)
├── 🆕 iconThemes/ (user color schemes)
├── 🆕 customIcons/ (team uploaded icons)
├── 🆕 iconAnalytics/ (usage tracking)
└── 🆕 teams/ (team management)
🚀 Step-by-Step Setup
Step 1: Create the Icons Database
In your Firebase Console (from your screenshot):
- Click the "Add database" button (circled in red)
Configure the new database:
- Database ID:
icons - Location: Choose the same region as your default database
- Security Rules: Start in Test mode (we'll secure it later)
- Database ID:
Click "Create"
Step 2: Update Your Firebase Configuration
Your configuration is already prepared! Just add your actual Firebase values:
// apps/ux-test/src/environments/firebase.config.ts
export const firebaseConfig = {
apiKey: "your-actual-api-key", // Get from Firebase Console
authDomain: "gograb-space.firebaseapp.com", // ✅ Already correct
projectId: "gograb-space", // ✅ Already correct
storageBucket: "gograb-space.appspot.com", // ✅ Already correct
messagingSenderId: "your-actual-sender-id", // Get from Firebase Console
appId: "your-actual-app-id", // Get from Firebase Console
measurementId: "your-measurement-id" // Optional, for Analytics
};
// Database configuration (already set up!)
export const DATABASE_CONFIG = {
MAIN_DATABASE: '(default)', // Your existing data
ICONS_DATABASE: 'icons' // New icon system database
};
Step 3: Update the Icon Showcase Component
// apps/ux-test/src/app/features/icons-showcase/icons-showcase.component.ts
async ngOnInit() {
// Initialize Firebase sync with separate database
await this.firebaseSync.initialize(
firebaseConfig,
'current-user-id',
DATABASE_CONFIG.ICONS_DATABASE // 🔥 Use separate database
);
// ... rest of initialization
}
Step 4: Set Up Security Rules for Icons Database
Create separate security rules for the icons database:
// firestore.rules (for icons database)
rules_version = '2';
service cloud.firestore {
match /databases/icons/documents {
// Icon themes - user-based access
match /iconThemes/{themeId} {
// Public themes readable by all
allow read: if resource.data.isPublic == true;
// Private themes - owner only
allow read, write: if request.auth.uid == resource.data.userId;
// Team themes - team members only
allow read: if resource.data.visibility == "team"
&& isTeamMember(resource.data.teamId);
// Anyone can create themes
allow create: if request.auth != null;
}
// Custom icons - team-based access
match /customIcons/{iconId} {
allow read: if true; // Icons are generally public
allow create, update: if request.auth != null;
allow delete: if request.auth.uid == resource.data.uploadedBy;
}
// Teams management
match /teams/{teamId} {
allow read, write: if request.auth != null
&& request.auth.uid in resource.data.members;
}
// Analytics - write by authenticated users, read by team admins
match /iconAnalytics/{analyticsId} {
allow create: if request.auth != null;
allow read: if isTeamAdmin();
}
// Helper functions
function isTeamMember(teamId) {
return exists(/databases/icons/documents/teams/$(teamId))
&& request.auth.uid in get(/databases/icons/documents/teams/$(teamId)).data.members;
}
function isTeamAdmin() {
// Add your admin logic here
return request.auth != null;
}
}
}
🔧 Collection Schema for Icons Database
iconThemes Collection
{
id: "theme_user123_dark_heart",
name: "Dark Heart Theme",
iconId: "svg/static/heart",
multiColor: {
primary: "#ff4757",
secondary: "#2f3542"
},
userId: "user123",
teamId: "design-team",
isPublic: true,
visibility: "team",
createdAt: timestamp,
usage: 47
}
customIcons Collection
{
id: "custom_logo_company",
name: "Company Logo",
svgContent: "<svg>...</svg>",
category: "brand",
uploadedBy: "user123",
teamId: "design-team",
downloadUrl: "https://storage.googleapis.com/...",
isApproved: true,
createdAt: timestamp
}
🎯 Benefits of This Approach
✅ Perfect Isolation
- No interference with existing data
- Independent backups and disaster recovery
- Separate monitoring and analytics
- Isolated testing environment
✅ Optimized Performance
- Custom indexes for icon searches
- Optimized queries for theme operations
- Dedicated resources for icon system
- Better scalability planning
✅ Simplified Management
- Clear separation of responsibilities
- Independent deployments of icon features
- Easier debugging and troubleshooting
- Clean data model without legacy constraints
🚀 Deployment Steps
- Create the database (via Firebase Console)
- Update your config with actual Firebase values
- Deploy security rules:
firebase deploy --only firestore:rules --database=icons - Test the integration in your icon showcase
- Monitor usage and optimize as needed
📊 Monitoring & Analytics
The separate database allows you to:
- Track icon-specific metrics independently
- Monitor database performance for icon operations
- Set up alerts for icon system issues
- Analyze usage patterns without noise from main app
🎉 Result
You'll have:
- 🗄️ (default) database: Your existing app data (safe and untouched)
- 🗄️ icons database: Clean, optimized icon system
- 🔐 Shared authentication: Same users across both databases
- 💰 Single billing: One Firebase project, unified costs
- 🛠️ Unified management: Everything in one console
This is the cleanest, most professional approach! 🚀
Your icon system will be completely isolated while maintaining all the benefits of your existing Firebase project setup.