A web application that integrates Google Drive documents with Gemini File Search Store, providing a knowledge base as MCP servers and Agent skills.
flowchart LR
user["User"]
subgraph GoogleDrive["Google Drive"]
docs["Documents"]
end
subgraph GoogleCloud["Google Cloud"]
hosting["Firebase Hosting"]
subgraph App["Knowledge Agents (Cloud Run)"]
webui["Web UI"]
functions["Cloud Functions"]
firestore["Firestore"]
end
scheduler["Cloud Scheduler"]
tasks["Cloud Tasks"]
gemini["Gemini File Search Store"]
end
subgraph AIAgents["AI Agents"]
claude["Claude Code"]
codex["Codex"]
other["Others"]
end
user --> hosting
hosting --> webui
scheduler -->|"Periodic Sync"| functions
functions --> tasks
tasks -->|"Fetch Files"| docs
tasks -->|"Upload"| gemini
webui -->|"Agent Management"| firestore
webui -->|"Manual Sync"| functions
claude -->|"MCP / Agent Skill"| hosting
codex -->|"MCP / Agent Skill"| hosting
other -->|"MCP / Agent Skill"| hosting
App -->|"Query"| gemini
- Node.js (see
.node-versionfor version) - pnpm (see
packageManagerinpackage.jsonfor version) - Firebase CLI
- gcloud CLI
Note: This project is configured for
asia-northeast1region. To use a different region, search forasia-northeast1in the codebase and replace it with your preferred region before setup.
Configure the following in the Firebase Console:
- Create a new Firebase project
- Add a web app
- Upgrade to Blaze plan
- Set up Firestore Database
- Set up Authentication
- Upgrade to Identity Platform
- Enable Google provider
# Install gcloud CLI (if not installed)
# https://cloud.google.com/sdk/docs/install
# Authenticate
gcloud auth logingcloud services enable \
cloudbuild.googleapis.com \
cloudfunctions.googleapis.com \
artifactregistry.googleapis.com \
run.googleapis.com \
eventarc.googleapis.com \
secretmanager.googleapis.com \
cloudscheduler.googleapis.com \
cloudtasks.googleapis.com \
pubsub.googleapis.com \
storage.googleapis.com \
identitytoolkit.googleapis.com \
drive.googleapis.com \
--project YOUR_PROJECT_IDGenerate service agent identities to avoid permission propagation delays during first deployment:
gcloud beta services identity create --service=pubsub.googleapis.com --project YOUR_PROJECT_ID
gcloud beta services identity create --service=eventarc.googleapis.com --project YOUR_PROJECT_IDNote: Wait 1-2 minutes after running these commands before proceeding to allow permissions to propagate.
Register the following secrets in Secret Manager:
| Secret Name | Description | How to Obtain |
|---|---|---|
GEMINI_API_KEY |
Gemini API Key | Get from Google AI Studio |
AUTH_TOKEN_ENCRYPTION_KEY |
Auth token encryption key (32-byte Hex) | Generate with openssl rand -hex 32 |
Create secrets in Secret Manager.
Configure the following in IAM on the GCP Console:
| Target | Role | Purpose |
|---|---|---|
| Default compute service account | Secret Manager Secret Accessor | Cloud Run access to Secret Manager |
| Developer account | Service Account Token Creator | Authentication during deployment |
{
"projects": {
"default": "YOUR_PROJECT_ID",
"test": "demo-test-project",
"dev": "demo-dev-project"
}
}# Root
cp -p .env.sample .env.default
# Cloud Functions
cp -p services/functions/.env.sample services/functions/.env.default
# Scripts
cp -p scripts/.env.sample scripts/.env.defaultRoot .env.default
| Environment Variable | Description |
|---|---|
NEXT_PUBLIC_ENVIRONMENT |
production |
NEXT_PUBLIC_FIREBASE_API_KEY |
Firebase API Key |
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN |
Firebase Auth Domain |
NEXT_PUBLIC_FIREBASE_PROJECT_ID |
Firebase Project ID |
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID |
Firebase Messaging Sender ID |
NEXT_PUBLIC_FIREBASE_APP_ID |
Firebase App ID |
NEXT_PUBLIC_GOOGLE_DRIVE_SERVICE_ACCOUNT_EMAIL |
Service account for Google Drive integration (*) |
(*) Check the email address of "Default compute service account" in GCP Console > IAM & Admin > Service Accounts
Cloud Functions services/functions/.env.default
| Environment Variable | Description |
|---|---|
ENVIRONMENT |
production |
Scripts scripts/.env.default
| Environment Variable | Description |
|---|---|
ENVIRONMENT |
production |
DEV_GOOGLE_SERVICE_ACCOUNT |
Default compute service account |
SCRIPTS_GOOGLE_SERVICE_ACCOUNT |
Service account for script execution (*) |
FIREBASE_PROJECT_ID |
Firebase Project ID |
(*) Create a service account with the following roles in GCP Console > IAM & Admin > Service Accounts:
- Firebase Admin SDK Administrator Service Agent
- Secret Manager Secret Accessor
- Service Account Token Creator
It is recommended to set up a budget alert to monitor costs. Configure in Budgets & alerts in the Google Cloud Console.
# Install packages
npm install -g pnpm firebase-tools
pnpm install
# Firebase authentication
firebase login
# Build shared packages
pnpm build:sharedpnpm deploy:default:functionsNote: On first deployment, permission propagation for 2nd Gen Cloud Functions may take time, causing some Functions to fail. Wait a few minutes and run
pnpm deploy:default:functionsagain.
pnpm deploy:default:webNote: On first Cloud Run deployment, you will be asked
Allow unauthenticated invocations to [app] (y/N)?. Selectyto publish as a web application.
Create an admin account to access the admin panel (/admin).
pnpm node:default scripts/src/createAdminUser.ts -e your-email@example.comNote: After running the script, sign in with Google using the registered email address.
Troubleshooting: If sign-in fails with an error, blocking functions may not have been configured automatically during deployment. Go to Firebase Console > Authentication > Settings > Blocking functions, and manually register
beforeUserCreatedandbeforeUserSignedInfunctions.
- Chat streaming responses do not work through Firebase Hosting (SSE is blocked due to reverse proxy specifications, but chat itself is available). To use streaming, access Cloud Run directly, via Cloud Run Domain Mapping, or use App Hosting.