Overview
Part IX: Deployment and Scaling
Section titled “Part IX: Deployment and Scaling”In this part:
- jac-scale Plugin - Production deployment, APIs, persistence
- Kubernetes Deployment - Helm charts, scaling
- Production Architecture - Multi-tier, security, monitoring
- Library Mode - Pure Python deployment with Jac runtime
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.
jac-scale Plugin
Section titled “jac-scale Plugin”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.
1 Overview
Section titled “1 Overview”jac-scale provides production-ready deployment with:
- FastAPI backend
- Redis caching
- MongoDB persistence
- Kubernetes orchestration
2 Installation
Section titled “2 Installation”pip install jac-scalejac plugins enable scale3 Basic Deployment
Section titled “3 Basic Deployment”# Developmentjac start main.jac --port 8000
# Production with scalingjac start --scale4 Environment Configuration
Section titled “4 Environment Configuration”| Variable | Description |
|---|---|
REDIS_URL | Redis connection URL |
MONGODB_URI | MongoDB connection URI |
K8S_NAMESPACE | Kubernetes namespace |
K8S_REPLICAS | Number of replicas |
5 CORS Configuration
Section titled “5 CORS Configuration”[plugins.scale.cors]allow_origins = ["https://example.com"]allow_methods = ["GET", "POST", "PUT", "DELETE"]allow_headers = ["*"]Kubernetes Deployment
Section titled “Kubernetes Deployment”1 Auto-Scaling
Section titled “1 Auto-Scaling”jac start --scaleAutomatically provisions:
- Deployment with specified replicas
- Service for load balancing
- ConfigMap for configuration
- StatefulSets for Redis/MongoDB
2 Generated Resources
Section titled “2 Generated Resources”# Example generated deploymentapiVersion: apps/v1kind: Deploymentmetadata: name: jac-appspec: replicas: 3 selector: matchLabels: app: jac-app3 Health Checks
Section titled “3 Health Checks”Built-in endpoints:
/health— Liveness probe/ready— Readiness probe
Production Architecture
Section titled “Production Architecture”1 Multi-Layer Memory
Section titled “1 Multi-Layer Memory”graph TD App["Application"] --- L1["L1: Volatile (in-memory)"] L1 --- L2["L2: Redis (cache)"] L2 --- L3["L3: MongoDB (persistent)"]2 FastAPI Integration
Section titled “2 FastAPI Integration”Public walkers become OpenAPI endpoints:
# Swagger docs available athttp://localhost:8000/docs3 Service Discovery
Section titled “3 Service Discovery”Kubernetes service mesh integration for:
- Automatic load balancing
- Service-to-service communication
- Health monitoring
Library Mode
Section titled “Library Mode”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.libimports - 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())