booting portfolio
ankit.kumar
cloud-native · ai-adjacent · reliable
All projects
Cloud-native agentic coding workspace on Kubernetes

Distributed CodeForge

Java 21Spring CloudSpring AIKubernetes (GKE)Fabric8 K8s ClientKafkaRedisPostgreSQL + pgvectorMinIOJibGitHub ActionsStripe
overview

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.

6
Microservices
~90%
Cold-start ↓
~1.5s
Preview p50
GKE
Cluster
architecture & flows

Every diagram, animated live.

Distributed CodeForge · Microservices architecture
// codeforge-core (Spring plane) is network-isolated from codeforge-previews (sandbox plane). Kafka drives async sagas; Redis fronts subdomain routing.
Preview subdomain flow · pre-warm + WS reverse proxy
// Wildcard *.previews.* hits the subdomain proxy, which resolves user→pod via Redis and reverse-proxies WS into the pre-warmed pool.
Agentic self-healing loop · Spring AI tool calling
// Intelligence Service calls file/build tools, catches compile errors, retrieves similar past fixes from pgvector, and re-applies a patch.
GKE cluster · two network-isolated namespaces
// codeforge-core holds the Spring plane; codeforge-previews holds untrusted sandbox pods. Egress policies restrict sandboxes to private IP scopes.
account_db · UML
// Users, plans, subscriptions and Stripe event de-dup log.
workspace_db · UML
// Projects fan out into files, members and preview pods. Saga log de-dupes Kafka events.
intelligence_db · UML (+ pgvector)
// Chat session/message/event chain, per-user token usage and the pgvector store.
schema.sql

Database schema

▸ schema.sql
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);
lessons_learned

Deep dive & lessons

  • 01
    Spring 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.
  • 02
    Kafka is the event backbone — enabling idempotent producers stopped duplicated deploy events during flaky retries.
  • 03
    A pre-warmed pod pool plus Redis-cached user→pod routing gave <100ms lookup and drove preview cold-start from ~15s to ~1.5s.
  • 04
    Spring AI + pgvector implements a self-healing compile loop: past fix diffs are embedded and retrieved as few-shot context for the LLM.
  • 05
    Jib packages the services without a Docker daemon, and GCP Workload Identity Federation lets CI push to Artifact Registry without long-lived keys.