How gacwr/openuba works
Purpose and Entry Points
OpenUBA is a Kubernetes-native UEBA/security-analytics platform: ingest behavioral data, run inspectable ML models, evaluate detection rules, and manage anomalies, alerts, and cases. Primary application entry points are FastAPI in core/fastapi_app.py, the Next.js App Router in interface/app/layout.tsx, the Kubernetes controller in core/operator/main.py, and the Python SDK in sdk/src/openuba/client.py.
API, Identity, and Application Domain
The Python backend exposes REST APIs for models, datasets, jobs, rules, workspaces, anomalies, cases, and settings through router modules such as core/api_routers/models.py, core/api_routers/pipelines.py, and core/api_routers/workspaces.py. It applies JWT authentication/RBAC through core/auth.py; API schemas separate request/response contracts from persistence. Domain-facing services coordinate workflows rather than placing them in endpoints, notably core/services/model_orchestrator.py, core/services/rule_engine.py, and core/services/workspace_service.py.
System of Record and Query Boundary
PostgreSQL is the authoritative metadata store for users, model lifecycle, jobs, datasets, rules, anomalies, cases, and workspace records. SQLAlchemy models and repository layer form the persistence boundary: core/db/models.py, core/database.py, and core/repositories/model_repository.py. Schema evolution is managed through alembic/env.py and alembic/versions/001_initial_schema.py. PostGraphile exposes database-derived GraphQL, including subscription-oriented UI access, via core/graphql/postgraphile.py and k8s/postgraphile-deployment.yaml.
Data Ingestion and Analytics Stores
Ingestion services move configured datasets into compute/search backends: core/services/data_ingestion.py, core/integrations/spark.py, and core/integrations/elasticsearch.py. Models access data through pluggable loaders—local pandas files, Elasticsearch, Spark, and source groups—in core/model_modules/local_pandas/local_pandas.py, core/model_modules/es/es.py, and core/model_modules/source_group/loader.py. Spark supplies distributed compute and Elasticsearch supports searchable analytics; PostgreSQL retains platform metadata rather than replacing these data-plane systems.
Model Registry, Installation, and Execution
Model discovery/install is adapter-based, allowing local filesystem, GitHub, OpenUBA Hub, HuggingFace, and Kubeflow sources through core/registry/registry_service.py, core/registry/adapters/github_adapter.py, and core/services/model_installer.py. Installed model packages follow MODEL.py plus manifest conventions, represented by core/model_library/basic_model/MODEL.py and core/model_library/basic_model/model.yaml. Training/inference orchestration submits isolated executions; framework-specific runner images execute model code via docker/model-runner/runner.py and Dockerfiles under docker/model-runner/.
Kubernetes Execution and Workspaces
The custom Kopf operator watches training, inference, pipeline, and workspace CRDs, then creates ephemeral Jobs/pods instead of persistent per-model services. Control logic is in core/operator/pipeline_handler.py and core/operator/workspace_handler.py; resource contracts are in k8s/crds/ubatraining.yaml, k8s/crds/ubainference.yaml, and k8s/crds/ubaworkspace-crd.yaml. Shared persistent volumes bridge runners, artifacts, source code, and datasets. Managed notebook workspaces use the SDK (sdk/src/openuba/context.py) to register models, submit jobs, and publish visualizations.
Detection-to-Investigation Flow
Model inference produces scores/results that become platform anomalies; the rule engine evaluates deterministic rule graphs against model outputs and emits alerts, which can link to cases. Relevant boundaries are core/services/rule_engine.py, core/api_routers/anomalies.py, and core/api_routers/cases.py. Scheduling is centralized in core/services/model_scheduler.py. The frontend renders these operational workflows and talks primarily to GraphQL via interface/src/lib/apollo-client.ts, while REST handles command-style backend operations.
Deployment Topology
Containers deploy backend, frontend, operator, PostGraphile, PostgreSQL, Spark, and Elasticsearch to Kubernetes. Core manifests include k8s/backend-deployment.yaml, k8s/operator-deployment.yaml, and k8s/spark-deployment.yaml; Docker Compose supports a local topology in docker-compose.yml. The frontend is Next.js/TypeScript, the backend/operator/SDK are Python, and external LLM providers are mediated by core/services/chat_service.py (Ollama, OpenAI, Claude, Gemini).
Main entry points: fastapi_app.py FastAPI backend · model_orchestrator.py Domain services · main.py Kopf operator · runner.py Isolated model runners
Components 19
Platform API
- FastAPI backend · REST command APIs and platform coordination.
core/fastapi_app.py - JWT & RBAC
core/auth.py - Domain services · Coordinates model, rule, and workspace workflows.
core/services/model_orchestrator.py - PostgreSQL metadata · Authoritative platform metadata and investigation records.
core/database.py - Repository layer
core/repositories/model_repository.py - PostGraphile GraphQL · Database-derived GraphQL with subscriptions.
core/graphql/postgraphile.py
Data & Detection
- Data ingestion
core/services/data_ingestion.py - Pluggable data loaders · Loads local, Elasticsearch, Spark, and source-group data.
core/model_modules/local_pandas/local_pandas.py - Spark
core/integrations/spark.py - Elasticsearch
core/integrations/elasticsearch.py - Rule engine · Evaluates rule graphs against model outputs.
core/services/rule_engine.py - Model registry · Discovers model packages from local and remote sources.
core/registry/registry_service.py
Kubernetes Execution
- Model scheduler
core/services/model_scheduler.py - Kopf operator · Reconciles training, inference, pipeline, and workspace CRDs.
core/operator/main.py - OpenUBA CRDs
k8s/crds/ubatraining.yaml - Isolated model runners · Framework-specific containers execute training and inference.
docker/model-runner/runner.py - Managed workspaces · Notebook pods share data and artifacts with runners.
core/operator/workspace_handler.py
Clients
- Next.js frontend
interface/app/layout.tsx - Python SDK
sdk/src/openuba/client.py
Connections 22
- Next.js frontend → PostGraphile GraphQL: queries and subscriptions
- Next.js frontend → FastAPI backend: REST commands
- FastAPI backend → JWT & RBAC: authenticates
- FastAPI backend → Domain services: delegates workflows
- Domain services → Repository layer: persists platform state
- Repository layer → PostgreSQL metadata: SQLAlchemy access
- PostGraphile GraphQL → PostgreSQL metadata: database-derived schema
- Data ingestion → Spark: loads distributed data
- Data ingestion → Elasticsearch: indexes analytics data
- Pluggable data loaders → Spark: reads compute data
- Pluggable data loaders → Elasticsearch: reads searchable data
- Model registry → Domain services: installs model packages
- Domain services → Model scheduler: schedules training and inference
- Model scheduler → Kopf operator: submits custom resources
- OpenUBA CRDs → Kopf operator: watched resources
- Kopf operator → Isolated model runners: creates ephemeral Jobs
- Kopf operator → Managed workspaces: creates workspace pods
- Isolated model runners → Pluggable data loaders: loads model inputs
- Isolated model runners → Rule engine: emits inference results
- Rule engine → Repository layer: records alerts and cases
- Python SDK → FastAPI backend: registers models and submits jobs
- Python SDK → Managed workspaces: runs in notebooks