# dars1k23/swiftml-k8s architecture

> Architecture diagram of the GitHub repository dars1k23/swiftml-k8s, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dars1k23/swiftml-k8s
- Repository: https://github.com/dars1k23/swiftml-k8s

## Overview

swiftml-k8s compiles a validated YAML model specification into a Docker image and Kubernetes Deployment/Service, then runs a FastAPI inference service. The primary workflow is configuration → compilation → image build and cluster deployment → health checks or batched predictions. The README documents the end-to-end deployment and framework handoff; runtime details below are based on the sampled source, so unsampled template behavior is represented only where documented or directly referenced.

Main entry points: [`main.py`](https://github.com/dars1k23/swiftml-k8s/blob/main/main.py) (Compiler entrypoint), [`compiler.py`](https://github.com/dars1k23/swiftml-k8s/blob/main/compiler.py) (Artifact compiler), [`server_core.py`](https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py) (Inference API), [`mlkube.yaml`](https://github.com/dars1k23/swiftml-k8s/blob/main/mlkube.yaml) (Model YAML)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compile["Configuration and compilation"]
  node_yaml["Model YAML<br/>[mlkube.yaml]"]
  node_entry["Compiler entrypoint<br/>[main.py]"]
  node_validation["Config validation<br/>[config.py]"]
  node_compiler["Artifact compiler<br/>[compiler.py]"]
  node_docker_template["Dockerfile template<br/>[Dockerfile.tmpl]"]
  node_k8s_template["Kubernetes template<br/>[deployment.tmpl]"]
end

subgraph group_deploy["Image and Kubernetes deployment"]
  node_dockerfile["Generated Dockerfile<br/>[Dockerfile.tmpl]"]
  node_manifest["Generated manifests<br/>[deployment.tmpl]"]
end

subgraph group_runtime["Inference runtime"]
  node_api["Inference API<br/>[server_core.py]"]
  node_model_loading["Model initialization<br/>[server_core.py]"]
  node_loaders["Framework loaders<br/>[server_core.py]"]
  node_model_file["Model artifact"]
  node_prediction["Prediction handler<br/>[server_core.py]"]
  node_health["Health endpoint<br/>[server_core.py]"]
end

subgraph group_integrations["External systems"]
  node_docker["Docker engine"]
  node_cluster["Kubernetes cluster"]
end

node_user(("Model author"))

node_user -->|"defines model"| node_yaml
node_yaml -->|"reads config"| node_entry
node_entry -->|"validates"| node_validation
node_entry -->|"creates compiler"| node_compiler
node_compiler -->|"formats Dockerfile"| node_docker_template
node_compiler -->|"formats manifests"| node_k8s_template
node_compiler -->|"uses config type"| node_validation
node_entry -->|"writes output"| node_dockerfile
node_entry -->|"builds image"| node_docker
node_entry -->|"writes output"| node_manifest
node_entry -->|"applies manifests"| node_cluster
node_manifest -->|"deploys service"| node_cluster
node_dockerfile -->|"sets framework ENV"| node_model_loading
node_model_loading -->|"selects loader"| node_loaders
node_loaders -->|"loads model"| node_model_file
node_user -->|"sends requests"| node_api
node_api -->|"routes predict"| node_prediction
node_prediction -->|"calls predict"| node_model_file
node_api -->|"routes health"| node_health
node_model_loading -->|"initializes at startup"| node_api

click node_yaml "https://github.com/dars1k23/swiftml-k8s/blob/main/mlkube.yaml"
click node_entry "https://github.com/dars1k23/swiftml-k8s/blob/main/main.py"
click node_validation "https://github.com/dars1k23/swiftml-k8s/blob/main/config.py"
click node_compiler "https://github.com/dars1k23/swiftml-k8s/blob/main/compiler.py"
click node_docker_template "https://github.com/dars1k23/swiftml-k8s/blob/main/templates/Dockerfile.tmpl"
click node_k8s_template "https://github.com/dars1k23/swiftml-k8s/blob/main/templates/deployment.tmpl"
click node_dockerfile "https://github.com/dars1k23/swiftml-k8s/blob/main/templates/Dockerfile.tmpl"
click node_manifest "https://github.com/dars1k23/swiftml-k8s/blob/main/templates/deployment.tmpl"
click node_api "https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py"
click node_model_loading "https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py"
click node_loaders "https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py"
click node_prediction "https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py"
click node_health "https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_yaml,node_entry,node_validation,node_compiler,node_docker_template,node_k8s_template toneBlue
class node_dockerfile,node_manifest toneAmber
class node_api,node_model_loading,node_loaders,node_model_file,node_prediction,node_health toneMint
class node_docker,node_cluster toneRose
class node_user toneIndigo
```

## Components

### Configuration and compilation

- [Model YAML](https://github.com/dars1k23/swiftml-k8s/blob/main/mlkube.yaml): `mlkube.yaml`
- [Compiler entrypoint](https://github.com/dars1k23/swiftml-k8s/blob/main/main.py): `main.py`
- [Config validation](https://github.com/dars1k23/swiftml-k8s/blob/main/config.py): `config.py`
- [Artifact compiler](https://github.com/dars1k23/swiftml-k8s/blob/main/compiler.py): `compiler.py`
- [Dockerfile template](https://github.com/dars1k23/swiftml-k8s/blob/main/templates/Dockerfile.tmpl): `templates/Dockerfile.tmpl`
- [Kubernetes template](https://github.com/dars1k23/swiftml-k8s/blob/main/templates/deployment.tmpl): `templates/deployment.tmpl`

### Image and Kubernetes deployment

- [Generated Dockerfile](https://github.com/dars1k23/swiftml-k8s/blob/main/templates/Dockerfile.tmpl): `templates/Dockerfile.tmpl`
- [Generated manifests](https://github.com/dars1k23/swiftml-k8s/blob/main/templates/deployment.tmpl): `templates/deployment.tmpl`

### Inference runtime

- [Inference API](https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py): `server_core.py`
- [Model initialization](https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py): `server_core.py`
- [Framework loaders](https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py): `server_core.py`
- **Model artifact**
- [Prediction handler](https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py): `server_core.py`
- [Health endpoint](https://github.com/dars1k23/swiftml-k8s/blob/main/server_core.py): `server_core.py`

### External systems

- **Docker engine**
- **Kubernetes cluster**

### Other components

- **Model author**

## Connections

- Model author → Model YAML: defines model (evidence: `README.md`)
- Model YAML → Compiler entrypoint: reads config (evidence: `main.py`)
- Compiler entrypoint → Config validation: validates (evidence: `main.py`)
- Compiler entrypoint → Artifact compiler: creates compiler (evidence: `main.py`)
- Artifact compiler → Dockerfile template: formats Dockerfile (evidence: `compiler.py`)
- Artifact compiler → Kubernetes template: formats manifests (evidence: `compiler.py`)
- Artifact compiler → Config validation: uses config type (evidence: `compiler.py`)
- Compiler entrypoint → Generated Dockerfile: writes output (evidence: `main.py`)
- Compiler entrypoint → Docker engine: builds image (evidence: `main.py`)
- Compiler entrypoint → Generated manifests: writes output (evidence: `main.py`)
- Compiler entrypoint → Kubernetes cluster: applies manifests (evidence: `main.py`)
- Generated manifests → Kubernetes cluster: deploys service (evidence: `README.md`)
- Generated Dockerfile → Model initialization: sets framework ENV (evidence: `README.md`)
- Model initialization → Framework loaders: selects loader (evidence: `server_core.py`)
- Framework loaders → Model artifact: loads model (evidence: `server_core.py`)
- Model author → Inference API: sends requests (evidence: `README.md`)
- Inference API → Prediction handler: routes predict (evidence: `server_core.py`)
- Prediction handler → Model artifact: calls predict (evidence: `server_core.py`)
- Inference API → Health endpoint: routes health (evidence: `server_core.py`)
- Model initialization → Inference API: initializes at startup (evidence: `server_core.py`)
