Skip to content

Commit

Permalink
Merge pull request #303 from cardanoapi/feat/readme
Browse files Browse the repository at this point in the history
Feat/readme
  • Loading branch information
Sital999 authored Jan 13, 2025
2 parents 94202ba + c2c10ef commit 51189e3
Show file tree
Hide file tree
Showing 31 changed files with 545 additions and 356 deletions.
70 changes: 70 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Frontend
NEXT_PUBLIC_API_URL=http://localhost:8000/api
NEXT_PUBLIC_NETWORK_NAME=sanchonet
NEXT_PUBLIC_MANAGER_BASE_DOMAIN=agent_manager:3001

# API and Manager Common
KAFKA_PREFIX=testing
DATABASE_URL=postgresql://root:root@postgres:5432/cardano_autonomous_agent_testing_db
KAFKA_BROKERS=kafka:9093
AGENT_MNEMONIC=

# API
DOCS_URL=/api/docs
KAFKA_ENABLED=true
METADATA_BASE_URL=https://metadata.drep.id/api
DB_SYNC_BASE_URL=http://dbsync:9000/api

# Agent Manager
CLIENT_ID=my-app
CARDANO_NODE_URL=172.31.0.4:3004
KUBER_BASE_URL=https://sanchonet.kuber.cardanoapi.io
KUBER_API_KEY=
MANAGER_WALLET_ADDRESS=
MANAGER_WALLET_SIGNING_KEY=
FAUCET_API_KEY=
CARDANO_NETWORK_MAGIC=4
BLOCKFROST_API_KEY=
ENABLE_BLOCKFROST_SUBMIT_API=True
NETWORK_NAME=sanchonet

# Postgres
POSTGRES_DB=cardano_autonomous_agent_testing_db
POSTGRES_USER=root
POSTGRES_PASSWORD=root

# DbSync
DBSYNC_PORT=9000
DBSYNC_CORS_ENABLE=true
DBSYNC_DATABASE_URL=

# KAFKA
KAFKA_BROKER_ID= 1
KAFKA_ZOOKEEPER_CONNECT= zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP= DOCKER_NET:PLAINTEXT,HOST_NET:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS= DOCKER_NET://kafka:9093,HOST_NET://localhost:9092
KAFKA_INTER_BROKER_LISTENER_NAME= DOCKER_NET
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR= 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR= 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR= 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS= 0
KAFKA_JMX_PORT= 9999
KAFKA_CREATE_TOPICS= "trigger_config_updates:1:1"

#zookeeper
ZOOKEEPER_CLIENT_PORT = 2181
ZOOKEEPER_TICK_TIME = 2000
ZOOKEEPER_SYNC_LIMIT = 2

# Docker network name
DOCKER_NETWORK_NAME=cardano_autonomous_agent

# Docker network name
DOCKER_NETWORK_NAME=cardano_autonomous_agent

# Agent
AGENT_NODE_DOCKER_IMAGE_NAME=autonomous_agent




1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ app.log
.idea/
.vscode/
*/**/.vscode/
.env


137 changes: 121 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,138 @@
Cardano Autonomous Agent Monorepo
============
# Welcome to Autonomous Agent Testing

1. [Backend](api/)
2. [Agent Manager](agent-manager/)
3. [Agent](agent-node/)
4. [Frontend](frontend/)
Autonomous Agent Testing focuses on evaluating features introduced in the Cardano Improvement Proposal (CIP) 1694. This includes testing the creation and voting mechanisms for proposals to ensure the governance model operates seamlessly. Additionally, it verifies functionalities such as:

## Running the stack locally
- Registering and deregistering as a Delegated Representative (DRep).
- Managing stake registrations and deregistrations.
- Performing ADA transfers.
- Triggering operations manually, via a CRON schedule, or through event filtering.

Setup the required dependencies by running the command locally.
The testing process ensures these operations are secure, efficient, and aligned with the decentralized governance objectives of Cardano's Voltaire era.

```shell
docker compose -f docker-compose.local.yml up -d
---

## Accessing the Deployed Service

You can access the deployed service here: [Autonomous Agent Testing](https://agents.cardanoapi.io/)

---

## Running the Stack Locally

### Directory Structure

1. **`api`**: Backend service.
2. **`manager`**: Middleware between agents and the backend; handles various agent-related services.
3. **`agent-node`**: Agent responsible for executing various functions.
4. **`frontend`**: User interface for autonomous agent testing.
5. **`dbsync-api`**: Service for interacting with the dbsync database.
---

### Using Docker

Before running the entire service locally using Docker, create `.env` files from `.env.example` and populate them with the necessary environment variables. Below are descriptions of key variables:
> **Note:** Some variables in `.env.example` are prepopulated. Keep them as it is or change them carefully.
#### Changes to be made in `.env` file

##### API and Manager

- **`KAFKA_PREFIX`**: Prefix for Kafka topics.
- **`AGENT_MNEMONIC`**: Seed phrase to generate a wallet.

##### Agent Manager

- **`KUBER_API_KEY`**: Generate an API key from [KuberIde](https://kuberide.com/kuber/settings/api-keys).
- **`MANAGER_WALLET_ADDRESS`** (Optional): Wallet address with sufficient ADA for transfers.
- **`MANAGER_WALLET_SIGNING_KEY`** (Optional): Signing key for the manager wallet.
- **`FAUCET_API_KEY`** (Optional): API key to load ADA for agent transfers if the manager wallet lacks sufficient funds.
- **`BLOCKFROST_API_KEY`** (Required if `ENABLE_BLOCKFROST_SUBMIT_API` is enabled): Obtain from [Blockfrost](https://blockfrost.io/).

> **Note:** If `ENABLE_BLOCKFROST_SUBMIT_API` is not enabled, transactions will be submitted using `Kuber`, which may take a few minutes.
##### DBSync

- **`DBSYNC_DATABASE_URL`**: URL for the `dbsync-api service`. Default running on `http://localhost:9000` on starting `dbsync-api` service.

##### Docker Network Name

- **`DOCKER_NETWORK_NAME`**: Customize the Docker network name (default value provided in `.env.example`).

##### Agent

- **`AGENT_NODE_DOCKER_IMAGE_NAME`**: Customize the Docker image name for the agent node.

#### Running in `Preprod` or `Preview` Networks

To run in `Preprod` or `Preview` networks, update the following environment variables:

##### Frontend

- **`NEXT_PUBLIC_NETWORK_NAME`**: Set to `preview` or `preprod`.

##### API and Manager

- **`DB_SYNC_BASE_URL`**:
- `https://preprod-dbync.agents.cardanoapi.io/api` for `preprod`
- `https://preview-dbync.agents.cardanoapi.io/api` for `preview`

##### Manager Only

- **`KUBER_BASE_URL`**:
- `https://preview.kuber.cardanoapi.io` for `preview`
- `https://preprod.kuber.cardanoapi.io` for `preprod`
- **`CARDANO_NETWORK_MAGIC`**:
- `3` for `preview`
- `2` for `preprod`
- **`BLOCKFROST_API_KEY`**: Obtain from [Blockfrost](https://blockfrost.io/) for the desired network.
- **`NETWORK_NAME`**: Set to `preprod` or `preview`.

##### DBSync

- **`DBSYNC_DATABASE_URL`**: Update the URL and database name accordingly.
---

#### Starting the Service

Run the following command:

```bash
docker compose -f docker-compose.dev.yml up -d
```

**Note**: You can also use already existing services in place of this
> **Note:** Ensure no applications are running on ports `3000` and `8000`.
#### Finally Running the Agent

1. Visit the frontend at `http://localhost:3000` and connect your wallet.
2. Navigate to the `My Agent` tab in the bottom left to access the `Agents Page`.
3. In the `Overview Tab`, click the `Run Agent` button in the top-right corner of the `Agents Overview Section`.
4. Copy the Docker command and run it in the terminal. Your agent is now ready to operate.

---

### Local Setup

The setup guide for each services are in the respective directories:
Each service has its own setup guide within its respective directory.

1. [Backend](api/README.md)
2. [Agent Manager](agent-manager/README.md)
3. [Agent](agent-node/README.md)
4. [Frontend](frontend/README.md)
5. [DbSync-Api](dbsync-api/README.md)

**`Note`**: For running all services locally, dependencies like `Kafka` and `PostgreSQL` can be run via Docker using the following command:
```bash
docker compose -f docker-compose.dev.yml up -d
```

---

## Important

# IMPORTANT
Before committing any changes to the repository, set up the pre-commit hook by running the following command:

Please setup the pre-commit hook before adding any commit for git by running the following command:
```shell
```bash
./install-pre-commit-hook.sh
```
```

41 changes: 19 additions & 22 deletions agent-manager/.env.example
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
KAFKA_BROKERS=127.0.0.1:9092
KAFKA_CLIENT_ID=
KAFKA_PREFIX=local
# Kafka
KAFKA_BROKERS=
KAFKA_TOPIC_PREFIX=
KAFKA_CONSUMER_GROUP=
CLIENT_ID=

CARDANO_NODE_URL=
CARDANO_NETWORK_MAGIC=4

KUBER_BASE_URL=
# Cardano
CARDANO_NODE_URL=172.31.0.4:3004
KUBER_BASE_URL='https://sanchonet.kuber.cardanoapi.io'
KUBER_API_KEY=
METADATA_BASE_URL='https://metadata.drep.id'
DB_SYNC_BASE_URL=
CARDANO_NETWORK_MAGIC=4
BLOCKFROST_API_KEY=
ENABLE_BLOCKFROST_SUBMIT_API=
ENABLE_BLOCKFROST_SUBMIT_API='True'


DATABASE_URL=postgresql://root:root@localhost:5432/cardano_autonomous_agent_testing_db

# Wallet
MANAGER_WALLET_ADDRESS=
MANAGER_WALLET_SIGNING_KEY=

SANCHONET_FAUCET_API_KEY=

FAUCET_API_KEY=
AGENT_MNEMONIC=
METADATA_BASE_URL=
METADATA_FETCH_BASE_URL=

DB_SYNC_BASE_URL=

SERVER_PORT=
NETWORK_NAME=


# Database
DATABASE_URL=


ELASTIC_APM_SERVER_URL=https://apm.sireto.io
ELASTIC_APM_API_KEY=XXX
# Server
SERVER_PORT=3002
NETWORK_NAME=sanchonet
Loading

0 comments on commit 51189e3

Please sign in to comment.