# oasislmf/oasisplatform architecture

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

- Interactive diagram: https://gitdiagram.com/oasislmf/oasisplatform
- Repository: https://github.com/oasislmf/oasisplatform

## Overview

##### Project Type and Purpose
- This is a full-stack, back-end-only application comprising:
– A Django REST API server (with Django ORM, migrations, multiple app modules, v1/v2 REST endpoints)
– A Celery‐based model execution worker handling asynchronous model runs
– A RabbitMQ (AMQP) message broker connecting the server and worker
– Persistent storage (MySQL/PostgreSQL + file store/S3) for data and model artifacts
– External services: Keycloak (OIDC), file storage (S3 or NFS), monitoring stack
– CI/CD pipelines and containerized deployments via Docker Compose and Kubernetes Helm charts

1. Client → Ingress (HTTP/HTTPS) → API Server
2. API Server ↔ Keycloak (OIDC/JWT)
3. API Server → Database (SQL queries)
4. API Server → File Store (S3 API or FS)
5. API Server → RabbitMQ (AMQP “task” messages)
6. Celery Worker ← RabbitMQ (consume tasks) → File Store (read model inputs, write outputs) → Database (update task/analysis records)
7. Worker‐Controller ↔ RabbitMQ / API Server (queue status) → Kubernetes API (scale worker Deployment)
8. Prometheus scrapes metrics from API Server, Celery, RabbitMQ; Grafana renders dashboards; Flower provides Celery UI

##### Architectural Patterns and Principles
- Microservices / decoupled services (API vs. worker)
- Event‐driven, asynchronous processing via Celery + AMQP
- 12-Factor app principles (separate config, backing services)
- Helm chart driven, GitOps‐friendly K8s deployments
- CI/CD pipelines automate image builds, tests, vulnerability scans

