AI Relationship Discovery
Powered by OpenAIDiscover hidden connections between your Firestore collections and get AI-powered schema optimization suggestions to fix vibe coding anti-patterns using advanced analysis of field patterns, naming conventions, and data samples.
Our AI system analyzes your Firestore collections using GPT-4 to identify potential relationships based on field names, data types, and actual content patterns. It also detects common vibe coding anti-patterns where AI tools incorrectly apply relational database thinking to NoSQL, providing confidence scores and detailed explanations for each discovered relationship and optimization.
Our AI specifically detects and fixes common anti-patterns created by AI coding tools like Cursor, Claude, and Replit when they incorrectly apply relational database patterns to NoSQL Firestore databases.
Common Vibe Coding Issues Fixed:
- ❌Separate Collections: AI creates `users` and `userProfiles` when data should be embedded
- ❌Excessive Reads: Requiring 2+ reads per query instead of 1 optimized read
- ❌Higher Costs: Unnecessary Firestore billing from inefficient queries
- ✅Our Solution: Suggests embedded document structures with cost analysis
Getting Started
Navigate to AI Relationships
From the Database Explorer, switch to the "AI Relationships" tab. You'll see all available collections in your Firebase project ready for analysis.
Select Collections for Analysis
Choose 2-10 collections that you suspect might be related. The AI will analyze relationships between all selected collections:
- Start small - Begin with 2-3 collections for faster results
- Related data - Select collections that logically might connect
- Limit selection - Maximum 10 collections to avoid timeouts
Configure Analysis Settings
Adjust the analysis depth and sample size based on your needs:
Analysis Depth Options
- Shallow: Quick analysis focusing on obvious patterns (fastest)
- Medium: Balanced analysis with good accuracy (recommended)
- Deep: Comprehensive analysis including subtle patterns (slowest)
Review Discovered Relationships
Once analysis completes, review the discovered relationships with their confidence scores and explanations. Use this information to understand your data structure better.
Review Vibe Coding Optimizations
Pay special attention to any vibe coding anti-patterns detected by the AI. These optimizations can significantly reduce your Firestore costs and improve performance:
- Priority fixes - Address vibe coding issues first (marked with AI tool badges)
- Cost analysis - Review percentage savings from each optimization
- Implementation guides - Follow step-by-step migration instructions
- Schema comparison - Use before/after views to understand changes
Understanding Results
High Confidence (80-100%)
Strong evidence of relationship. Clear field name matches, consistent data types, and logical connection patterns. These relationships are very likely accurate.
Medium Confidence (50-79%)
Moderate evidence of relationship. Some matching patterns but may require manual verification. Good starting point for investigation.
Low Confidence (0-49%)
Weak evidence or speculative relationship. May be coincidental patterns. Use caution and verify manually before relying on these connections.
Foreign Key Relationships
Fields that reference documents in other collections (e.g., userId, productId, categoryId)
Hierarchical Relationships
Parent-child relationships where one collection contains subcategories of another
Many-to-Many Relationships
Junction tables or collections that link multiple entities together
Semantic Relationships
Logical connections based on field names and data patterns that suggest related business concepts
Embed Collection
Combines separate collections into embedded documents. Most common vibe coding fix. Example: `users` + `userProfiles` → embedded `users` with profile data.
Denormalize Field
Duplicates frequently accessed data to reduce queries. Good for read-heavy data. Example: Adding user name to posts collection to avoid user lookup.
Merge Collections
Combines multiple related collections into a single collection with type fields. Good for similar data structures that were unnecessarily separated.
Advanced Configuration
Sample Size
Analysis Depth
Best Practices
- ✓Use consistent naming conventions in your collections for better detection
- ✓Include collections with obvious relationships first to validate AI accuracy
- ✓Analyze related collections together (e.g., users, orders, products)
- ✓Re-run analysis after significant schema changes
- 💡Ensure collections have sufficient sample data (at least 10-20 documents)
- 💡Use descriptive field names that indicate their purpose (userId vs uid)
- 💡Include representative data that shows typical usage patterns
- ⚡Start with high-confidence, low-complexity optimizations first
- ⚡Test optimizations in development before applying to production
- ⚡Use the migration guides for step-by-step implementation instructions
- ⚡Monitor Firestore usage after applying optimizations to verify cost savings
Troubleshooting
AI analysis not available
Ensure your subscription includes AI features and that OpenAI API is properly configured. Check the status indicator in the AI Relationships tab.
No relationships found
Try selecting different collections, increasing sample size, or using deeper analysis. Some datasets may genuinely have no detectable relationships.
Analysis timeout
Reduce the number of selected collections (try 3-5 instead of 10) or decrease the sample size. Large analyses may need to be split into smaller groups.
Low confidence results
Increase analysis depth, ensure collections have meaningful field names, or verify that the collections actually contain related data.
No vibe coding optimizations found
Your schema may already be well-optimized for NoSQL! This is good news. If you suspect issues, try analyzing collections created by AI tools specifically.
Optimization seems incorrect
Check the confidence score and explanation. Not all optimizations fit every use case. Consider your specific read/write patterns and data access requirements.
Here's how AI might analyze relationships and detect vibe coding issues in a typical e-commerce database:
Relationship Discovery:
Strong relationship: orders.userId field matches users collection document IDs
Likely relationship: orders.items.productId appears to reference products collection
Clear relationship: products.categoryId field matches categories collection structure
Vibe Coding Issues Detected:
Separate collections should be embedded. Cost saving: 50% (2 reads → 1 read)
Order items should be embedded in orders. Cost saving: 67% (3 reads → 1 read)
Enhance Your Analysis
Combine AI relationship discovery with schema visualization and data browsing for a complete understanding of your database structure.