GitDiagram has two components:
- Frontend: Next.js app (TypeScript, Tailwind CSS, ShadCN)
- Backend: FastAPI Python server (handles AI diagram generation via OpenAI o4-mini)
- Database: PostgreSQL with Drizzle ORM
Your deployment target: GCP, served at gitunderstand.com/diagrams
Before the agents can execute, you need to provide:
- OpenAI API Key — GitDiagram uses OpenAI o4-mini for diagram generation
- GitHub Personal Access Token — for fetching repo file trees and README content
- GCP Project ID — which GCP project to deploy into
- Current infra details — how is gitunderstand.com currently deployed? (Cloud Run? GKE? Compute Engine? App Engine?) This determines how we integrate the
/diagramssub-path - Domain/DNS setup — who manages DNS for gitunderstand.com? (Cloud DNS, Cloudflare, etc.)
- Database preference — use Cloud SQL (PostgreSQL), or an existing Postgres instance?
- PostHog API key — if you want analytics (optional)
- Rate limiting preferences — any specific limits for diagram generation?
- Existing CI/CD — do you have GitHub Actions, Cloud Build, or another pipeline?
- Clone gitdiagram repo into your codebase (as a subdirectory or monorepo module)
- Analyze all env vars needed from
.env.example - Validate local build:
pnpm i→docker-compose up→pnpm dev - Identify all hardcoded references to
gitdiagram.comand plan replacements
- Rebrand/repath: change all routes from
/root to/diagramssub-path - Update
next.config.jswithbasePath: '/diagrams' - Update all internal links, API calls, and asset paths
- Modify backend CORS settings to allow
gitunderstand.com - Update any hardcoded domain references in prompts, metadata, OG tags
- Remove or adapt analytics (PostHog) integration
- Provision Cloud SQL PostgreSQL instance (or reuse existing)
- Set up
DATABASE_URLconnection string - Run
pnpm db:pushto initialize schema (Drizzle ORM) - Test database connectivity
- Dockerize backend (already has Dockerfile in
backend/) - Deploy to Cloud Run as a separate service
- Configure env vars:
OPENAI_API_KEY,GITHUB_TOKEN,ENVIRONMENT=production - Set up internal URL for frontend → backend communication
- Verify
/generateendpoint works
- Build Next.js with
basePath: '/diagrams'and production env vars - Deploy to Cloud Run (or integrate with existing hosting)
- Set
NEXT_PUBLIC_API_URLto point to backend Cloud Run service - Configure the reverse proxy / load balancer to route
gitunderstand.com/diagrams/*to this service
- Configure your existing load balancer / reverse proxy:
gitunderstand.com/diagrams/*→ GitDiagram frontend servicegitunderstand.com/api/diagrams/*→ GitDiagram backend service (or use internal service-to-service)
- If using Cloud Run with a shared load balancer, add URL map rules
- SSL certificate should already cover
gitunderstand.com
- End-to-end test: enter a GitHub repo URL → get diagram
- Test private repo flow with GitHub PAT
- Test diagram caching (DB storage)
- Verify click-through interactivity (links to source files)
- Load testing if needed
- Monitor logs via Cloud Logging
You need 2 subagents. Create them in your project:
# Option A: Use the /agents command in Claude Code
# 1. Start Claude Code session in your repo
# 2. Type /agents
# 3. Select "Create new agent" → "Project-level"
# 4. Follow prompts for each agent below
# Option B: Manually create the files
mkdir -p .claude/agents
# Then create the two .md files belowCreate file: .claude/agents/repo-analyzer.md
Create file: .claude/agents/gcp-deployer.md
Step 1: Clone gitdiagram into your repo
$ git clone https://github.com/ahmedkhaleel2004/gitdiagram.git diagrams
Step 2: Start Claude Code in your repo root
$ claude
Step 3: Ask the repo-analyzer agent to analyze and adapt
> "Use the repo-analyzer agent to analyze the gitdiagram code in ./diagrams
and adapt it to work under the /diagrams basePath for gitunderstand.com"
Step 4: Provide your env vars when prompted
Step 5: Ask the gcp-deployer agent to deploy
> "Use the gcp-deployer agent to deploy the diagrams backend and frontend
to GCP Cloud Run and configure routing for gitunderstand.com/diagrams"
Step 6: Test and iterate
> "Test the deployment at gitunderstand.com/diagrams"
| File | What to Change |
|---|---|
next.config.js |
Add basePath: '/diagrams', update rewrites |
src/env.js |
Environment variable validation |
backend/app/routers/generate.py |
Rate limits, CORS |
backend/app/prompts.py |
No changes needed (prompt engineering) |
docker-compose.yml |
Production config, remove volume mounts |
drizzle.config.ts |
Database connection URL |
.env |
All secrets and config |
- Cost: OpenAI o4-mini calls cost money. Set rate limits early.
- GitHub API limits: Use authenticated requests (PAT) to get 5000 req/hr vs 60.
- Database: Cloud SQL costs ~$7-25/month for small instance. Consider Neon or Supabase for free tier.
- Cold starts: Cloud Run has cold start latency. Set min instances = 1 for backend if needed.