How kubestellar/ui works
Project type and purpose
• KubestellarUI is a full-stack web application.
• Frontend: React + TypeScript single-page application (SPA).
• Backend: Go service built on Gin, exposing REST endpoints and WebSocket streams.
• Purpose: Provide a UI for managing multi-cluster Kubernetes workloads (namespaces, binding policies, deployments, etc.) and stream real-time status updates via WebSockets.
File structure
• Top-level directories:
• /backend – Go monolith (API handlers, installer, k8s client, JWT auth, middleware, services, models)
• /src – React code (components, pages, hooks, API client, context providers, stores)
• /public – static examples & assets
• Infrastructure files: Dockerfile, docker-compose.yml, nginx.conf, GitHub Actions workflows, Makefile
• Notice patterns:
• Frontend communicates via HTTP REST + WebSocket.
• Backend encapsulates k8s interactions, JWT auth, Redis for caching, PostgreSQL for persistent data.
• CI/CD and container orchestration (Docker Compose, GitHub CI).
Key insights from README
• Frontend runs on port 5173, backend on port 4000.
• Redis optional for caching WebSocket updates.
• Kubernetes clusters must be pre-configured; backend uses kubernetes/client-go.
• Docker Compose brings up backend, frontend, redis.
a. Components to include:
• React Frontend (SPA)
• Go Backend (Gin HTTP server + WebSocket handler)
• PostgreSQL (persistent store)
• Redis (cache / pub-sub for WebSocket throttling)
• Kubernetes Clusters (one or more; managed via K8s client & custom controllers)
• External services: Artifact Hub registry, GitHub (for repository browsing), Helm Chart repositories
• CI/CD pipelines (GitHub Actions, Docker registry)
• Load Balancer / Reverse Proxy (NGINX in front of frontend/backend if present)
b. Relationships & data flows:
1. User → Browser → React SPA
2. SPA → (HTTP/REST) → Gin backend routes (e.g., /api/cluster, /api/bindings, /ws/installer)
3. Backend → PostgreSQL (user, namespace, cluster metadata)
4. Backend → Redis (cache real-time k8s watch events)
5. Backend → Kubernetes API (deploy, list resources, watch CSRs)
6. Backend → External artifact hub / GitHub / Helm repos (to fetch charts, images)
7. Backend WebSocket → SPA (push real-time status updates via socket)
8. Docker Compose / CI → Build and deploy container images to registry
c. Architectural patterns & principles:
• Layered architecture in backend: API handler → service layer → k8s client / installer / models
• React: component hierarchy, context for theming & WebSocket, React-Query for data fetching & caching
• Use of pub-sub (Redis) to decouple k8s watch events from WebSocket streams
• Single responsibility: distinct modules for auth, installer, k8s, namespace, JWT, logging
d. Technologies & frameworks to annotate:
• Frontend: React, Vite, TypeScript, TailwindCSS, React-Query, WebSocket
• Backend: Go, Gin framework, client-go, Redis client, PostgreSQL driver, JWT
• DevOps: Docker, Docker Compose, GitHub Actions, Makefile, Air (hot reload)