# kenza-ai/sagify architecture

> Architecture diagram of the GitHub repository kenza-ai/sagify, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kenza-ai/sagify
- Repository: https://github.com/kenza-ai/sagify

## Overview

Sagify is a CLI for managing machine-learning workflows on AWS SageMaker, alongside an HTTP LLM Gateway for chat, embeddings, and image generation. The main workflow runs through CLI commands into cloud or LLM APIs, then SageMaker operations; gateway requests route to endpoint handlers and provider clients. The README documents OpenAI and SageMaker backends and deployment capabilities. Some API and provider wiring is unsampled, so those links are omitted or marked unverified rather than inferred.

Main entry points: [`sagify/commands`](https://github.com/kenza-ai/sagify/tree/main/sagify/commands) (CLI Commands), [`sagify/api/cloud.py`](https://github.com/kenza-ai/sagify/blob/main/sagify/api/cloud.py) (Cloud API), [`sagify/sagemaker/sagemaker.py`](https://github.com/kenza-ai/sagify/blob/main/sagify/sagemaker/sagemaker.py) (SageMaker Operations), [`sagify/llm_gateway/api/v1/routes.py`](https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/api/v1/routes.py) (Versioned Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and Configuration"]
  node_entry["CLI Entry<br/>[__main__.py]"]
  node_commands["CLI Commands"]
  node_config["Project Config<br/>[config.py]"]
end

subgraph group_ml["SageMaker Workflows"]
  node_cloud_api["Cloud API<br/>[cloud.py]"]
  node_llm_api["LLM API<br/>[llm.py]"]
  node_sagemaker["SageMaker Operations<br/>[sagemaker.py]"]
  node_streaming["Streaming Inference"]
  node_training_templates["Training Templates<br/>[training.py]"]
  node_inference_templates["Inference Templates<br/>[prediction.py]"]
end

subgraph group_gateway["LLM Gateway"]
  node_gateway_app["Gateway App<br/>[main.py]"]
  node_routes["Versioned Routes<br/>[routes.py]"]
  node_chat_endpoint["Chat Endpoint<br/>[chat.py]"]
  node_embedding_endpoint["Embedding Endpoint<br/>[embeddings.py]"]
  node_image_endpoint["Image Endpoint<br/>[images.py]"]
  node_schemas["Request Schemas"]
  node_services["Gateway Services"]
end

subgraph group_providers["Model Providers"]
  node_factory["Client Factory<br/>[client_factory.py]"]
  node_openai["OpenAI Client<br/>[client.py]"]
  node_anthropic["Anthropic Client<br/>[client.py]"]
  node_sm_client["SageMaker Client<br/>[sagemaker.py]"]
end

node_user(("CLI User"))
node_provider_services{{"Model APIs"}}
node_aws{{"AWS Services"}}

node_user -->|"invokes"| node_entry
node_entry -->|"dispatches"| node_commands
node_commands -->|"calls"| node_cloud_api
node_commands -->|"calls"| node_llm_api
node_commands -->|"reads config"| node_config
node_cloud_api -->|"loads config"| node_config
node_cloud_api -->|"runs jobs"| node_sagemaker
node_cloud_api -->|"manages streams"| node_streaming
node_sagemaker -.->|"provisions models"| node_aws
node_streaming -->|"uses queues and functions"| node_aws
node_sagemaker -.->|"uses training code"| node_training_templates
node_sagemaker -.->|"uses inference code"| node_inference_templates
node_gateway_app -->|"mounts routes"| node_routes
node_routes -->|"routes requests"| node_chat_endpoint
node_routes -->|"routes requests"| node_embedding_endpoint
node_routes -->|"routes requests"| node_image_endpoint
node_chat_endpoint -->|"uses DTOs"| node_schemas
node_embedding_endpoint -->|"uses DTOs"| node_schemas
node_image_endpoint -->|"uses DTOs"| node_schemas
node_chat_endpoint -->|"delegates"| node_services
node_embedding_endpoint -->|"delegates"| node_services
node_image_endpoint -->|"delegates"| node_services
node_services -->|"selects clients"| node_factory
node_factory -->|"creates client"| node_openai
node_factory -->|"creates client"| node_anthropic
node_factory -->|"creates client"| node_sm_client
node_openai -->|"calls provider API"| node_provider_services
node_anthropic -->|"calls provider API"| node_provider_services
node_sm_client -.->|"invokes endpoints"| node_aws

click node_entry "https://github.com/kenza-ai/sagify/blob/main/sagify/__main__.py"
click node_commands "https://github.com/kenza-ai/sagify/tree/main/sagify/commands"
click node_config "https://github.com/kenza-ai/sagify/blob/main/sagify/config/config.py"
click node_cloud_api "https://github.com/kenza-ai/sagify/blob/main/sagify/api/cloud.py"
click node_llm_api "https://github.com/kenza-ai/sagify/blob/main/sagify/api/llm.py"
click node_sagemaker "https://github.com/kenza-ai/sagify/blob/main/sagify/sagemaker/sagemaker.py"
click node_streaming "https://github.com/kenza-ai/sagify/blob/main/sagify/streaming_inference/streaming_inference.py"
click node_training_templates "https://github.com/kenza-ai/sagify/blob/main/sagify/template/sagify_base/training/training.py"
click node_inference_templates "https://github.com/kenza-ai/sagify/blob/main/sagify/template/sagify_base/prediction/prediction.py"
click node_gateway_app "https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/main.py"
click node_routes "https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/api/v1/routes.py"
click node_chat_endpoint "https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/api/v1/endpoints/chat.py"
click node_embedding_endpoint "https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/api/v1/endpoints/embeddings.py"
click node_image_endpoint "https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/api/v1/endpoints/images.py"
click node_schemas "https://github.com/kenza-ai/sagify/tree/main/sagify/llm_gateway/schemas"
click node_services "https://github.com/kenza-ai/sagify/tree/main/sagify/llm_gateway/services"
click node_factory "https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/providers/client_factory.py"
click node_openai "https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/providers/openai/client.py"
click node_anthropic "https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/providers/anthropic/client.py"
click node_sm_client "https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/providers/aws/sagemaker.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_entry,node_commands,node_config,node_user toneBlue
class node_cloud_api,node_llm_api,node_sagemaker,node_streaming,node_training_templates,node_inference_templates toneAmber
class node_gateway_app,node_routes,node_chat_endpoint,node_embedding_endpoint,node_image_endpoint,node_schemas,node_services,node_provider_services toneMint
class node_factory,node_openai,node_anthropic,node_sm_client toneRose
class node_aws toneIndigo
```

## Components

### CLI and Configuration

- [CLI Entry](https://github.com/kenza-ai/sagify/blob/main/sagify/__main__.py): `sagify/__main__.py`
- [CLI Commands](https://github.com/kenza-ai/sagify/tree/main/sagify/commands): `sagify/commands`
- [Project Config](https://github.com/kenza-ai/sagify/blob/main/sagify/config/config.py): `sagify/config/config.py`

### SageMaker Workflows

- [Cloud API](https://github.com/kenza-ai/sagify/blob/main/sagify/api/cloud.py): `sagify/api/cloud.py`
- [LLM API](https://github.com/kenza-ai/sagify/blob/main/sagify/api/llm.py): `sagify/api/llm.py`
- [SageMaker Operations](https://github.com/kenza-ai/sagify/blob/main/sagify/sagemaker/sagemaker.py): `sagify/sagemaker/sagemaker.py`
- [Streaming Inference](https://github.com/kenza-ai/sagify/blob/main/sagify/streaming_inference/streaming_inference.py): `sagify/streaming_inference/streaming_inference.py`
- [Training Templates](https://github.com/kenza-ai/sagify/blob/main/sagify/template/sagify_base/training/training.py): `sagify/template/sagify_base/training/training.py`
- [Inference Templates](https://github.com/kenza-ai/sagify/blob/main/sagify/template/sagify_base/prediction/prediction.py): `sagify/template/sagify_base/prediction/prediction.py`

### LLM Gateway

- [Gateway App](https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/main.py): `sagify/llm_gateway/main.py`
- [Versioned Routes](https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/api/v1/routes.py): `sagify/llm_gateway/api/v1/routes.py`
- [Chat Endpoint](https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/api/v1/endpoints/chat.py): `sagify/llm_gateway/api/v1/endpoints/chat.py`
- [Embedding Endpoint](https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/api/v1/endpoints/embeddings.py): `sagify/llm_gateway/api/v1/endpoints/embeddings.py`
- [Image Endpoint](https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/api/v1/endpoints/images.py): `sagify/llm_gateway/api/v1/endpoints/images.py`
- [Request Schemas](https://github.com/kenza-ai/sagify/tree/main/sagify/llm_gateway/schemas): `sagify/llm_gateway/schemas`
- [Gateway Services](https://github.com/kenza-ai/sagify/tree/main/sagify/llm_gateway/services): `sagify/llm_gateway/services`

### Model Providers

- [Client Factory](https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/providers/client_factory.py): `sagify/llm_gateway/providers/client_factory.py`
- [OpenAI Client](https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/providers/openai/client.py): `sagify/llm_gateway/providers/openai/client.py`
- [Anthropic Client](https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/providers/anthropic/client.py): `sagify/llm_gateway/providers/anthropic/client.py`
- [SageMaker Client](https://github.com/kenza-ai/sagify/blob/main/sagify/llm_gateway/providers/aws/sagemaker.py): `sagify/llm_gateway/providers/aws/sagemaker.py`

### Other components

- **CLI User**
- **Model APIs**
- **AWS Services**

## Connections

- CLI User → CLI Entry: invokes (evidence: `sagify/__main__.py`)
- CLI Entry → CLI Commands: dispatches (evidence: `sagify/__main__.py`)
- CLI Commands → Cloud API: calls (evidence: `sagify/commands/cloud.py`)
- CLI Commands → LLM API: calls (evidence: `sagify/commands/llm.py`)
- CLI Commands → Project Config: reads config (evidence: `sagify/commands/cloud.py`)
- Cloud API → Project Config: loads config (evidence: `sagify/api/cloud.py`)
- Cloud API → SageMaker Operations: runs jobs (evidence: `sagify/api/cloud.py`)
- Cloud API → Streaming Inference: manages streams (evidence: `sagify/api/cloud.py`)
- SageMaker Operations → AWS Services: provisions models
- Streaming Inference → AWS Services: uses queues and functions (evidence: `sagify/streaming_inference/streaming_inference.py`)
- SageMaker Operations → Training Templates: uses training code
- SageMaker Operations → Inference Templates: uses inference code
- Gateway App → Versioned Routes: mounts routes (evidence: `sagify/llm_gateway/main.py`)
- Versioned Routes → Chat Endpoint: routes requests (evidence: `sagify/llm_gateway/api/v1/routes.py`)
- Versioned Routes → Embedding Endpoint: routes requests (evidence: `sagify/llm_gateway/api/v1/routes.py`)
- Versioned Routes → Image Endpoint: routes requests (evidence: `sagify/llm_gateway/api/v1/routes.py`)
- Chat Endpoint → Request Schemas: uses DTOs (evidence: `sagify/llm_gateway/api/v1/endpoints/chat.py`)
- Embedding Endpoint → Request Schemas: uses DTOs (evidence: `sagify/llm_gateway/api/v1/endpoints/embeddings.py`)
- Image Endpoint → Request Schemas: uses DTOs (evidence: `sagify/llm_gateway/api/v1/endpoints/images.py`)
- Chat Endpoint → Gateway Services: delegates (evidence: `sagify/llm_gateway/api/v1/endpoints/chat.py`)
- Embedding Endpoint → Gateway Services: delegates (evidence: `sagify/llm_gateway/api/v1/endpoints/embeddings.py`)
- Image Endpoint → Gateway Services: delegates (evidence: `sagify/llm_gateway/api/v1/endpoints/images.py`)
- Gateway Services → Client Factory: selects clients (evidence: `sagify/llm_gateway/services/embeddings.py`)
- Client Factory → OpenAI Client: creates client (evidence: `sagify/llm_gateway/providers/client_factory.py`)
- Client Factory → Anthropic Client: creates client (evidence: `sagify/llm_gateway/providers/client_factory.py`)
- Client Factory → SageMaker Client: creates client (evidence: `sagify/llm_gateway/providers/client_factory.py`)
- OpenAI Client → Model APIs: calls provider API (evidence: `sagify/llm_gateway/providers/openai/client.py`)
- Anthropic Client → Model APIs: calls provider API (evidence: `sagify/llm_gateway/providers/anthropic/client.py`)
- SageMaker Client → AWS Services: invokes endpoints
