Skip to main content

Paqtra Web Application Architecture

Overview​

Cloud-native web application providing a real-time dashboard for Cilium network observability, policy management, and intelligent automation. Built with React 19, TypeScript, and Tailwind CSS.

Architecture Diagram​

+-------------------------------------------------------------+
| Kubernetes Cluster |
+-------------------------------------------------------------+
| |
| +---------------------------+ +--------------------------+ |
| | Frontend (React SPA) | | Backend (Rust/Actix) | |
| | Port: 3000 (dev) | | Port: 9191 | |
| | | | | |
| | 34 shared components | | REST API (/api/v1/*) | |
| | 64 lazy-loaded views | | WebSocket (/ws/*) | |
| | Zustand state (3 stores) | | JWT authentication | |
| | WebSocket real-time | | Hubble gRPC proxy | |
| +---------------------------+ +--------------------------+ |
| | |
| +--------------+---------------+ |
| | | |
| +-----------v-----------+ +---------------v-+ |
| | Paqtra Core | | Hubble Relay | |
| | (Intelligence) | | (Flow Data) | |
| | | +-----------------+ |
| | AutoPolicy Engine | |
| | Anomaly Detection | |
| | Chaos Engineering | |
| | eBPF Profiler | |
| +-----------------------+ |
+-------------------------------------------------------------+

Technology Stack​

Backend (Rust)​

  • Framework: Actix-Web
  • WebSocket: actix-ws
  • Serialization: serde_json
  • Authentication: JWT (Bearer tokens)
  • Observability: tracing, prometheus metrics

Frontend (React)​

  • Framework: React 19 with TypeScript 5.6
  • State Management: Zustand 5 (auth, theme, preferences)
  • Data Fetching: TanStack React Query 5.56 + Axios
  • Routing: React Router 6.28 with React.lazy code splitting
  • Visualization: Recharts 2.15, D3 (d3-force, d3-selection, d3-drag)
  • Code Editor: Monaco Editor (YAML policy editing)
  • Icons: Lucide React
  • Styling: Tailwind CSS 3.4 (dark-first, class-based toggle)
  • Build Tool: Vite 6 (manual chunk splitting, sourcemaps)
  • Testing: Vitest 2 + React Testing Library (68 tests)

Frontend Architecture​

Component Layer (34 components)​

components/
Layout: MainLayout, LoginPage
Data Display: StatCard, HealthCheckCard, ChartContainer, SortableTable,
ResponsiveTable, AlertsList, Badge, ProgressBar, ScoreGauge,
Sparkline, PipelineView, SystemInfoPanel, ActivityFeed
Feedback: Toast, LoadingSpinner, Skeleton, EmptyState, LiveBadge,
DataFreshness
Navigation: GlobalSearch, Breadcrumbs, NamespaceSidebar, Pagination
Form: ToggleSwitch, Accordion, ExportButton, NotificationManager,
FilterBar, BulkActionBar

State Management​

StorePurposePersistence
authStoreToken, username, session checklocalStorage + sessionStorage
themeStoreDark/light togglelocalStorage
preferencesStorePage size, refresh interval, etc.localStorage

Hooks (6 hooks)​

HookPurpose
useAutoRefreshConfigurable auto-refresh with interval control
useWebSocketAuto-reconnect WS with JSON parsing
useMetricsHistorySliding-window buffer for time-series data
useKeyboardShortcutsGlobal shortcuts with g-prefix navigation
useAutoDismissAuto-clearing state for success/error messages
usePageTitleDynamic document.title

View Layer (64 views)​

All views are lazy-loaded via React.lazy() + Suspense for optimal code splitting.

Each view follows a consistent pattern:

  1. Gradient icon box page header
  2. Error/success alert banners
  3. Stat cards with card-glow hover effects
  4. Data tables with sortable headers, section headers, count badges
  5. Charts with gradient icon headers and dark tooltip styling

API Layer​

Single Axios instance (services/api.ts) with:

  • Auto-injected Bearer token from sessionStorage
  • 401 response interceptor (clears auth state)
  • 49 typed interfaces for all API responses
  • 70+ typed API functions

Design System​

Dark-first theme patterns:

Color Palette​

  • Page: bg-slate-950 / #0f172a
  • Cards: bg-slate-800/50 with border-slate-700/50
  • Inputs: bg-slate-900/50 with border-slate-700/50
  • Primary text: text-white
  • Secondary text: text-slate-400
  • Muted text: text-slate-500

Stat Card System​

Six gradient variants: stat-card-{blue,green,red,purple,orange,cyan} Each with matching card-glow-{color} hover effect and hover:scale-[1.02]

Component Patterns​

  • Gradient icon box: w-10 h-10 rounded-lg bg-gradient-to-br from-{color}-500 to-{color}-700
  • Section accent bar: w-1 h-5 bg-gradient-to-b from-{color}-400 to-{color}-500 rounded-full
  • Terminal header: Traffic light dots (red/yellow/green circles)
  • Table headers: uppercase tracking-wider font-semibold text-slate-400
  • Buttons: Gradient primary, border secondary, gradient-to-r reset

Animations​

  • animate-fade-in: translateY(8px) + opacity
  • animate-scale-in: scale(0.95) + opacity
  • animate-slide-in: translateX(100%) + opacity
  • animate-pulse-dot: opacity pulse for live indicators
  • skeleton: shimmer gradient for loading states

Light Theme​

Full light theme support via .light-theme class + html:not(.dark) CSS variables. Toggle persisted in localStorage.

API Endpoints (75+ total)​

Health & Metrics​

MethodPathDescription
GET/healthHealth check
GET/readyReadiness probe
GET/metricsPrometheus metrics

Core Data (under /api/v1)​

MethodPathDescription
GET/api/v1/flowsPaginated flows with filters
GET/api/v1/flows/{id}Single flow detail
GET/api/v1/flows/statsFlow statistics
GET/api/v1/endpointsCilium endpoints
GET/api/v1/nodesNode status and resources
GET/api/v1/eventsKubernetes events
GET/api/v1/identitiesCilium identities

Policies​

MethodPathDescription
GET/api/v1/policiesList network policies
POST/api/v1/policiesCreate policy
PUT/api/v1/policies/{id}Update policy
DELETE/api/v1/policies/{id}Delete policy
POST/api/v1/policies/{id}/rulesAdd one rule (direction, rule; ?dry_run=true)
PUT/api/v1/policies/{id}/rulesReplace one rule (direction, index, rule)
DELETE/api/v1/policies/{id}/rulesDelete one rule (?direction=&index=); a policy's last rule cannot be deleted (Cilium rejects rule-less policies), delete the policy instead
POST/api/v1/policies/simulateSimulate policy impact
POST/api/v1/policies/validateValidate YAML
GET/api/v1/policies/templatesPolicy templates
POST/api/v1/policies/templates/{id}/applyApply template

Security​

MethodPathDescription
GET/api/v1/anomaliesDetected anomalies
GET/api/v1/anomalies/{id}Anomaly detail
POST/api/v1/anomalies/{id}/remediateRemediate anomaly
GET/api/v1/compliance/frameworksCompliance frameworks
POST/api/v1/compliance/auditRun compliance audit
GET/api/v1/security/postureSecurity posture overview
GET/api/v1/security/findingsSecurity findings
GET/api/v1/security/zero-trustZero-trust score
GET/api/v1/security/podsPod security status

Intelligence Modules​

MethodPathDescription
POST/api/v1/modules/autopolicy/generateML policy generation
GET/api/v1/modules/chaos/experimentsChaos experiments
POST/api/v1/modules/chaos/runRun experiment
GET/api/v1/modules/canary/{id}Canary deployment status
GET/api/v1/modules/replay/recordingsFlow recordings
POST/api/v1/modules/replay/startStart recording
POST/api/v1/modules/replay/{id}/stopStop recording
GET/api/v1/modules/healer/problemsDetected problems
POST/api/v1/modules/healer/{id}/fixApply fix
GET/api/v1/modules/rootcause/dropsDrop analysis
POST/api/v1/modules/rootcause/analyzeRoot cause analysis
GET/api/v1/modules/multicluster/clustersMulti-cluster status
POST/api/v1/modules/multicluster/{name}/syncSync cluster
GET/api/v1/modules/ebpf/programseBPF programs
GET/api/v1/modules/ebpf/mapseBPF maps
GET/api/v1/modules/capture/sessionsPacket captures
POST/api/v1/modules/capture/startStart capture
POST/api/v1/modules/capture/{id}/stopStop capture
GET/api/v1/modules/mirror/rulesMirror rules
POST/api/v1/modules/mirror/rulesCreate mirror rule
DELETE/api/v1/modules/mirror/rules/{id}Delete mirror rule

Observability​

MethodPathDescription
GET/api/v1/heatmapTraffic heatmap data
GET/api/v1/dependenciesService dependencies
GET/api/v1/servicemapService map topology
GET/api/v1/dns/queriesDNS query monitoring
GET/api/v1/dns/statsDNS statistics
GET/api/v1/latency/analysisLatency percentile analysis
GET/api/v1/bandwidthBandwidth metrics
GET/api/v1/metrics/summaryMetrics summary

Networking​

MethodPathDescription
GET/api/v1/network/interfacesNetwork interfaces
GET/api/v1/loadbalancer/servicesLoad balancer services
GET/api/v1/ingress/routesIngress routes
GET/api/v1/ipam/poolsIPAM pools
GET/api/v1/ipam/allocationsIP allocations
GET/api/v1/encryption/statusEncryption status
GET/api/v1/wireguard/peersWireGuard peers
GET/api/v1/bgp/peersBGP peers
GET/api/v1/clustermesh/peersClusterMesh peers
POST/api/v1/clustermesh/connectConnect cluster
GET/api/v1/kpr/statusKPR status
GET/api/v1/egress/policiesEgress policies
GET/api/v1/servicemesh/servicesService mesh services

Operations​

MethodPathDescription
GET/api/v1/host/infoHost information
GET/api/v1/cilium/statusCilium agent status
GET/api/v1/cilium/featuresWhich Cilium features cilium-config enables
GET/api/v1/cilium/resources/{kind}List a Cilium CRD read-only (BGP v2, LB-IPAM, L2, pod IP pools, CIDR groups, Gateway API, ...)
GET/api/v1/cilium/metricsCilium agent metrics via Prometheus
GET/api/v1/hubble/metricsHubble flow metrics via Prometheus
GET/api/v1/hubble/nodesHubble nodes with flow-buffer fill (GetNodes)
GET/api/v1/cilium/agent/{what}Read-only agent query: endpoints, identities, services, fqdn-cache, status, policy-selectors (editor)
GET/api/v1/cluster/healthCluster health
GET/api/v1/rbac/bindingsRBAC bindings
GET/api/v1/alerts/rulesAlert rules
POST/api/v1/alerts/rulesCreate alert rule
PUT/api/v1/alerts/rules/{id}/definitionEdit alert rule name/condition/severity
DELETE/api/v1/alerts/rules/{id}Delete alert rule (seeded defaults need ?force=true)
GET/api/v1/alerts/historyAlert history
PUT/api/v1/alerts/rules/{id}Update alert rule
GET/api/v1/audit/logAudit log
GET/api/v1/slo/targetsSLO targets
GET/api/v1/incidentsIncidents
GET/api/v1/changesChange log
POST/api/v1/changes/{id}/rollbackRollback change
GET/api/v1/nodes/drain/statusNode drain status
POST/api/v1/nodes/drainDrain node
POST/api/v1/nodes/uncordonUncordon node
GET/api/v1/flows/exportsFlow exports
POST/api/v1/flows/exportsCreate export
DELETE/api/v1/flows/exports/{id}Delete export
GET/api/v1/costs/breakdownCost breakdown
GET/api/v1/forecast/metricsForecast metrics
GET/api/v1/forecast/{metric}Forecast specific metric
POST/api/v1/diagnostics/runRun health checks
POST/api/v1/diagnostics/connectivityConnectivity test
POST/api/v1/troubleshoot/runTroubleshooting

eBPF Data (real kernel queries via bpftool)​

MethodPathDescription
GET/api/v1/ebpf/programsList all eBPF programs (117 programs)
GET/api/v1/ebpf/mapsList all eBPF maps (132 maps)
GET/api/v1/ebpf/conntrackConntrack table entries (12,066 entries)
GET/api/v1/ebpf/conntrack/statsConntrack statistics and summary
GET/api/v1/ebpf/policy-mapPolicy map entries per endpoint
GET/api/v1/ebpf/ipcacheIP cache identity mappings (35 entries)
GET/api/v1/ebpf/lbLoad balancer service/backend maps
GET/api/v1/ebpf/dropsDrop reason categories (16 categories)
GET/api/v1/ebpf/drops/statsDrop statistics and trends
GET/api/v1/ebpf/map/{id}Dump specific eBPF map by ID
GET/api/v1/ebpf/profilereBPF profiler with program/map metrics

WebSocket​

MethodPathDescription
WS/api/v1/ws/flowsReal-time flow stream
WS/api/v1/ws/metricsReal-time metrics stream

Development​

# Frontend
cd web-ui
npm install
npm run dev # Vite dev server (port 3000, proxies to :9191)
npm run build # Production build (tsc + vite)
npm run test # vitest
npm run lint # ESLint (0 errors)

# Backend
cd web-api
cargo run # API server on port 9191

# Full stack
docker-compose up

Build & Performance​

MetricValue
Production build~6s
Bundle size (gzip)~220 KB total
Code splitting4 vendor chunks + per-view lazy loading
TypeScriptStrict mode, 0 errors
ESLint0 errors, 0 warnings
Views64 lazy-loaded pages
Components34 shared UI components
API Endpoints75+
Hooks6 custom hooks

Security​

FeatureDetails
AuthenticationJWT Bearer tokens
AuthorizationRBAC with require_admin on destructive operations
Rate LimitingPer-endpoint rate limiting
CORSConfigurable origin whitelist
WebSocket LimitsMax 100 concurrent connections
Input ValidationRequest body validation on all POST/PUT endpoints