You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DeltaEd — Growth-Based Student Leaderboard & AI Coach
DeltaEd ranks students by how much they personally improve — not by who was already the best. An AI Coach (RAG-powered) helps each student understand their gaps and guides them through targeted tutoring.
Live URL:https://deltaed-frontend-wzlqkvs7dq-nw.a.run.app
DeltaEd runs as three microservices on Google Cloud Run, deployed via Terraform with Docker containers.
System Architecture
End-to-end flow from UI pages through the backend and agent services to BigQuery and the vector store.
Multi-Agent System (Google ADK)
The AI Coach is a multi-agent system built on Google ADK. The Learning Orchestrator routes student queries to specialised sub-agents, each grounded in educational principles.
Three Cloud Run Services
Service
Image
Description
deltaed-frontend
Dockerfile.frontend
Express server serving static HTML/CSS/JS + reverse proxy to backend & agent
deltaed-backend
Dockerfile.backend
FastAPI API for auth, leaderboard, dashboard with BigQuery
deltaed-agent
Dockerfile.agent
FastAPI + Google ADK RAG teacher agent with Gemini 2.5 Flash
# Same venv as backendexport GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_CLOUD_PROJECT=deltaed
export GOOGLE_CLOUD_LOCATION=europe-west2
# Run agent
uvicorn RAG_Pipeline.teacher_agent.server:app --host 0.0.0.0 --port 8001 --reload
Frontend (Express Proxy)
npm install
# Point to local backendsexport BACKEND_URL=http://localhost:8000
export AGENT_URL=http://localhost:8001
npm start
# → http://localhost:8080
Environment Variables
Frontend (server.js)
Variable
Default
Description
PORT
8080
Server port (Cloud Run sets this automatically — do NOT set in Terraform)
BACKEND_URL
http://localhost:8000
Backend API URL (set by Terraform in production)
AGENT_URL
http://localhost:8001
Agent API URL (set by Terraform in production)
NODE_ENV
development
Environment mode
Backend (src/apis/main.py)
Variable
Required
Description
GCP_PROJECT_ID
✅
Google Cloud project ID
Agent (RAG_Pipeline/teacher_agent/server.py)
Variable
Required
Description
GOOGLE_CLOUD_PROJECT
✅
Google Cloud project ID
GOOGLE_CLOUD_LOCATION
✅
GCP region (e.g. europe-west2)
GOOGLE_GENAI_USE_VERTEXAI
✅
Must be true — tells ADK to use Vertex AI, not Gemini API key
BIGQUERY_SCORES_DATASET_ID
✅
BigQuery dataset for scores (student_db)
BIGQUERY_CHAPTER_DATASET_ID
✅
BigQuery dataset for chapters (educational_resources_db)
GOOGLE_RAG_CORPUS
✅
Vertex AI RAG corpus resource path
RAG Corpus Setup (Manual)
The agent uses a Vertex AI RAG corpus to ground its answers in the NLP textbook (Speech and Language Processing, Jurafsky & Martin, 3rd ed.). This is set up manually via the GCP Console because the Google Terraform provider (v5.x) has no native resource for Vertex AI RAG Engine.
cd deployments
# Preview changes
terraform plan
# Apply all changes
terraform apply -auto-approve
# Deploy only one service (e.g., frontend)
terraform apply -auto-approve -target=google_cloud_run_service.deltaed_frontend
# View current state
terraform state list
# Import an existing resource
terraform import google_cloud_run_service.deltaed_frontend \
locations/europe-west2/namespaces/deltaed/services/deltaed-frontend
Common Operations
Check Service Status
gcloud run services list --region europe-west2 --project deltaed
gcloud run services describe deltaed-frontend --region europe-west2 \
--format="yaml(spec.template.spec.containers[0].env)"
Test Users
Email
Password
Student
mei.lin@example.com
meilin
Mei Lin
fatima.alhassan@example.com
fatimaalhassan
Fatima Al-Hassan
wei.chen@example.com
weichen
Wei Chen
Test Endpoints Directly
# Health checks
curl https://deltaed-frontend-wzlqkvs7dq-nw.a.run.app/health
curl https://deltaed-backend-wzlqkvs7dq-nw.a.run.app/
curl https://deltaed-agent-wzlqkvs7dq-nw.a.run.app/health
# Register a user
curl -X POST https://deltaed-frontend-wzlqkvs7dq-nw.a.run.app/register \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"pass123"}'# Login
curl -X POST https://deltaed-frontend-wzlqkvs7dq-nw.a.run.app/login \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"pass123"}'# Leaderboard
curl https://deltaed-frontend-wzlqkvs7dq-nw.a.run.app/leaderboard
Troubleshooting
Problem → Cause → Fix
Symptom
Cause
Fix
Login hangs / no response
express.json() consumes POST body before proxy forwards it
Remove express.json() from server.js
Backend returns 403 Forbidden
Cloud Run IAM rejects unauthenticated calls
Add allUsers as roles/run.invoker on the backend service
Backend 500 — "Dataset not found in location US"
BigQuery client defaults to US but datasets are in EU
Set bigquery.Client(project=..., location="EU") in main.py
Agent 500 — "No API key was provided"
ADK tries Gemini API instead of Vertex AI
Add GOOGLE_GENAI_USE_VERTEXAI=true env var to agent service
Agent 500 — "Permission denied" on Vertex AI
Service account missing AI Platform role
Add roles/aiplatform.user IAM binding for the service account
Frontend shows blank page
Missing config.js referenced by HTML
Create static/config.js with var CONFIG = { API_BASE: '' };
Docker push fails with auth error
Docker not configured for GCR
Run gcloud auth configure-docker gcr.io
Terraform wants to recreate services
State drift from manual gcloud run deploy
Run terraform apply to reconcile, or terraform import the resource
EADDRINUSE on frontend
Duplicate app.listen() in server.js
Ensure only one app.listen() call exists
Cloud Run fails with "PORT is reserved"
PORT env var set in Terraform
Remove PORT from env block — Cloud Run injects it automatically
Useful Debug Commands
# Check what image a service is running
gcloud run revisions list --service deltaed-frontend --region europe-west2
# Force a new revision (same image)
gcloud run deploy deltaed-frontend \
--image gcr.io/deltaed/deltaed-frontend:latest \
--region europe-west2
# Describe full service config
gcloud run services describe deltaed-backend --region europe-west2 --format=yaml