Skip to content

Overview

In this part:


Jac applications can be deployed to production with the jac-scale plugin. It transforms your Jac code into a scalable backend with automatic API generation, database persistence, and Kubernetes orchestration. This “scale-native” approach means you develop locally and deploy to production without rewriting code.

The jac-scale plugin is Jac’s production deployment system. It wraps your code with FastAPI for HTTP handling, Redis for caching, and MongoDB for persistence. Walkers automatically become API endpoints, and graph state persists across requests.

jac-scale provides production-ready deployment with:

  • FastAPI backend
  • Redis caching
  • MongoDB persistence
  • Kubernetes orchestration
pip install jac-scale
jac plugins enable scale
# Development
jac start main.jac --port 8000
# Production with scaling
jac start --scale
VariableDescription
REDIS_URLRedis connection URL
MONGODB_URIMongoDB connection URI
K8S_NAMESPACEKubernetes namespace
K8S_REPLICASNumber of replicas
[plugins.scale.cors]
allow_origins = ["https://example.com"]
allow_methods = ["GET", "POST", "PUT", "DELETE"]
allow_headers = ["*"]

jac start --scale

Automatically provisions:

  • Deployment with specified replicas
  • Service for load balancing
  • ConfigMap for configuration
  • StatefulSets for Redis/MongoDB
# Example generated deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: jac-app
spec:
replicas: 3
selector:
matchLabels:
app: jac-app

Built-in endpoints:

  • /health — Liveness probe
  • /ready — Readiness probe

graph TD
App["Application"] --- L1["L1: Volatile (in-memory)"]
L1 --- L2["L2: Redis (cache)"]
L2 --- L3["L3: MongoDB (persistent)"]

Public walkers become OpenAPI endpoints:

# Swagger docs available at
http://localhost:8000/docs

Kubernetes service mesh integration for:

  • Automatic load balancing
  • Service-to-service communication
  • Health monitoring

For teams preferring pure Python syntax or integrating Jac into existing Python codebases, Library Mode provides an alternative deployment approach. Instead of .jac files, you use Python files with Jac’s runtime as a library.

Complete Guide: See Library Mode for the full API reference, code examples, and migration guide.

Key Features:

  • All Jac features accessible through jaclang.lib imports
  • Pure Python syntax with decorators (@on_entry, @on_exit)
  • Full IDE/tooling support (autocomplete, type checking, debugging)
  • Zero migration friction for existing Python projects

Quick Example:

from jaclang.lib import Node, Walker, spawn, root, on_entry
class Task(Node):
title: str
done: bool = False
class TaskFinder(Walker):
@on_entry
def find(self, here: Task) -> None:
print(f"Found: {here.title}")
spawn(TaskFinder(), root())