# redhat-cop/babylon architecture

> Architecture diagram of the GitHub repository redhat-cop/babylon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/redhat-cop/babylon
- Repository: https://github.com/redhat-cop/babylon

## Overview

##### Project type and purpose
- Babylon is a Kubernetes-native, multi-service suite deployed on OpenShift. It consists of several custom controllers (“operators”), RESTful microservices, and front-end UIs.
- Its goal is to manage catalogs, workshops, sandboxes, incident tracking, cost reporting, ratings, and lab UIs via CRDs and microservices.

##### File structure
- Top-level folders:
- admin, catalog, ratings → each is a REST API service (Python + FastAPI/Flask) with its own database models, routers, schemas, and Docker/S2I build files.
- catalog/ui → React/TypeScript front-end served by Nginx.
- agnosticv-operator, catalog-manager, workshop-manager, cost-tracker, lab-ui-manager, notifier → each implements a Python/Kopf operator under `operator/` and has a Helm chart under `helm/`.
- helm/ + openshift/config/ → umbrella Helm chart and environment-specific overrides.
- playbooks/ and tools/ → Ansible automation scripts for initial setup.

##### README for additional insights
- It confirms a Helm-driven deployment and ties back to multiple GitHub repos.

a. Main components (grouped by layer)
- Control Plane
– Kubernetes API Server & CRDs (from top-level `helm/crds`)
– Operators (each watching specific CRDs):
· AgnosticV Operator
· Catalog Manager Operator
· Workshop Manager Operator
· Cost-Tracker Operator
· Lab-UI Manager Operator
· Notifier Operator
- Data Plane
– Microservices: admin/api, catalog/api, ratings/api
– UIs: Catalog React App, Status Page
- Data Stores
– PostgreSQL (per-service databases; database-secrets.yaml)
– Redis (Notifier queue)
- External Services
– Salesforce API (catalog integrations)
– SMTP server (Notifier)
– OpenShift OAuth Proxy (authentication)

b. Relationships & interactions
- Operators ←── watch CRD events via K8s API → reconcile → create/update K8s resources (Deployments, Secrets, ConfigMaps).
- Helm umbrella chart ←── CI/CD pipelines (GitHub Actions & GitLab CI) → deploy subcharts (operators + microservices + CRDs).
- React UI −−HTTP/S→ OAuth Proxy −−> Kubernetes Service −−> catalog/api, admin/api, ratings/api
- Microservices −−SQL→ PostgreSQL; optionally −−Redis Pub/Sub→ Redis
- Notifier Operator −−listens to CR events→ enqueues messages in Redis −−> SMTP server

c. Architectural patterns & design principles
- Operator Pattern (Kopf + CRDs) for declarative control loops
- Microservices per bounded context
- Event-driven reconciliation vs synchronous HTTP/API calls
- Separation of control-plane (operators) vs data-plane (UIs + APIs)
- Helm-based packaging and GitOps-style CI

d. Key technologies & frameworks
- Python + Kopf for operators
- FastAPI/Flask + Pydantic for REST APIs
- React + Redux for front-end
- PostgreSQL + SQLAlchemy
- Redis for message queuing
- Helm for packaging & templating
- OpenShift S2I or Containerfile for builds
- Ansible playbooks for OpenShift setup

## Diagram (Mermaid)

