Skip to content

kube-rca/frontend

Repository files navigation

KubeRCA Logo

KubeRCA Frontend

React Web Dashboard for Kubernetes Incident Management

React TypeScript Vite Tailwind CSS


Overview

The KubeRCA Frontend is a React-based web dashboard that provides a user interface for viewing and managing Kubernetes incidents. It displays RCA (Root Cause Analysis) results, alerts, and allows users to search for similar past incidents.

Key Features

  • Incident Dashboard - View and manage Kubernetes incidents
  • RCA Viewer - Display AI-generated root cause analysis
  • Alert Management - Browse and filter alerts
  • Similar Incident Search - Find related past incidents via vector similarity
  • Muted Incidents - Manage hidden/muted incidents
  • Dark Mode - Toggle between light and dark themes
  • Authentication - Login/signup with JWT tokens

Screenshots

The dashboard provides views for:

  • Incident list with filtering and pagination
  • Incident detail with RCA analysis results
  • Alert list and detail views
  • Hidden/muted incident management

Tech Stack

Category Technology
Framework React 18
Language TypeScript
Build Tool Vite
Styling Tailwind CSS
Linting ESLint
Container Docker + Nginx

Quick Start

Prerequisites

  • Node.js 18+ (LTS recommended)
  • npm 9+

Installation

# Run in repository root
# (monorepo layout: cd frontend/main)
npm install

Run Development Server

npm run dev

Open http://localhost:5173 in your browser.

Build for Production

npm run build

Preview Production Build

npm run preview

Project Structure

frontend/
├── src/
│   ├── main.tsx              # React entrypoint
│   ├── App.tsx               # Main app with routing
│   ├── types.ts              # TypeScript type definitions
│   ├── index.css             # Tailwind CSS entrypoint
│   ├── components/           # React components
│   │   ├── AlertTable.tsx         # Alerts list table
│   │   ├── AlertDetailView.tsx    # Alert detail view
│   │   ├── RCATable.tsx           # Incidents/RCA list table
│   │   ├── RCADetailView.tsx      # Incident detail with RCA
│   │   ├── ArchiveTable.tsx       # Hidden incidents table
│   │   ├── ArchiveDetailView.tsx  # Hidden incident detail
│   │   ├── UnifiedSearchPanel.tsx # Unified search panel
│   │   ├── Header.tsx             # App header (theme, auth)
│   │   ├── AuthPanel.tsx          # Login/signup panel
│   │   ├── Pagination.tsx         # Pagination component
│   │   └── TimeRangeSelector.tsx  # Time range filter
│   ├── context/              # React Context providers
│   │   ├── ThemeContext.ts        # Theme context definition
│   │   ├── ThemeProvider.tsx      # Theme provider component
│   │   └── SearchContext.tsx      # Search context
│   ├── constants/            # Application constants
│   │   └── index.ts
│   └── utils/                # Utility functions
│       ├── api.ts                 # Backend API client
│       ├── auth.ts                # Authentication utilities
│       ├── config.ts              # Configuration utilities
│       ├── filterAlerts.ts        # Alert filtering logic
│       └── searchLogic.ts         # Search scoring and sorting
├── Dockerfile               # Production build (Nginx)
├── package.json             # Dependencies and scripts
├── tsconfig.json            # TypeScript configuration
├── vite.config.ts           # Vite configuration
├── tailwind.config.js       # Tailwind CSS configuration
└── .eslintrc.cjs            # ESLint configuration

Configuration

Environment Variables

Variable Description Default
VITE_API_BASE_URL Backend API URL '' (same-origin)

Local Development

Create a .env file:

VITE_API_BASE_URL=http://localhost:8080

Production (Kubernetes)

In Kubernetes deployments, set VITE_API_BASE_URL when frontend and backend are served from different origins.


Available Scripts

Command Description
npm run dev Start development server
npm run build Build for production
npm run preview Preview production build
npm run lint Run ESLint

Full Verification

npm run lint && npm run build

API Integration

The frontend communicates with the KubeRCA Backend API:

Endpoints Used

API Description
/api/v1/auth/* Authentication (login, register, refresh)
/api/v1/incidents Incident list and details
/api/v1/alerts Alert list and details
/api/v1/embeddings/search Similar incident search

API Client

Located at src/utils/api.ts, the API client handles:

  • Request/response formatting
  • Authentication token management
  • Error handling

Styling

Tailwind CSS

The project uses Tailwind CSS for styling:

// Example component with Tailwind classes
<div className="bg-white dark:bg-gray-800 p-4 rounded-lg shadow">
  <h1 className="text-xl font-bold text-gray-900 dark:text-white">
    Incident Details
  </h1>
</div>

Dark Mode

Dark mode is implemented using Tailwind's dark: prefix:

<div className="bg-white dark:bg-gray-900">
  {/* Content adapts to theme */}
</div>

Toggle is available in the header component.


Docker

Build Image

docker build -t kube-rca-frontend .

Run Container

docker run -d -p 80:80 kube-rca-frontend

Access at http://localhost.

Dockerfile Overview

Multi-stage build:

  1. Build stage - Node.js builds the React app
  2. Production stage - Nginx serves static files

Development Guidelines

TypeScript

  • Use strict mode (tsconfig.json)
  • Define shared types in src/types.ts
  • Use interface for component props

Components

  • Functional components with hooks
  • Keep components focused and reusable
  • Use React Context for global state

API Calls

// Example API call pattern
const [data, setData] = useState<Incident[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);

useEffect(() => {
  const fetchData = async () => {
    try {
      const response = await api.getIncidents();
      setData(response);
    } catch (err) {
      setError('Failed to fetch incidents');
    } finally {
      setLoading(false);
    }
  };
  fetchData();
}, []);

Merge Policy (release-please)

  • Avoid merge commits when merging PRs; they can create duplicate changelog entries.
  • Prefer "Squash and merge" or "Rebase and merge" and ensure the final commit message is conventional.

Related Components


License

This project is part of KubeRCA, licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages