Menu

Getting Started

Relevant source files

This page provides a practical guide to installing AStack and creating your first components and pipelines. It covers installation prerequisites, basic setup, and two execution patterns: standalone components and pipeline orchestration. For detailed architectural concepts, see Key Concepts. For information about specific packages and their APIs, see Package System.

Prerequisites

AStack requires the following system dependencies:

RequirementVersionPurpose
Node.jsv18.0.0 or higherJavaScript runtime
Package Managerpnpm (recommended), npm, or yarnDependency management

The Node.js version requirement is specified in package.json6-8

Sources: package.json6-8

Installation

Clone and Build from Source

AStack is currently distributed as a monorepo that must be built from source:

The monorepo uses pnpm workspaces to manage four core packages located in packages/*:

  • @astack-tech/core - Pipeline execution engine and Component base class
  • @astack-tech/components - Pre-built components (Agent, Memory, PromptTemplate, TextSplitter)
  • @astack-tech/tools - Tool definition system
  • @astack-tech/integrations - Model provider integrations (Deepseek, OpenAI)

Build System Overview

Sources: README.md124-148 package.json1-51 README.zh-CN.md124-148

Quick Start: Standalone Component Execution

Components in AStack can execute independently without a Pipeline. This is useful for simple transformations and testing individual components.

Using TextSplitter Component

The TextSplitter component splits text into chunks with configurable size and overlap:

Standalone Execution Flow

The run() method is defined in the base Component class and executes the component's _transform() method. All components inherit this capability.

Sources: examples/text-splitter/index.ts52-75

Quick Start: Pipeline Execution

Pipelines orchestrate multiple components by connecting their input and output ports. The Pipeline class manages component registration and data flow.

Creating Your First Pipeline

Pipeline Architecture

Pipeline Execution Internals

The Pipeline class automatically injects internal components for orchestration:

ComponentPurposePort
BaseProducer (START_COMPONENT_NAME)Injects input data into pipelineout
BaseConsumer (END_COMPONENT_NAME)Collects final outputin

When pipeline.run(triggerName, params) is called:

  1. Pipeline.addComponent() registers the component at packages/core/src/pipeline/index.ts66-72
  2. Pipeline.runWithBaseMode() creates internal start/end components at packages/core/src/pipeline/index.ts99-171
  3. Pipeline.connect() links component ports at packages/core/src/pipeline/index.ts84-90
  4. HLang Flow engine executes the connected graph
  5. BaseConsumer captures output and resolves the Promise

Sources: packages/core/src/pipeline/index.ts1-189 examples/text-splitter/index.ts48-80

Connecting Multiple Components

To build multi-component pipelines, use pipeline.connect() to link output ports to input ports:

Multi-Component Pipeline Flow

The connect() method uses dot notation componentName.portName to specify connections. It internally calls from() and to() helper methods to retrieve the HLang port objects at packages/core/src/pipeline/index.ts23-58

Sources: packages/core/src/pipeline/index.ts84-90 website/components/Hero.tsx50-74

Running Example Applications

The examples/ directory contains four demonstration applications:

ExamplePurposeKey Features
text-splitterBasic pipeline usageSingle component, standalone vs pipeline modes
agent-with-toolsTool integrationFile system tools, multi-turn conversations
simple-deep-researchComplex orchestrationMultiple coordinated components, feedback loops
serve-astackProduction applicationFastify backend, Next.js frontend, streaming agents

Running text-splitter Example

This example demonstrates both execution modes in examples/text-splitter/index.ts48-80:

  • Pipeline mode: pipeline.run('textSplitter.text', sampleText) at line 66
  • Standalone mode: textSplitter.run(sampleText) at line 70

Each example directory contains its own README with specific setup instructions, including required API keys for examples using LLM integrations.

Sources: README.md145-148 examples/text-splitter/index.ts1-80

Component Port System

Components communicate through a port-based system inherited from HLang's Flow-Based Programming model. Understanding ports is essential for pipeline construction.

Port Types and Methods

Key methods for working with ports:

MethodSignaturePurpose
Component.Port.I(name)attach(component)Declare input port
Component.Port.O(name)attach(component)Declare output port
component.I(name)Returns input portAccess input port for connection
component.O(name)Returns output portAccess output port for connection
pipeline.from(name)Returns output portInternal helper for connect()
pipeline.to(name)Returns input portInternal helper for connect()

The Pipeline.connect() method at packages/core/src/pipeline/index.ts84-90 internally calls from() and to() to retrieve port objects and establish connections.

Sources: packages/core/src/pipeline/index.ts23-90

Next Steps

After completing this guide, you should understand:

  • How to install and build AStack
  • Standalone vs pipeline execution modes
  • Basic component instantiation and configuration
  • Pipeline construction with addComponent() and connect()
  • Port-based communication between components
  1. Key Concepts - Deep dive into Components, Pipelines, Ports, Agents, Tools, and Model Providers
  2. Component System - Component interface, lifecycle methods, and the _transform() pattern
  3. Pipeline System - Pipeline orchestration, execution modes, and data flow management
  4. Example Applications - Explore progressively complex real-world examples
  5. Package System - Detailed API documentation for each package

Creating Custom Components

To create custom components, extend the base Component class and implement the _transform() method. For detailed guidance, see Component System.

Working with Agents and Tools

For AI agent development with tool integration, see:

Sources: README.md21-90 README.zh-CN.md21-90