Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Latest commit

 

History

181 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Firebase MCP Integration for Trae AI

A comprehensive Firebase backend solution integrated with Trae AI's Model Context Protocol (MCP) for automated backend management, code generation, and deployment.

🚀 Features

  • 🔐 Enhanced Authentication: Complete Firebase Auth integration with social logins, profile management, and role-based access control
  • 📊 Smart Firestore Operations: Advanced CRUD operations with real-time subscriptions, batch processing, and intelligent caching
  • 📁 Intelligent Storage Management: File uploads with progress tracking, image processing, and automated optimization
  • ⚡ MCP-Enhanced Cloud Functions: Auto-generated functions with performance monitoring and intelligent scaling
  • 🛡️ Advanced Security Rules: Dynamic security rules with role-based access, data validation, and audit logging
  • 🚀 Automated CI/CD: Comprehensive deployment pipelines with testing, security scanning, and rollback capabilities
  • 📈 Performance Monitoring: Real-time analytics, error tracking, and performance optimization
  • 🔧 Developer Tools: Enhanced debugging, logging, and development workflow integration

📋 Prerequisites

  • Node.js 18+ and npm/yarn
  • Firebase CLI (npm install -g firebase-tools)
  • Trae AI environment with MCP support
  • Firebase project with enabled services (Auth, Firestore, Storage, Functions)

🛠️ Quick Start

1. Clone and Setup

# Clone the repository
git clone <your-repo-url>
cd ezy-zip

# Install dependencies
npm install
cd functions && npm install && cd ..

# Login to Firebase
firebase login

# Initialize Firebase project
firebase use --add

2. Environment Configuration

Create environment files:

# .env.local (Development)
FIREBASE_PROJECT_ID=your-dev-project
FIREBASE_API_KEY=your-dev-api-key
FIREBASE_AUTH_DOMAIN=your-dev-project.firebaseapp.com
FIREBASE_STORAGE_BUCKET=your-dev-project.appspot.com
FIREBASE_MESSAGING_SENDER_ID=123456789
FIREBASE_APP_ID=1:123456789:web:abcdef

# MCP Configuration
MCP_SERVER_NAME=firebase-mcp
MCP_AUTO_DEPLOY=true
MCP_ENVIRONMENT_SYNC=true
MCP_LOGGING_LEVEL=debug

# .env.production
FIREBASE_PROJECT_ID=your-prod-project
# ... production values
MCP_LOGGING_LEVEL=error

3. Deploy Security Rules

# Copy MCP-enhanced rules
cp firestore-mcp-rules.rules firestore.rules
cp storage-mcp-rules.rules storage.rules

# Deploy rules
firebase deploy --only firestore:rules,storage

4. Deploy Cloud Functions

# Build and deploy functions
cd functions
npm run build
cd ..
firebase deploy --only functions

5. Start Development

# Start local emulators
firebase emulators:start

# In another terminal, start your app
npm run dev

🏗️ Project Structure

ezy-zip/
├── src/
│   ├── lib/
│   │   ├── firebase-mcp-integration.ts    # Core MCP integration
│   │   ├── firestore-mcp-operations.ts    # Enhanced Firestore operations
│   │   └── storage-mcp-operations.ts      # Enhanced Storage operations
│   └── components/
│       └── auth/
│           └── FirebaseAuthProvider.tsx   # Authentication provider
├── functions/
│   └── src/
│       ├── index.ts                       # Function exports
│       └── mcp-enhanced-functions.ts      # MCP-enhanced functions
├── docs/
│   └── firebase-mcp-integration.md        # Comprehensive documentation
├── .github/
│   └── workflows/
│       └── firebase-mcp-deploy.yml        # CI/CD pipeline
├── firestore-mcp-rules.rules              # Enhanced Firestore rules
├── storage-mcp-rules.rules                # Enhanced Storage rules
├── firebase.json                          # Firebase configuration
└── README.md                              # This file

🔧 Usage Examples

Authentication

import { FirebaseAuthProvider, useAuth } from './src/components/auth/FirebaseAuthProvider';

function App() {
  return (
    <FirebaseAuthProvider>
      <LoginComponent />
    </FirebaseAuthProvider>
  );
}

function LoginComponent() {
  const { user, signInWithEmail, signInWithGoogle } = useAuth();
  
  if (user) {
    return <div>Welcome, {user.displayName}!</div>;
  }
  
  return (
    <div>
      <button onClick={() => signInWithEmail('user@example.com', 'password')}>
        Sign In with Email
      </button>
      <button onClick={signInWithGoogle}>
        Sign In with Google
      </button>
    </div>
  );
}

