- ✅ Develop and test locally before deploying
- ✅ Use Firebase Emulators for full local environment
- ✅ Fast iteration and debugging
- ✅ No network dependencies during development
- ✅ Functions secured in production
- ✅ Proper authentication and authorization
- ✅ IAM roles and permissions
- ✅ No public access unless explicitly needed
- ✅ ADC (Application Default Credentials) for authentication
- ✅ No secrets or JSON keys in code
- ✅ Service account impersonation when needed
- ✅ Proper error handling and logging
# Start local development
./start-local-development.sh
# Test functions locally
./test-local-functions.sh
# Populate local data
node populate-local-data.js- Firebase Console: http://localhost:4000
- Functions: http://localhost:5001/demo-project/us-central1
- Firestore: http://localhost:8080
- Auth: http://localhost:9099
# Test individual function
curl http://localhost:5001/demo-project/us-central1/categoryExtraction
# Test with data
curl -X POST http://localhost:5001/demo-project/us-central1/orchestratorService \
-H "Content-Type: application/json" \
-d '{"workflow_type": "test", "user_id": "local-user"}'# Use ADC for authenticated access
node test-pipeline-final.js
# Check deployment status
./test-deployment-status.sh-
ADC (Application Default Credentials) - ✅ Recommended
- No secrets required
- Works with
gcloud auth application-default login - Production-grade security
-
Service Account Impersonation - ✅ For advanced use cases
- Use existing service accounts
- No key creation required
- Secure and auditable
-
Firebase Auth Tokens - ✅ For user-specific access
- User authentication
- Custom claims and roles
- Secure user data access
// Secure function example
exports.secureFunction = functions.https.onRequest(async (request, response) => {
// Verify authentication
const authHeader = request.headers.authorization;
if (!authHeader) {
response.status(401).json({ error: 'Authentication required' });
return;
}
// Process request
// ...
});# View function logs
firebase functions:log --only categoryExtraction
# Check emulator logs
firebase emulators:start --only functions --debug# View production logs
firebase functions:log --project ${PROJECT_ID:-your-firebase-project-id}
# Check function status
firebase functions:list --project ${PROJECT_ID:-your-firebase-project-id}- Local Development - Use emulators
- Staging Deployment - Test in isolated environment
- Production Deployment - Deploy to production with proper auth
# Example GitHub Actions
- name: Deploy to Staging
run: firebase deploy --project staging-project
- name: Deploy to Production
run: firebase deploy --project ${PROJECT_ID:-your-firebase-project-id}
if: github.ref == 'refs/heads/main'- ✅ Use local emulators
- ✅ Test functions locally
- ✅ Use local Firestore
- ✅ Fast iteration cycle
- ✅ Deploy with proper security
- ✅ Use ADC for authentication
- ✅ Monitor with Firebase Console
- ✅ Implement proper error handling
- ✅ Local testing first
- ✅ Remote testing when needed
- ✅ Use proper authentication
- ✅ Check logs and monitoring
- ✅ Functions secured by default
- ✅ No public access vulnerabilities
- ✅ Proper authentication required
- ✅ Audit trail and monitoring
- ✅ Local development environment
- ✅ Fast iteration cycles
- ✅ No network dependencies
- ✅ Easy debugging and testing
- ✅ Proper error handling
- ✅ Monitoring and logging
- ✅ Scalable architecture
- ✅ Secure by design
-
Set up local development:
cd scripts/firebase/local ./setup-local-development.sh -
Start local development:
./start-local-development.sh
-
Test functions locally:
./test-local-functions.sh
-
Deploy to production when ready:
cd ../remote firebase deploy --project ${PROJECT_ID:-your-firebase-project-id}
This approach follows Google's best practices and provides a secure, scalable, and maintainable microservices architecture! 🎉