App Droplet Object

The Reasoning Flows component for developing and deploying web applications and API services.

App Droplet Object Overview

The Reasoning Flows component for developing, managing, and publishing web applications and API services.


Purpose

The App Droplet Object is a specialized environment within Reasoning Flows for developing, managing, and publishing web applications or API services written in PHP or Python. It integrates directly with configured App Droplet servers, enabling developers to write, test, and deploy applications directly from within the ARPIA platform.

This object serves as the bridge between data-driven workflows and production deployment, giving teams a secure, controlled way to operationalize data applications and APIs.


Where It Fits in Reasoning Flows

In the Reasoning Flows architecture:

  1. Extract & Load ingests and structures source data.
  2. Repository Tables register datasets for reuse.
  3. Transform & Prepare cleans and enriches data for analytics.
  4. AI & Machine Learning builds and trains predictive or generative models.
  5. Visual Objects delivers insights through dashboards, APIs, or notebooks.
  6. Data Models (Nodes) define semantic entities.
  7. AI Apps combines and orchestrates all components into a deployable project.
  8. App Droplet Object publishes these applications to external servers for production use.

Goal: The App Droplet Object transforms Reasoning Flows projects into live, operational web or API services hosted on connected servers.


Key Capabilities

Built-in Code Editor
Develop multi-file applications directly in the browser with syntax highlighting and project organization.

Server Integration
Connects to pre-configured App Droplet servers for seamless deployment.

Project Management
Supports structured file organization and dependency management.

Terminal Access
Built-in SSH terminal for real-time command-line interaction with the server.

Controlled Publishing
Deploys code safely through a version-controlled publishing process.


Development Environments

When creating an App Droplet Object, select the programming language and runtime environment:

PHP Environment

Runtime: PHP 8.x

Best for:

  • Traditional web applications
  • Dynamic sites and backend interfaces
  • Integration with existing PHP frameworks

Available Extensions:

  • Database: mysqli, PDO, sqlite3, redis
  • HTTP & Network: curl, ftp, openssl
  • Image Processing: gd, imagick
  • Data: json, xml, SimpleXML, zip
  • Other: mbstring, imap, mcrypt

Database Connectivity:

<?php
require_once('datakubes-connect.php');
$dk_conn = dk_connect();  // Returns a mysqli instance

// Query example
$stmt = $dk_conn->prepare("SELECT * FROM sales_gold WHERE region = ?");
$stmt->bind_param('s', $region);
$stmt->execute();
$result = $stmt->get_result();

while ($row = $result->fetch_assoc()) {
    echo $row['product_name'] . ": " . $row['revenue'] . "\n";
}

Python Environment

Runtime: Python 3.x

Best for:

  • APIs and data-driven microservices
  • ML model endpoints
  • Web integrations with Flask/FastAPI
  • Serving Reasoning Flows outputs

Database Connectivity:

import dkconnect

conn = dkconnect.connect()  # Returns a MySQLi-style connection
cursor = conn.cursor()

# Query example
cursor.execute(
    "SELECT * FROM sales_gold WHERE region = %s",
    (region,)
)
rows = cursor.fetchall()

for row in rows:
    print(f"{row[0]}: {row[1]}")

cursor.close()
conn.close()

Interface Overview

The App Droplet interface provides full control over coding and publishing workflows.

1. Code Area

A built-in development environment where you can create, edit, and organize project files. It functions as a lightweight IDE optimized for web and API development within Reasoning Flows.

2. Publishing Configuration

Defines where and how your application will be deployed:

  • Select a target App Droplet Server for publishing
  • Once configured, the Publish button becomes active
  • Deployment replaces all files in the target directory with the latest versions

Tip: Always test in a staging server before pushing to production.

3. Terminal

A built-in SSH terminal that connects directly to the associated App Droplet server. You can run commands, inspect logs, manage dependencies, and interact with the environment in real time.

App Droplet Interface


Typical Use Cases

  • Deploying API services that expose Reasoning Flows outputs (e.g., model predictions or prepared datasets)
  • Hosting micro frontends or lightweight dashboards for data visualization
  • Managing Python FastAPI or PHP-based applications that automate workflows
  • Integrating external services or triggering actions via web endpoints
  • Building RESTful APIs that serve data from Repository Tables

Example: Building a Prediction API

Python (FastAPI)

import dkconnect
from fastapi import FastAPI

app = FastAPI()

@app.get("/predictions/{product_id}")
def get_prediction(product_id: int):
    conn = dkconnect.connect()
    cursor = conn.cursor()
    
    cursor.execute(
        "SELECT product_name, predicted_sales, confidence "
        "FROM sales_forecast_optimized WHERE product_id = %s",
        (product_id,)
    )
    row = cursor.fetchone()
    cursor.close()
    conn.close()
    
    if row:
        return {
            "product_name": row[0],
            "predicted_sales": row[1],
            "confidence": row[2]
        }
    return {"error": "Product not found"}

PHP (REST Endpoint)

<?php
require_once('datakubes-connect.php');
header('Content-Type: application/json');

$dk_conn = dk_connect();
$product_id = (int)($_GET['product_id'] ?? 0);

$stmt = $dk_conn->prepare(
    "SELECT product_name, predicted_sales, confidence 
     FROM sales_forecast_optimized WHERE product_id = ?"
);
$stmt->bind_param('i', $product_id);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();

if ($row) {
    echo json_encode([
        'product_name' => $row['product_name'],
        'predicted_sales' => $row['predicted_sales'],
        'confidence' => $row['confidence']
    ]);
} else {
    echo json_encode(['error' => 'Product not found']);
}

Deployment Workflow

Development (App Droplet Object)
    │
    ├── Write code in Code Area
    ├── Test via Terminal
    │
    ▼
Configure Publishing
    │
    ├── Select target server (staging)
    ├── Click Publish
    │
    ▼
Test on Staging Server
    │
    ├── Verify functionality
    ├── Check logs and performance
    │
    ▼
Publish to Production
    │
    ├── Select production server
    ├── Click Publish
    │
    ▼
Live API/Application
    https://api.yourcompany.com/endpoint

Best Practices

Use App Droplet Objects for all externally facing deployments. Keep production code separate from workflow logic.

Establish staging and production servers for safe testing and controlled releases. Never publish directly to production without testing.

Always use parameterized queries to prevent SQL injection:

  • PHP: Use prepared statements with ? placeholders
  • Python: Use %s placeholders with tuple parameters

Secure connections using SSH keys and HTTPS endpoints.

Sync code changes to version control before publishing. This ensures you can roll back if needed.

Document deployed services and endpoints in the Reasoning Atlas for traceability and governance.

Combine App Droplets with AI Apps to package full workflow and deployment logic together.

Handle errors gracefully with try/catch blocks and meaningful error responses.


Related Documentation