Firestore Operations

import { firestoreMCP } from './src/lib/firestore-mcp-operations';

// Create document
const user = await firestoreMCP.createDocument('users', {
  name: 'John Doe',
  email: 'john@example.com',
  createdAt: new Date()
});

// Real-time subscription
const unsubscribe = firestoreMCP.listenToDocument(
  'users',
  user.id,
  (userData) => console.log('User updated:', userData)
);

// Advanced query with pagination
const { documents, hasMore } = await firestoreMCP.getDocuments(
  'orders',
  {
    where: [['userId', '==', currentUser.uid]],
    orderBy: [['createdAt', 'desc']],
    limit: 20
  }
);

Storage Operations

import { storageMCP } from './src/lib/storage-mcp-operations';

// Upload with progress tracking
const uploadTask = storageMCP.uploadFileResumable(
  file,
  `users/${userId}/profile.jpg`,
  {
    onProgress: (progress) => setUploadProgress(progress.percentage),
    onComplete: (result) => console.log('Upload completed:', result.downloadUrl)
  }
);

// Image processing
const processedImage = await storageMCP.uploadAndProcessImage(
  imageFile,
  `images/${userId}/photo.jpg`,
  {
    resize: { width: 800, height: 600 },
    quality: 0.8,
    generateThumbnail: true
  }
);

🚀 Deployment

Automated Deployment (Recommended)

The project includes a comprehensive CI/CD pipeline that automatically deploys on pushes to main branches:

# Push to trigger deployment
git add .
git commit -m "feat: add new feature"
git push origin main

Manual Deployment

# Deploy everything
npm run deploy:prod

# Deploy specific services
firebase deploy --only functions
firebase deploy --only firestore:rules
firebase deploy --only storage

# Deploy to specific environment
firebase use production
firebase deploy

🔍 Monitoring and Debugging

View Logs

# Function logs
firebase functions:log

# Specific function logs
firebase functions:log --only functionName

# Real-time logs
firebase functions:log --follow

Local Development

# Start emulators
firebase emulators:start

# Access emulator UIs
# Firestore: http://localhost:4000/firestore
# Auth: http://localhost:4000/auth
# Functions: http://localhost:5001
# Storage: http://localhost:9199

🛡️ Security Features

  • Role-based Access Control: Admin, moderator, and user roles with granular permissions
  • Data Validation: Comprehensive input validation and sanitization
  • Rate Limiting: Built-in rate limiting for sensitive operations
  • Audit Logging: Automatic logging of security events and data access
  • Content Moderation: Integration with content scanning and moderation services
  • Encryption: End-to-end encryption for sensitive data

📊 Performance Features

  • Intelligent Caching: Multi-level caching with automatic invalidation
  • Connection Pooling: Optimized database connections
  • Batch Operations: Efficient bulk data operations
  • Image Optimization: Automatic image compression and format conversion
  • CDN Integration: Global content delivery for static assets
  • Performance Monitoring: Real-time performance metrics and alerts

🔧 Configuration

Firebase Configuration

// firebase.json
{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "source": "functions",
    "runtime": "nodejs18",
    "predeploy": ["npm --prefix functions run build"]
  },
  "storage": {
    "rules": "storage.rules"
  },
  "emulators": {
    "auth": { "port": 9099 },
    "functions": { "port": 5001 },
    "firestore": { "port": 8080 },
    "storage": { "port": 9199 },
    "ui": { "enabled": true, "port": 4000 }
  }
}

MCP Configuration

// MCP settings in firebase-mcp-integration.ts
const mcpConfig = {
  serverName: 'firebase-mcp',
  autoDeployment: true,
  environmentSync: true,
  logging: {
    level: 'info',
    enableAnalytics: true,
    enableErrorTracking: true
  },
  backup: {
    enabled: true,
    schedule: '0 2 * * *', // Daily at 2 AM
    retention: 30 // days
  }
};

🧪 Testing

# Run all tests
npm test

# Run specific test suites
npm run test:unit
npm run test:integration
npm run test:e2e

# Test with emulators
npm run test:emulator

# Test security rules
npm run test:rules

📚 Documentation

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support

🙏 Acknowledgments

  • Firebase team for the excellent backend services
  • Trae AI team for the MCP integration capabilities
  • Open source community for inspiration and contributions

Built with ❤️ for modern web applications using Firebase and Trae AI MCP

About

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages