Lewati ke konten

Ringkasan Arsitektur

Greentic mengikuti arsitektur berlapis dengan pemisahan tanggung jawab yang jelas:

┌─────────────────────────────────────────────────────────┐
│ Messaging Channels │
│ (Slack, Teams, Telegram, WhatsApp, WebChat) │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ Gateway (HTTP/NATS) │
│ Public Endpoint Router │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ greentic-runner │
│ (Production Runtime Host) │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Flow Executor │ │
│ │ (Wasmtime Component Model) │ │
│ └─────────────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Session Manager │ │
│ │ (Memory / Redis) │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ WASM Components │
│ (Flows, Providers, MCP Tools, Custom Components) │
└─────────────────────────────────────────────────────────┘

greentic-runner

Runtime produksi utama yang meng-host dan mengeksekusi flow, mengelola session, dan mengoordinasikan semua layanan platform.

greentic-flow

Definisi skema flow, intermediate representation (IR), loader, dan validator untuk file .ygtc.

greentic-pack

CLI pack builder untuk membuat arsip .gtpack bertanda tangan yang berisi flow, komponen, dan aset.

greentic-component

CLI authoring komponen dan utilitas runtime untuk membangun komponen WASM.

LayerTechnologyPurpose
WASM RuntimeWasmtime v41Eksekusi component model
Async RuntimeTokio v1Async I/O, penjadwalan task
HTTP ServerAxum v0.8REST API, webhook
Message BusNATSDistribusi event, pub/sub
Session StoreMemory/RedisPersistensi state flow
SecretsAWS/Azure/GCP/VaultManajemen kredensial
1. External Message (e.g., Slack)
2. Webhook Handler (Provider Ingress)
3. NATS: greentic.messaging.ingress.{env}.{tenant}.{team}.{channel}
4. Flow Router (tenant/team resolution)
5. Flow Executor (WASM component execution)
6. Session State Update
7. Reply/Action Nodes
8. NATS: greentic.messaging.egress.{env}.{tenant}.{team}.{channel}
9. Provider Egress → External Service
1. Bundle Configuration (greentic.demo.yaml)
2. Pack Resolver (local/OCI registry)
3. Signature Verification (ed25519-dalek)
4. CBOR Metadata Parsing
5. WASM Component Instantiation
6. WIT Interface Binding
7. Runtime Registration

Greentic mengimplementasikan isolasi tenant di setiap lapisan:

Tenant
└── Environment (prod, staging, dev)
└── Team
└── Channel (messaging provider instance)
└── Session (user conversation state)

Struct TenantCtx mengalir melalui semua operasi:

pub struct TenantCtx {
pub tenant_id: String,
pub env_id: String,
pub team_id: Option<String>,
}

Greentic menggunakan spesifikasi WebAssembly Interface Types (WIT) untuk mendefinisikan antarmuka komponen:

greentic-interfaces/wit/component.wit
package greentic:component;
interface types {
record message {
id: string,
content: string,
sender: string,
timestamp: u64,
}
record outcome {
success: bool,
data: option<string>,
error: option<string>,
}
}
world component {
import types;
export execute: func(input: types.message) -> types.outcome;
}
greentic-types ─────────────────────────── (foundation)
greentic-telemetry
greentic-interfaces ← greentic-types
greentic-config ← greentic-types
greentic-session ← greentic-types
greentic-state ← greentic-types + greentic-interfaces
greentic-flow ← greentic-interfaces + greentic-types
greentic-pack ← greentic-flow + greentic-types
greentic-component ← greentic-interfaces + greentic-types
greentic-mcp ← greentic-interfaces + greentic-types
greentic-runner ← ALL of the above

Greentic menggunakan OpenTelemetry untuk distributed tracing dan metrics:

  • Tracing: OTLP exporter untuk korelasi trace terdistribusi
  • Metrics: Waktu eksekusi flow, throughput pesan, tingkat error
  • Logging: Structured logging dengan trace context
  • Flows - Pelajari definisi flow
  • Packs - Pahami struktur pack
  • Components - Bangun komponen WASM kustom