A powerful React-based marketing intelligence platform leveraging Google Cloud services for advanced analytics, machine learning, and real-time data processing.
-
Real-time Analytics Dashboard
- BigQuery integration for large-scale data analysis
- Interactive data visualization components
- Custom report generation
-
Machine Learning Capabilities
- Vertex AI integration for predictive analytics
- Gemini AI for personalized content generation
- Automated lead scoring system
-
Real-time Data Management
- Firestore integration for live updates
- Automated ETL pipelines
- Data synchronization across clients
-
Security
- Firebase Authentication
- Role-based access control
- Secure data encryption
- Frontend: React, TypeScript
- Cloud Services: Google Cloud Platform
- Database: Firestore
- Analytics: BigQuery
- AI/ML: Vertex AI, Gemini AI
- Authentication: Firebase Auth
- CI/CD: GitHub Actions
- Node.js (v18 or higher)
- Google Cloud CLI
- Firebase CLI
- Valid Google Cloud Project with enabled APIs
- Firebase Project
- Clone the repository
git clone [repository-url]
cd mb-marketing
- Install dependencies
npm install
- Configure Google Cloud
gcloud init
gcloud config set project [YOUR_PROJECT_ID]
gcloud services enable bigquery.googleapis.com aiplatform.googleapis.com firestore.googleapis.com
- Set up Firebase
npm install -g firebase-tools
firebase login
firebase init
- Environment Configuration
Create a
.env
file:
REACT_APP_GCP_PROJECT_ID=your-project-id
REACT_APP_GEMINI_API_KEY=your-gemini-api-key
npm run dev
npm run build
npm start
src/
βββ components/
β βββ analytics/ # Analytics components
β βββ ml/ # Machine learning components
β βββ common/ # Shared components
βββ services/ # API and service integrations
βββ hooks/ # Custom React hooks
βββ utils/ # Utility functions
- Firebase Authentication
import { getAuth, signInWithPopup, GoogleAuthProvider } from "firebase/auth";
export const auth = getAuth();
- Authorization Hook
const { user } = useAuth();
Automated deployment via GitHub Actions:
name: Deploy to Production
on:
push:
branches: [main]
# Run tests
npm test
# Run tests with coverage
npm test -- --coverage
- Set up Google Cloud Monitoring
- Configure error tracking
- Implement usage analytics
- Review maintenance documentation
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE.md file for details.
- Implement code splitting
- Optimize bundle size
- Use lazy loading for components
- Configure caching strategies
- Automated testing
- Build verification
- Deployment staging
- Production deployment
Detailed documentation for each component and service is available in the /docs
directory:
- API Documentation
- Component Documentation
- Service Integration Guides
- Security Guidelines
# Create main directories
mkdir -p src/{components,services,hooks,utils,contexts}
mkdir -p src/components/{analytics,ml,common}
mkdir -p src/services/{bigquery,firestore,vertex-ai,gemini-ai}
# Core dependencies
npm install @google-cloud/bigquery @google-cloud/vertexai firebase
npm install @google/generative-ai recharts flowbite-react
npm install tailwindcss @headlessui/react @heroicons/react
# Development dependencies
npm install -D typescript @types/react @types/node
Create src/services/config.ts
:
import { BigQuery } from '@google-cloud/bigquery';
import { VertexAI } from '@google-cloud/vertexai';
export const bigQueryClient = new BigQuery({
projectId: process.env.NEXT_PUBLIC_GCP_PROJECT_ID
});
export const vertexAIClient = new VertexAI({
project: process.env.NEXT_PUBLIC_GCP_PROJECT_ID,
location: 'us-central1'
});
Create src/services/firestore/client.ts
:
import { initializeApp } from 'firebase/app';
import { getFirestore } from 'firebase/firestore';
const firebaseConfig = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
// Add other config values
};
const app = initializeApp(firebaseConfig);
export const db = getFirestore(app);
Create src/components/analytics/Dashboard.tsx
:
import React from 'react';
import { LineChart, XAxis, YAxis, CartesianGrid, Line } from 'recharts';
interface DashboardProps {
data: any[];
}
export const Dashboard: React.FC<DashboardProps> = ({ data }) => {
return (
<div className="p-4">
<h2 className="text-2xl font-bold mb-4">Analytics Dashboard</h2>
<LineChart width={800} height={400} data={data}>
<XAxis dataKey="name" />
<YAxis />
<CartesianGrid strokeDasharray="3 3" />
<Line type="monotone" dataKey="value" stroke="#8884d8" />
</LineChart>
</div>
);
};
Create src/components/ml/PredictiveModel.tsx
:
import { VertexAIService } from '../../services/vertex-ai/client';
import React, { useState } from 'react';
export const PredictiveModel = () => {
const [prediction, setPrediction] = useState(null);
const vertexAI = new VertexAIService();
const handlePredict = async (data: any) => {
const result = await vertexAI.predictLeadScore(data);
setPrediction(result);
};
return (
<div className="p-4">
{/* Add prediction UI components */}
</div>
);
};
Create src/services/auth/firebase.ts
:
import { getAuth, signInWithPopup, GoogleAuthProvider } from 'firebase/auth';
export const auth = getAuth();
const provider = new GoogleAuthProvider();
export const signInWithGoogle = async () => {
try {
const result = await signInWithPopup(auth, provider);
return result.user;
} catch (error) {
console.error('Authentication error:', error);
throw error;
}
};
Create pages/api/analytics/data.ts
:
import type { NextApiRequest, NextApiResponse } from 'next';
import { bigQueryClient } from '../../../services/config';
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
try {
const query = req.body.query;
const [rows] = await bigQueryClient.query(query);
res.status(200).json(rows);
} catch (error) {
res.status(500).json({ error: 'Failed to fetch data' });
}
}
Create .env.local
:
NEXT_PUBLIC_GCP_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_API_KEY=your-api-key
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-firebase-project-id
NEXT_PUBLIC_GEMINI_API_KEY=your-gemini-api-key
-
Initialize Services
- Set up Google Cloud Project
- Enable necessary APIs in Google Cloud Console
- Configure Firebase project
- Set up authentication
-
Component Implementation
- Implement analytics dashboard
- Create ML model integration
- Set up real-time data sync with Firestore
-
Testing
# Run tests npm test # Start development server npm run dev
Create .github/workflows/deploy.yml
:
name: Deploy
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: npm ci
- run: npm test
- run: npm run build
- Set up Google Cloud Monitoring
- Implement error tracking
- Configure usage analytics
- Set up performance monitoring
- Implement proper authentication flows
- Set up Firebase security rules
- Configure CORS policies
- Implement rate limiting
- Set up API key rotation
- Review and implement error handling
- Add comprehensive logging
- Implement user feedback mechanisms
- Set up monitoring alerts
- Document API endpoints
- Create user guides