```mermaid
graph TB
  subgraph "Control Plane"
    subgraph "CRD Definitions"
      CRDs["CRD Definitions"]:::crd
    end
    AVO["AgnosticV Operator"]:::operator
    CMO["Catalog Manager Operator"]:::operator
    WMO["Workshop Manager Operator"]:::operator
    CTO["Cost-Tracker Operator"]:::operator
    LMO["Lab-UI Manager Operator"]:::operator
    NO["Notifier Operator"]:::operator
  end

  subgraph "Data Plane"
    subgraph Microservices
      ADMIN["Admin Service"]:::service
      CATALOG_MS["Catalog Service"]:::service
      RATINGS["Ratings Service"]:::service
    end
    subgraph UIs
      CATALOG_UI["Catalog React UI"]:::ui
      STATUS["Status Page UI"]:::ui
    end
  end

  subgraph "Data Stores"
    POSTGRES["PostgreSQL"]:::db
    REDIS["Redis"]:::db
  end

  subgraph "External Services"
    SALESFORCE["Salesforce API"]:::external
    SMTP["SMTP Server"]:::external
    OAUTH["OpenShift OAuth Proxy"]:::external
  end

  subgraph "CI/CD & Deployment"
    CICD["CI/CD Pipeline"]:::ci
    HELM["Helm Umbrella Chart"]:::helm
    OS["OpenShift Overrides"]:::helm
  end

  subgraph "Infrastructure Setup"
    ANS["Ansible Playbooks & Tools"]:::infra
  end

  %% Connections
  CICD -.->|deploy| HELM
  HELM -.->|installs CRDs| CRDs
  HELM -.->|deploys operators & services| AVO & CMO & WMO & CTO & LMO & NO & ADMIN & CATALOG_MS & RATINGS

  CRDs ---|watches| AVO & CMO & WMO & CTO & LMO & NO
  AVO & CMO & WMO & CTO & LMO & NO -->|"reconcile"| HELM

  CATALOG_UI -->|"HTTPS"| OAUTH
  STATUS -->|"HTTPS"| OAUTH
  OAUTH -->|"authn"| ADMIN & CATALOG_MS & RATINGS

  ADMIN -->|"SQL"| POSTGRES
  CATALOG_MS -->|"SQL"| POSTGRES
  RATINGS -->|"SQL"| POSTGRES

  CATALOG_MS -->|"REST"| SALESFORCE

  NO ---|enqueues| REDIS
  REDIS -->|"Pub/Sub"| SMTP

  ANS -->|provisions| CICD & HELM & OS

  %% Click events
  click AVO "https://github.com/redhat-cop/babylon/tree/main/agnosticv-operator/operator"
  click AVO "https://github.com/redhat-cop/babylon/tree/main/agnosticv-operator/helm"
  click CMO "https://github.com/redhat-cop/babylon/tree/main/catalog-manager/operator"
  click CMO "https://github.com/redhat-cop/babylon/tree/main/catalog-manager/helm"
  click WMO "https://github.com/redhat-cop/babylon/tree/main/workshop-manager/operator"
  click WMO "https://github.com/redhat-cop/babylon/tree/main/workshop-manager/helm"
  click CTO "https://github.com/redhat-cop/babylon/tree/main/cost-tracker/operator"
  click CTO "https://github.com/redhat-cop/babylon/tree/main/cost-tracker/helm"
  click LMO "https://github.com/redhat-cop/babylon/tree/main/lab-ui-manager/operator"
  click LMO "https://github.com/redhat-cop/babylon/tree/main/lab-ui-manager/helm"
  click NO "https://github.com/redhat-cop/babylon/tree/main/notifier/operator"
  click NO "https://github.com/redhat-cop/babylon/tree/main/notifier/helm"
  click ADMIN "https://github.com/redhat-cop/babylon/tree/main/admin/api"
  click ADMIN "https://github.com/redhat-cop/babylon/tree/main/admin/Dockerfile"
  click ADMIN "https://github.com/redhat-cop/babylon/tree/main/admin/helm"
  click CATALOG_MS "https://github.com/redhat-cop/babylon/tree/main/catalog/api"
  click CATALOG_MS "https://github.com/redhat-cop/babylon/tree/main/catalog/helm"
  click RATINGS "https://github.com/redhat-cop/babylon/tree/main/ratings/api"
  click CATALOG_UI "https://github.com/redhat-cop/babylon/tree/main/catalog/ui"
  click CATALOG_UI "https://github.com/redhat-cop/babylon/tree/main/catalog/ui/Dockerfile"
  click CATALOG_UI "https://github.com/redhat-cop/babylon/tree/main/catalog/ui/nginx-default-cfg"
  click STATUS "https://github.com/redhat-cop/babylon/tree/main/catalog/status"
  click HELM "https://github.com/redhat-cop/babylon/blob/main/helm/Chart.yaml"
  click HELM "https://github.com/redhat-cop/babylon/tree/main/helm/crds/*"
  click HELM "https://github.com/redhat-cop/babylon/tree/main/helm/templates"
  click OS "https://github.com/redhat-cop/babylon/tree/main/openshift/config"
  click ANS "https://github.com/redhat-cop/babylon/tree/main/playbooks/"
  click ANS "https://github.com/redhat-cop/babylon/tree/main/tools/"

  %% Styles
  classDef operator fill:#cfe2f3,stroke:#2f5597
  classDef service fill:#d9ead3,stroke:#38761d
  classDef ui fill:#e2efda,stroke:#6aa84f
  classDef db fill:#f9cb9c,stroke:#b45f06
  classDef external fill:#f4cccc,stroke:#a61c00
  classDef ci fill:#ffe599,stroke:#b07d00
  classDef helm fill:#ead1dc,stroke:#881c65
  classDef infra fill:#d9d2e9,stroke:#674ea7
  classDef crd fill:#fff2cc,stroke:#bf9000
```
