Skip to content

Core Architecture

🏗️ Architecture Overview

SFAI SDK uses a plugin-based architecture for platforms and integrations. All official plugins are bundled with the SDK for convenience, but the system is designed for extensibility.

header

SFAI SDK Plugin-Based Architecture


🔌 Plugin-Based Platform System

SFAI SDK uses a plugin-based architecture for platform and integration support. All platform plugins must inherit from BasePlatform, which acts as the contract for platform features.

⚙️ How It Works

Handles app lifecycle, context, deployment orchestration, and CLI/API interfaces.

# Core responsibilities
- App lifecycle management
- Context and state handling
- Deployment orchestration
- CLI/API interface provision

Each platform is a separate module that inherits from BasePlatform

# Platform examples
- Heroku Plugin
- AWS Plugin
- Local Docker Plugin
- Custom Enterprise Plugin

All plugins implement: init, deploy, delete, status, logs, open

Each platform must be registered in pyproject.toml

[project.entry-points."sfai.platforms"]
heroku = "sfai.platform.providers.heroku.platform:HerokuPlatform"
aws = "sfai.platform.providers.aws.platform:AWSPlatform"
local = "sfai.platform.providers.local.platform:LocalPlatform"

Auto-discovery and loading of all registered platforms

# Runtime platform discovery
entry_points = pkg_resources.iter_entry_points('sfai.platforms')
platforms = {ep.name: ep.load() for ep in entry_points}

✨ Benefits

🚀 Extensibility

New platforms can be added as plugins without modifying the core engine.

🛡️ Stability

Changes to platform plugins do not impact the core SDK logic.

🎨 Customization

Organizations can fork or extend platform plugins for their needs.


🏗️ Base Implementations

Core Base Classes

Abstract base for app-level operations

class BaseApp:
    """Abstract base for application operations"""
    pass

Abstract base for all platform plugins

class BasePlatform:
    def init(self, **kwargs) -> BaseResponse: ...
    def deploy(self, context, **kwargs) -> BaseResponse: ...
    def delete(self, context) -> BaseResponse: ...
    def status(self, context) -> BaseResponse: ...
    def logs(self, context) -> BaseResponse: ...
    def open(self, context, **kwargs) -> BaseResponse: ...

Abstract base for integrations (e.g., MuleSoft)

class BaseIntegration:
    """Abstract base for external integrations"""
    pass

Standard response model for all operations

class BaseResponse:
    success: bool
    message: str
    error: Optional[str]
    data: Optional[Dict]

🛠️ How to Add a New Platform Plugin

Step-by-Step Guide

Create a new provider module:

# Create directory structure
mkdir -p sfai/platform/providers/<your_platform>/
touch sfai/platform/providers/<your_platform>/platform.py
# Implement your platform class
from sfai.core.base import BasePlatform

class YourPlatform(BasePlatform):
    # Implement all required methods
    pass

Add to pyproject.toml entry points:

```