Distributed CodeForge
Distributed CodeForge is a cloud-native, agentic collaborative coding workspace — a 6-microservice Spring Cloud control plane(Gateway, Eureka, Config Server, Account, Workspace, Intelligence) split across network-isolated Kubernetes namespaces on GKE to secure sandbox runtime execution. Services coordinate over Apache Kafka and Redis, backed by PostgreSQL 16 + pgvector for relational and vector data, with MinIO for file trees.
Sandbox preview spin-up latency was reduced ~90% (15s → <1.5s) by orchestrating a pre-warmed Kubernetes runner-pod pool with Redis-based route caching and LRU eviction. Workspace drives the pool through the Fabric8 Kubernetes client. A self-correcting agentic feedback loop uses Spring AI tool calling to read files, run preview builds and dynamically resolve compiler exceptions — pulling few-shot context from a pgvector memory of past error-fix pairs.
Deployments run through 5 path-filtered GitHub Actions workflows using Jib for daemonless container packaging and keyless GCP Workload Identity Federation, so CI pushes to Artifact Registry without long-lived keys. Stripe powers subscription billing with automated token-usage quotas, and Kubernetes egress policies lock sandbox pods down to private IP scopes only.
Every diagram, animated live.
Database schema
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE projects (
id BIGSERIAL PRIMARY KEY,
owner_id BIGINT REFERENCES users(id),
name TEXT NOT NULL
);
CREATE TABLE sessions (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT REFERENCES users(id),
project_id BIGINT REFERENCES projects(id),
started_at TIMESTAMPTZ DEFAULT now(),
ended_at TIMESTAMPTZ
);
CREATE TABLE embeddings (
id BIGSERIAL PRIMARY KEY,
scope TEXT NOT NULL, -- 'diff' | 'file' | 'issue'
ref_id BIGINT NOT NULL,
embedding VECTOR(1536),
created_at TIMESTAMPTZ DEFAULT now()
);
CREATE INDEX ON embeddings USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);Deep dive & lessons
- 01Spring Cloud Gateway with a custom JWT filter handles routing + authentication in one place; Eureka provides service discovery so ports and hostnames stay out of app code.
- 02Kafka is the event backbone — enabling idempotent producers stopped duplicated deploy events during flaky retries.
- 03A pre-warmed pod pool plus Redis-cached user→pod routing gave <100ms lookup and drove preview cold-start from ~15s to ~1.5s.
- 04Spring AI + pgvector implements a self-healing compile loop: past fix diffs are embedded and retrieved as few-shot context for the LLM.
- 05Jib packages the services without a Docker daemon, and GCP Workload Identity Federation lets CI push to Artifact Registry without long-lived keys.