##### Detail Level
- Per-microservice config sources (e.g., Celery conf v1/v2, Django settings v1/v2) only if the audience needs to understand version branches
- Migrations step for Django (manage.py migrate) as a one-time DB preparation task
- CI/CD pipelines as a side pool feeding Docker Hub and triggering Helm releases

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layer 1: Edge
    subgraph "Layer 1: Edge"
        Client(("Clients / SDK / Postman")):::external
        Ingress["Ingress / Load Balancer"]:::infra
    end
    Client -->|HTTP/HTTPS| Ingress

    %% Layer 2: API
    subgraph "Layer 2: API"
        Keycloak(("Keycloak (OIDC)")):::external
        DjangoAPI["Django REST API Server"]:::api
        JWTEP["JWT Endpoints"]:::api
        SwaggerUI["Swagger / DRF API UI"]:::api
        Healthcheck["Healthcheck Endpoint"]:::api
    end
    Ingress -->|HTTP/JSON| DjangoAPI
    DjangoAPI -->|OIDC/JWT| Keycloak
    DjangoAPI -->|refresh_token/access_token| JWTEP
    DjangoAPI -->|browsable API| SwaggerUI
    DjangoAPI -->|healthcheck| Healthcheck

    %% Layer 3: Data & Messaging
    subgraph "Layer 3: Data & Messaging"
        RelationalDB(("Relational DB")):::database
        FileStorage(("File Storage (S3/local)")):::storage
        RabbitMQ(("RabbitMQ Broker")):::message
    end
    DjangoAPI -->|SQL| RelationalDB
    DjangoAPI -->|S3 GET/PUT| FileStorage
    DjangoAPI -->|AMQP task| RabbitMQ

    %% Layer 4: Processing
    subgraph "Layer 4: Processing"
        CeleryWorker["Celery Model Execution Worker"]:::worker
        WorkerController["Worker-Controller Autoscaler"]:::controller
        CeleryConf["Celery Config v1/v2"]:::config
        DjangoSettings["Django Settings v1/v2"]:::config
    end
    RabbitMQ -->|consume tasks| CeleryWorker
    CeleryWorker -->|read/write| FileStorage
    CeleryWorker -->|update records| RelationalDB
    WorkerController -->|queue status| RabbitMQ
    WorkerController -->|calls API| DjangoAPI
    WorkerController -->|scale via K8s API| WorkerController

    %% Layer 5: Observability
    subgraph "Layer 5: Observability"
        Prometheus["Prometheus"]:::monitor
        Grafana["Grafana"]:::monitor
        Flower["Flower UI"]:::monitor
    end
    Prometheus -->|scrape metrics| DjangoAPI
    Prometheus -->|scrape metrics| CeleryWorker
    Prometheus -->|scrape metrics| RabbitMQ
    Grafana -->|dashboards| Prometheus
    Flower -->|UI| CeleryWorker

    %% Side: Deployment & CI/CD
    subgraph "Side: Deployment & CI/CD"
        DockerCompose["Docker Compose (local)"]:::infra
        HelmPlatform["Helm: oasis-platform"]:::infra
        HelmModels["Helm: oasis-models"]:::infra
        HelmMonitoring["Helm: oasis-monitoring"]:::infra
        CICD["CI/CD Pipelines"]:::infra
    end
    CICD -->|build/publish| DockerCompose
    CICD -->|Helm Release| HelmPlatform
    CICD -->|Helm Release| HelmModels
    CICD -->|Helm Release| HelmMonitoring
    DockerCompose -->|deploy| DjangoAPI
    DockerCompose -->|deploy| RabbitMQ
    DockerCompose -->|deploy| RelationalDB
    DockerCompose -->|deploy| FileStorage
    HelmPlatform -->|deploy| DjangoAPI
    HelmPlatform -->|deploy| Keycloak
    HelmPlatform -->|deploy| RelationalDB
    HelmMonitoring -->|deploy| Prometheus
    HelmMonitoring -->|deploy| Grafana
    HelmMonitoring -->|deploy| Flower

    %% Click Events
    click DjangoAPI "https://github.com/oasislmf/oasisplatform/tree/main/src/server/oasisapi"
    click CeleryWorker "https://github.com/oasislmf/oasisplatform/tree/main/src/model_execution_worker"
    click RabbitMQ "https://github.com/oasislmf/oasisplatform/blob/main/compose/debug.docker-compose.yml"
    click RelationalDB "https://github.com/oasislmf/oasisplatform/blob/main/kubernetes/charts/oasis-platform/templates/databases.yaml"
    click FileStorage "https://github.com/oasislmf/oasisplatform/blob/main/src/common/filestore/filestore.py"
    click Keycloak "https://github.com/oasislmf/oasisplatform/blob/main/kubernetes/charts/oasis-platform/templates/keycloak.yaml"
    click JWTEP "https://github.com/oasislmf/oasisplatform/tree/main/src/server/oasisapi/auth"
    click Ingress "https://github.com/oasislmf/oasisplatform/blob/main/kubernetes/charts/oasis-platform/templates/ingress.yaml"
    click WorkerController "https://github.com/oasislmf/oasisplatform/blob/main/kubernetes/worker-controller/src/worker_controller.py"
    click CeleryConf "https://github.com/oasislmf/oasisplatform/blob/main/src/conf/celeryconf_v1.py"
    click DjangoSettings "https://github.com/oasislmf/oasisplatform/blob/main/src/server/oasisapi/settings/v1.py"
    click Healthcheck "https://github.com/oasislmf/oasisplatform/blob/main/src/server/oasisapi/healthcheck/views.py"
    click SwaggerUI "https://github.com/oasislmf/oasisplatform/blob/main/src/server/oasisapi/swagger.py"
    click CICD "https://github.com/oasislmf/oasisplatform/blob/main/.github/workflows/build-images.yml"
    click DockerCompose "https://github.com/oasislmf/oasisplatform/blob/main/docker-compose.yml"
    click HelmPlatform "https://github.com/oasislmf/oasisplatform/tree/main/kubernetes/charts/oasis-platform"
    click HelmModels "https://github.com/oasislmf/oasisplatform/tree/main/kubernetes/charts/oasis-models"
    click HelmMonitoring "https://github.com/oasislmf/oasisplatform/tree/main/kubernetes/charts/oasis-monitoring"
    click Prometheus "https://github.com/oasislmf/oasisplatform/tree/main/kubernetes/charts/oasis-monitoring/templates"
    click Grafana "https://github.com/oasislmf/oasisplatform/tree/main/kubernetes/charts/oasis-monitoring/templates"
    click Flower "https://github.com/oasislmf/oasisplatform/blob/main/kubernetes/charts/oasis-monitoring/templates/flower.yaml"

    %% Styles
    classDef api fill:#b3cde3,stroke:#005b96,color:#000
    classDef worker fill:#c7e9c0,stroke:#238b45,color:#000
    classDef database fill:#fddbc7,stroke:#b35806,color:#000
    classDef storage fill:#fddbc7,stroke:#b35806,color:#000
    classDef message fill:#f2f0f7,stroke:#4d4d4d,color:#000
    classDef external fill:#d9d9d9,stroke:#636363,color:#000
    classDef infra fill:#ece2f0,stroke:#7b3294,color:#000
    classDef controller fill:#c7e9c0,stroke:#2ca25f,color:#000
    classDef monitor fill:#f7f7f7,stroke:#252525,color:#000
    classDef config fill:#fff7bc,stroke:#fec44f,color:#000
```
