This repository contains the source code for GamerHeads, a web application that leverages Google's Gemini models (including Veo for video generation) to create dynamic video content. The project is designed to be easily deployed to your own Google Cloud Platform (GCP) environment via Cloud Run.
- Automated AI Video Creation: Generate images, scripts, and video clips using Gemini and Veo models.
- Admin Dashboard: Monitor API usage, view generated logs, and export statistics.
- Built-in Authentication: Protect your application either using Google Identity-Aware Proxy (IAP) or simple Basic Authentication (Fixed Username/Password).
- One-Click Deployment: A comprehensive
deploy.shscript automates GCP Cloud Build, Cloud Run deployment, Datastore setup, and IAM permissions.
Prerequisites:
- Node.js (v20+ recommended)
- Install dependencies:
npm install
- Set your API Key:
Create a
.env.localfile in the root directory (or edit the existing one) and add your Gemini API key:VITE_GEMINI_API_KEY=your_gemini_api_key_here
- Run the app locally:
npm run dev
This project includes a robust deployment script (deploy.sh) that automates the process of building the code in the cloud and deploying it to Google Cloud Run.
- Google Cloud CLI: Ensure you have the
gcloudCLI installed and initialized.gcloud auth login
- GCP Project with Billing Enabled: You must have a GCP Project ID, and it must be linked to an active Billing Account, as Cloud Run requires billing to be enabled.
- Gemini API Key: Obtain an API key from Google AI Studio.
- Make the deployment script executable:
chmod +x deploy.sh
- Run the deployment script:
./deploy.sh
- Follow the interactive prompts:
- Confirm or input your GCP Project ID.
- Set the Cloud Run service name and region (defaults to
us-central1). - Enter your Gemini API Key.
- Choose Authentication Method:
- Option 1 (IAP): Leaves the app open internally, relying on you configuring GCP Identity-Aware Proxy in the Cloud Console to restrict access.
- Option 2 (Fixed Password): Allows you to add one or multiple Username/Password combinations. The script securely injects these credentials into Cloud Run via environment variables, triggering a browser native login prompt when accessing the site.
- Sit back and relax: The script will automatically:
- Enable necessary GCP APIs (Cloud Build, Cloud Run, Artifact Registry, Firestore).
- Create a Firestore Native database to store generation logs.
- Fix any IAM permissions for the Cloud Build and Cloud Run service accounts.
- Build the Docker container in the cloud and deploy it to Cloud Run.
"User location is not supported for the API use" Error
The architecture of this application initiates Gemini API requests (like image, script, and Veo video generation) directly from the client-side (the user's browser) to Google's API servers.
If you or your users encounter a region restriction error, it means your local machine's IP address is in a region where Google does not currently support the Gemini/Veo API.
Solution: You must use a VPN or proxy on your local machine (e.g., set to a US node) before clicking the generate buttons in the web application.
The application includes an /admin route (or click the Admin Dashboard button).
- If you deployed using Option 2 (Fixed Password), the system automatically extracts the username you logged in with.
- If you deployed using Option 1 (IAP), it automatically extracts your Google Account Email from the IAP headers.
- All generation actions (successes and failures) are logged to GCP Datastore/Firestore and displayed securely in the dashboard.
