A powerful web application for generating high-quality blog articles using Google's Gemini API. The app automatically creates SEO-optimized content, generates relevant images with Imagen, and saves everything directly to your Google Drive.
- π€ AI-Powered Content Generation - Uses Gemini 2.5 Pro for high-quality article writing
- πΌοΈ Automatic Image Generation - Creates featured images and in-content images with Imagen 4
- π Google Sheets Integration - Manage your content queue directly from spreadsheets
- πΎ Google Drive Storage - Automatically saves articles and images to organized folders
- π¨ Multiple Blog Profiles - Support for different writing styles and target audiences
- π Article Customization - Control length, language, image count, and more
- π Regeneration Options - Regenerate text or images if you're not satisfied
- βοΈ Built-in Editor - Edit and refine articles before saving
- π± Modern UI - Clean, responsive interface with real-time progress tracking
- π Secure Backend - API keys protected via Firebase Cloud Functions
- π Email-Based Access Control - Restrict access to authorized users only
The application is deployed at: https://ai-article-gen-pavel.web.app
Note: The live demo is restricted to authorized email addresses only.
- Frontend: React 19 + TypeScript + Vite
- Backend: Firebase Cloud Functions (Node.js 20)
- Styling: Tailwind CSS (via CDN)
- AI Services: Google Gemini API (text + image generation)
- Cloud Storage: Google Drive API
- Data Management: Google Sheets API
- Hosting: Firebase Hosting
This application implements several security measures:
- Backend API Proxy - Gemini API calls are made through Firebase Cloud Functions, keeping the API key secure on the server
- Email Authorization - Only specified email addresses can access the application
- No Client-Side Secrets - API keys are never exposed in the browser or frontend code
- Environment Variables - Sensitive data stored in
.envfiles (excluded from Git)
Before you begin, you'll need:
-
Google Cloud Project with the following APIs enabled:
- Google Drive API
- Google Sheets API
- OAuth 2.0 credentials (Client ID)
-
Gemini API Key from Google AI Studio
-
Firebase Project on the Blaze (pay-as-you-go) plan
- Required for Cloud Functions
- Free tier includes 2M function invocations/month
git clone https://github.com/yourusername/ai-article-generator.git
cd ai-article-generatornpm installcd functions
npm install
cd ..Create .env.local in the root directory (this file is gitignored):
# Not needed anymore - API key is now on backend only
# VITE_GEMINI_API_KEY is no longer usedEdit functions/.env and add your Gemini API key:
GEMINI_API_KEY=your_actual_gemini_api_key_hereImportant: Never commit
.envfiles to Git! They are already in.gitignore.
Edit the ALLOWED_EMAILS array in two locations to specify who can access your application:
File 1: functions/src/index.ts (lines 16-19)
const ALLOWED_EMAILS = [
'your-email@example.com',
'another-email@example.com'
];File 2: services/googleAuthService.ts (lines 7-10)
const ALLOWED_EMAILS = [
'your-email@example.com',
'another-email@example.com'
];Note: Both files must have the same email list for proper authorization.
If your Firebase project ID or region differs, update FUNCTIONS_BASE_URL in services/geminiService.ts:
const FUNCTIONS_BASE_URL = 'https://YOUR-REGION-YOUR-PROJECT-ID.cloudfunctions.net';firebase login
firebase initSelect:
- Hosting
- Functions
- Use existing project (select your Firebase project)
cd functions
npm run build
cd ..
firebase deploy --only functionsnpm run build
firebase deploy --only hosting- Go to Google Cloud Console
- Create OAuth 2.0 credentials (Web application)
- Add authorized JavaScript origins and redirect URIs:
- For local development:
http://localhost:5173 - For production:
https://your-app.web.app
- For local development:
- Copy the Client ID
- Sign in with your authorized Google account
- Enter your Google OAuth Client ID
- Create a new blog profile with:
- Profile name
- Writing style/persona
- Target audience
- Image style preferences
- Google Drive folder ID (for saving articles)
- Optional: Google Sheet URL (for content queue)
Option 1: From Google Sheets
- Create a Google Sheet with columns:
topic,keywords,category,status - Add the sheet URL to your profile
- Load topics and click "Generate" on any topic
Option 2: From XLSX File
- Upload an XLSX file with the required columns
- Click "Generate" on any topic
The app will:
- βοΈ Generate article text using Gemini 2.5 Pro
- πΌοΈ Create images with Imagen 4
- π Find relevant external sources via Google Search
- π Format and save HTML to Google Drive
- β Update status in Google Sheets (if applicable)
- Never commit
.envfiles - They're in.gitignorebut double-check before pushing - Rotate API keys regularly - Especially if you suspect exposure
- Review Cloud Function logs - Monitor for unauthorized access attempts
- Keep dependencies updated - Run
npm auditregularly - Use environment-specific configs - Different keys for dev/staging/production
- Protect your OAuth Client ID - Don't share it publicly
- Review authorized users - Regularly check who has access
- Monitor API usage - Check Google Cloud Console for unexpected usage
- Enable 2FA - On your Google account for added security
- Cloud Functions: 2M invocations/month free, then $0.40 per million
- Hosting: 10GB storage + 360MB/day transfer free
- Typical usage: Should stay within free tier for personal use
- Gemini 2.5 Pro: Free tier available, check current pricing
- Imagen 4: Paid service, check Google AI Studio for rates
- Drive API: Free for reasonable use
- Sheets API: Free for reasonable use
- Check that your email is in the
ALLOWED_EMAILSarray in both files - Verify you're signed in with the correct Google account
- Check that Cloud Functions are deployed:
firebase deploy --only functions - Verify
GEMINI_API_KEYis set infunctions/.env - Check Firebase Functions logs:
firebase functions:log
- Verify Imagen API is enabled in Google Cloud Console
- Check API quota limits
- Review Cloud Functions logs for detailed error messages
- Ensure all dependencies are installed:
npm installandcd functions && npm install - Check Node.js version (requires Node 20 for functions)
- Clear cache:
npm cache clean --force
# Run frontend dev server
npm run dev
# Run functions emulator (optional)
cd functions
npm run serveBefore deploying, verify:
-
API key not in build:
npm run build findstr /s /i "AIza" dist\assets\*.js # Should return nothing
-
Email restriction works:
- Try signing in with unauthorized email
- Should see "Access Denied" message
-
Functions are working:
- Test article generation end-to-end
- Check all features (text, images, sources)
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini API for powerful AI capabilities
- Firebase for hosting and backend infrastructure
- React and Vite for the excellent development experience
For questions or support, please open an issue on GitHub.
This application handles API keys and user data. Always:
- Keep your
.envfiles private - Regularly review access logs
- Update dependencies for security patches
- Follow the principle of least privilege for API access