Skip to content

Commit

Permalink
Merge pull request #3 from Brahma-fi/ft-readme
Browse files Browse the repository at this point in the history
readme changes
  • Loading branch information
Bapi-Reddy authored Jan 10, 2025
2 parents 08e9a4f + 66ffe14 commit ce16579
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 52 deletions.
74 changes: 22 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,42 @@

Scalable, high-performance workflow scheduling engine built on Temporal for executing custom strategies with the Brahma Builder Kit API. Seamlessly manages workflow orchestration, fault tolerance, and Brahma ecosystem integration.

![alt text](./docs/image.png)

- **[Architecture reference](./docs/architecture.md)**
- **[Additional context](https://www.notion.so/brahmafi/Bringing-AI-Agents-On-Chain-Automate-Execute-and-Scale-with-Brahma-175a53ecb04c80d9b9d6cf16cd1dd98a#175a53ecb04c8078b143f61bd9681e2b)**

## Features

- Zero-config workflow scheduling
- Automatic retry handling
- Native Brahma Builder Kit integration
- Temporal engine under the hood

## Architecture
## Running locally

### Core Components
1. Setup vault

#### Executor Interface
The primary interface for implementing custom strategies:
```go
type Executor interface {
Execute(ctx context.Context, req *entity.ExecuteTaskReq) (*entity.ExecuteTaskResp, error)
}
```
make setup-local-vault
make setup-local-plugin
```

#### Runtime Components
- **Temporal Scheduler**: Manages schedule creation and trigger handling
- **Activity Executor**: Handles strategy execution and lifecycle management
- **State Manager**: Maintains execution state and handles persistence
- **Error Handler**: Implements retry mechanisms and failure recovery

### Implementation Requirements

#### Strategy Development
1. Implement the `Executor` interface
2. Process incoming `ExecuteTaskReq`
3. Return execution results via `ExecuteTaskResp`

#### System Integration
- Strategies are automatically registered with Temporal
- Schedules are created based on subscription configurations
- Execution is triggered according to defined intervals

### Managed Components

#### Scheduling
- Schedule creation and management
- Trigger processing and distribution
- Execution window management
2. Setup env

#### Execution
- Activity lifecycle management
- State persistence
- Error handling and retries
- Result processing
```
export VAULT_ADDR=127.0.0.1:8200
export ENV=local
```

#### Resource Management
- Workload distribution
- Execution throttling
- Resource allocation
3. Run scheduler & workers

### Design Considerations
```
go run cmd/main.go scheduler|base-worker|morpho-worker
```

#### Strategy Implementation
- Implement atomic, single-responsibility strategies
- Utilize provided context for execution control
- Handle edge cases within strategy implementation
- Return structured responses via `ExecuteTaskResp`
## Example

#### Performance
- Strategies are executed as Temporal activities
- Built-in support for parallel execution
- Automatic resource scaling
Morpho Yield Optimizer is a strategy that is built using Brahma builder. It maximises user’s Morpho positions by taking decisions on which vaults to choose based on APY; liquidity and TVL, on every rebalance.

For reference implementation, see [Morpho Optimizer Strategy](https://github.com/Brahma-fi/brahma-builder/blob/main/internal/usecase/workflows/activities/morpho/activity.go).
For reference implementation, see [Morpho Optimizer Strategy](https://github.com/Brahma-fi/brahma-builder/blob/main/internal/usecase/workflows/activities/morpho/activity.go).
70 changes: 70 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
## Architecture

### Core Components

#### Executor Interface

The primary interface for implementing custom strategies:

```go
type Executor interface {
Execute(ctx context.Context, req *entity.ExecuteTaskReq) (*entity.ExecuteTaskResp, error)
}
```

#### Runtime Components

- **Temporal Scheduler**: Manages schedule creation and trigger handling
- **Activity Executor**: Handles strategy execution and lifecycle management
- **State Manager**: Maintains execution state and handles persistence
- **Error Handler**: Implements retry mechanisms and failure recovery

### Implementation Requirements

#### Strategy Development

1. Implement the `Executor` interface
2. Process incoming `ExecuteTaskReq`
3. Return execution results via `ExecuteTaskResp`

#### System Integration

- Strategies are automatically registered with Temporal
- Schedules are created based on subscription configurations
- Execution is triggered according to defined intervals

### Managed Components

#### Scheduling

- Schedule creation and management
- Trigger processing and distribution
- Execution window management

#### Execution

- Activity lifecycle management
- State persistence
- Error handling and retries
- Result processing

#### Resource Management

- Workload distribution
- Execution throttling
- Resource allocation

### Design Considerations

#### Strategy Implementation

- Implement atomic, single-responsibility strategies
- Utilize provided context for execution control
- Handle edge cases within strategy implementation
- Return structured responses via `ExecuteTaskResp`

#### Performance

- Strategies are executed as Temporal activities
- Built-in support for parallel execution
- Automatic resource scaling
Binary file added docs/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ce16579

Please sign in to comment.