Overview
The K8s Scheduler frontend is a modern React 19 single-page application built with TypeScript, Vite, and TanStack Query. It provides a responsive UI for managing deployments, sandboxes, secrets, teams, and billing.Tech Stack
React 19
Latest React with concurrent features
TypeScript
Type-safe development experience
Vite
Fast build tool and dev server
TanStack Query
Powerful data fetching and caching
Project Structure
ui/src/ directory structure
API Client
The frontend uses a custom API client built on the Fetch API with automatic error handling and session management.Client Implementation
ui/src/api/client.ts
ui/src/api/client.ts:1-104
Key Features
- Credential handling: Automatic cookie-based session management
- Error handling: Structured error responses with
ApiErrorclass - 401 handling: Throws errors for React Router to handle redirects
- 204 handling: Returns
undefinedfor No Content responses - Type safety: Full TypeScript generics support
TanStack Query Hooks
The application uses TanStack Query (React Query v5) for data fetching, caching, and state management.Available Hooks
ui/src/api/hooks/ directory
Example Hook Usage
Application Structure
Entry Point
ui/src/main.tsx
ui/src/main.tsx:1-11
App Component
ui/src/App.tsx
ui/src/App.tsx:1-22
Routing
The application uses React Router v7 with nested routes and protected routes.Route Configuration
ui/src/routes/index.tsx
ui/src/routes/index.tsx:24-106
Protected Routes
All authenticated routes are wrapped in<ProtectedRoute> which:
- Checks for valid session
- Redirects to
/signinif unauthorized - Handles 401 errors from API
Component Organization
Layout Components
- AppShell: Main layout with navigation, sidebar, and content area
- ProtectedRoute: Authentication guard
- Navigation: Top navigation bar with user menu
- Sidebar: Left sidebar with feature navigation
Feature Components
ui/src/components/ directory structure
Pages
Available Pages
ui/src/pages/ directory
Development Setup
Prerequisites
package.json
ui/package.json:12-42
Vite Configuration
vite.config.ts
ui/vite.config.ts:1-24
Development Commands
Key Features
Path Aliasing
Vite is configured with@ alias pointing to src/ for clean imports:
Development Proxy
Vite proxies API requests to the Go backend during development:/api/*→http://localhost:8080/auth/*→http://localhost:8080/oauth2/*→http://localhost:8080
ui/vite.config.ts:14-21
Hot Module Replacement
Vite provides instant HMR for React components with state preservation.TypeScript Strict Mode
The project uses TypeScript strict mode for maximum type safety:tsconfig.json
State Management
The application uses TanStack Query for server state and React Context for UI state:- Server state: TanStack Query handles all API data
- Auth state:
AuthProvidercontext for user session - Theme state:
ThemeProvidercontext for dark/light mode - Local state: React hooks (
useState,useReducer)
Styling
The UI uses Tailwind CSS 4 with the Vite plugin for instant compilation:ui/vite.config.ts:3,8
Build Output
Production builds are optimized with:- Code splitting
- Tree shaking
- Asset optimization
- Minification
ui/dist/ and is served by the Go backend.
Related Documentation
Server Architecture
Go backend with HTTP handlers and middleware
Operator
Kubernetes operator for deployment reconciliation