Skip to content

Commit c2c10ef

Browse files
committed
enhacnement: Update readme and .env.example for all service
1 parent c3f9e90 commit c2c10ef

File tree

17 files changed

+193
-155
lines changed

17 files changed

+193
-155
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ You can access the deployed service here: [Autonomous Agent Testing](https://age
2626
3. **`agent-node`**: Agent responsible for executing various functions.
2727
4. **`frontend`**: User interface for autonomous agent testing.
2828
5. **`dbsync-api`**: Service for interacting with the dbsync database.
29+
---
2930

3031
### Using Docker
3132

@@ -51,7 +52,7 @@ Before running the entire service locally using Docker, create `.env` files from
5152
5253
##### DBSync
5354

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

5657
##### Docker Network Name
5758

@@ -89,6 +90,7 @@ To run in `Preprod` or `Preview` networks, update the following environment vari
8990
##### DBSync
9091

9192
- **`DBSYNC_DATABASE_URL`**: Update the URL and database name accordingly.
93+
---
9294

9395
#### Starting the Service
9496

@@ -100,7 +102,7 @@ docker compose -f docker-compose.dev.yml up -d
100102

101103
> **Note:** Ensure no applications are running on ports `3000` and `8000`.
102104
103-
#### Running the Agent
105+
#### Finally Running the Agent
104106

105107
1. Visit the frontend at `http://localhost:3000` and connect your wallet.
106108
2. Navigate to the `My Agent` tab in the bottom left to access the `Agents Page`.
@@ -111,12 +113,18 @@ docker compose -f docker-compose.dev.yml up -d
111113

112114
### Local Setup
113115

114-
Each service has its own setup guide within its respective directory. For running all services locally, dependencies like `Kafka` and `PostgreSQL` can be run via Docker using the following command:
116+
Each service has its own setup guide within its respective directory.
115117

116118
1. [Backend](api/README.md)
117119
2. [Agent Manager](agent-manager/README.md)
118120
3. [Agent](agent-node/README.md)
119121
4. [Frontend](frontend/README.md)
122+
5. [DbSync-Api](dbsync-api/README.md)
123+
124+
**`Note`**: For running all services locally, dependencies like `Kafka` and `PostgreSQL` can be run via Docker using the following command:
125+
```bash
126+
docker compose -f docker-compose.dev.yml up -d
127+
```
120128

121129
---
122130

agent-manager/.env.example

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
1-
KAFKA_BROKERS=127.0.0.1:9092
2-
KAFKA_CLIENT_ID=
3-
KAFKA_PREFIX=local
1+
# Kafka
2+
KAFKA_BROKERS=
3+
KAFKA_TOPIC_PREFIX=
4+
KAFKA_CONSUMER_GROUP=
5+
CLIENT_ID=
46

5-
CARDANO_NODE_URL=
6-
CARDANO_NETWORK_MAGIC=4
77

8-
KUBER_BASE_URL=
8+
# Cardano
9+
CARDANO_NODE_URL=172.31.0.4:3004
10+
KUBER_BASE_URL='https://sanchonet.kuber.cardanoapi.io'
911
KUBER_API_KEY=
12+
METADATA_BASE_URL='https://metadata.drep.id'
13+
DB_SYNC_BASE_URL=
14+
CARDANO_NETWORK_MAGIC=4
1015
BLOCKFROST_API_KEY=
11-
ENABLE_BLOCKFROST_SUBMIT_API=
16+
ENABLE_BLOCKFROST_SUBMIT_API='True'
1217

1318

14-
DATABASE_URL=postgresql://root:root@localhost:5432/cardano_autonomous_agent_testing_db
15-
19+
# Wallet
1620
MANAGER_WALLET_ADDRESS=
1721
MANAGER_WALLET_SIGNING_KEY=
18-
19-
SANCHONET_FAUCET_API_KEY=
20-
22+
FAUCET_API_KEY=
2123
AGENT_MNEMONIC=
22-
METADATA_BASE_URL=
23-
METADATA_FETCH_BASE_URL=
24-
25-
DB_SYNC_BASE_URL=
26-
27-
SERVER_PORT=
28-
NETWORK_NAME=
29-
3024

25+
# Database
26+
DATABASE_URL=
3127

3228

33-
ELASTIC_APM_SERVER_URL=https://apm.sireto.io
34-
ELASTIC_APM_API_KEY=XXX
29+
# Server
30+
SERVER_PORT=3002
31+
NETWORK_NAME=sanchonet

agent-manager/README.md

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
# Agent Manager Application
22

3-
This project is a TypeScript Agent Manager application where Agents are connected to it through websocket .
3+
This project is a TypeScript Agent Manager application where agents are connected to it through websocket.
44

55
## Table of Contents
66

77
- [Requirements](#requirements)
88
- [Installation](#installation)
9-
- [Usage](#usage)
10-
- [Development](#development)
119

1210
## Requirements
1311

1412
- [Node.js](https://nodejs.org/) (v18.18.0 or higher)
1513
- [yarn](https://yarnpkg.com/) package manager
14+
- `kafka service`
15+
- `postgres server`
1616

1717
## Installation
1818

19-
1. Clone the repository:
19+
1. Go to the agent-manager folder (If in root folder)
2020

2121
```shell
22-
git clone https://github.com/sireto/cardano-autonomous-agent.git
23-
cd cardano-autonomous-agent/agent-manager
22+
cd agent-manager
2423
```
2524

2625
2. Install dependencies using yarn:
@@ -31,42 +30,73 @@ This project is a TypeScript Agent Manager application where Agents are connecte
3130

3231
## Usage
3332

34-
Copy the env variables form `.env.example` to `.env` and update the env variables.
33+
Create new file `.env` and copy env variables form `.env.example` to `.env` and update the env variables.
3534

36-
Make sure to run the following command to generate the database client and creating the required table mentioned in schema
35+
#### Setup environment variables
3736

38-
```bash
39-
yarn prisma generate
40-
```
37+
#### Kafka Configuration
4138

42-
### Development Mode
39+
- **`KAFKA_CONSUMER_GROUP`**: Kafka consumer group name.
40+
- **`CLIENT_ID`**: Unique client ID for Kafka.
41+
- **`KAFKA_PREFIX`**: Prefix for Kafka topics.
42+
- **`KAFKA_BROKERS`**: Kafka broker URL. Specify either a locally running Kafka URL (e.g., on Docker) or a deployed Kafka service URL.
4343

44-
To run the application in dev mode run the following command
44+
#### Cardano Configuration
4545

46-
```shell
47-
yarn dev
48-
```
46+
- **`CARDANO_NODE_URL`**: `172.31.0.4:3004` - URL for the Cardano node.
47+
- **`KUBER_BASE_URL`**: `'https://sanchonet.kuber.cardanoapi.io'` - Base URL for Kuber's Cardano API.
48+
- **`KUBER_API_KEY`**: API key for accessing Kuber services. Generate an API key from [KuberIde](https://kuberide.com/kuber/settings/api-keys).
49+
- **`METADATA_BASE_URL`**: Metadata URL to fetch information about dReps and proposals across different networks. (Default provided in `.env.example`)
50+
- **`DB_SYNC_BASE_URL`**: URL for the `dbsync-api service`. Default running on `http://localhost:9000` on starting `dbsync-api` service.
51+
- **`CARDANO_NETWORK_MAGIC`**: `4` - Network magic for the Cardano testnet(Sanchonet).
52+
- **`BLOCKFROST_API_KEY`** (Optional): API key for accessing the Blockfrost API. (Required if `ENABLE_BLOCKFROST_SUBMIT_API` is enabled): Obtain from [Blockfrost](https://blockfrost.io/).
53+
- **`ENABLE_BLOCKFROST_SUBMIT_API`** (Optional): `'True'` - Enable or disable Blockfrost transaction submission API.
54+
> **Note:** If `ENABLE_BLOCKFROST_SUBMIT_API` is not enabled, transactions will be submitted using `Kuber`, which may take a few minutes.
4955
50-
### Production Mode
56+
#### Wallet Configuration
5157
52-
To run the Agent Manager application, follow these steps:
58+
- **`MANAGER_WALLET_ADDRESS`** (Optional): Wallet address with sufficient ADA for transfers.
59+
- **`MANAGER_WALLET_SIGNING_KEY`** (Optional): Signing key for the manager wallet.
60+
- **`FAUCET_API_KEY`** (Optional): API key to load ADA for agent transfers if the manager wallet lacks sufficient funds.
61+
- **`AGENT_MNEMONIC`**: Seed phrase used to generate a wallet.
5362
54-
1. Build the application using the following command:
63+
#### Database Configuration
5564
56-
```shell
57-
yarn build
58-
```
65+
- **`DATABASE_URL`**: PostgreSQL database URL. Specify either a local Docker-based database or a deployed database URL.
5966
60-
This will compile the TypeScript files into JavaScript and place the output in the `dist` directory.
67+
#### Server Configuration
6168
62-
2. Run the application with an agent ID as a command-line argument:
69+
- **`SERVER_PORT`** (OPTIONAL): `3002` - Port number for the server. (Default port is 3001)
70+
- **`NETWORK_NAME`**: `sanchonet` - Name of the Cardano network.
6371
64-
```shell
65-
yarn start
66-
```
72+
After updating environment variables make sure to run the following command to generate the database client and creating the required table mentioned in schema
6773
68-
Make sure your API service is up and running .
74+
```bash
75+
yarn prisma generate
76+
```
6977
70-
If successful a server listening on port `3000` will be running:
78+
Now finally run the below command to start the manager:
79+
80+
```bash
81+
yarn dev
82+
```
83+
84+
If successful a server listening on mentioned PORT will be running:
7185
7286
> http://localhost:3001
87+
88+
## Running in `Preprod` or `Preview` Networks
89+
90+
To run in `Preprod` or `Preview` networks, update the following environment variables:
91+
92+
- **`DB_SYNC_BASE_URL`**:
93+
- `https://preprod-dbync.agents.cardanoapi.io/api` for `preprod`
94+
- `https://preview-dbync.agents.cardanoapi.io/api` for `preview`
95+
- **`KUBER_BASE_URL`**:
96+
- `https://preview.kuber.cardanoapi.io` for `preview`
97+
- `https://preprod.kuber.cardanoapi.io` for `preprod`
98+
- **`CARDANO_NETWORK_MAGIC`**:
99+
- `3` for `preview`
100+
- `2` for `preprod`
101+
- **`BLOCKFROST_API_KEY`**: Obtain from [Blockfrost](https://blockfrost.io/) for the desired network.
102+
- **`NETWORK_NAME`**: Set to `preprod` or `preview`.

agent-manager/src/controller/health.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ async function healthCheck(req: Request, res: Response) {
5858
database: {
5959
isHealthy: isDatabaseHealthy,
6060
},
61-
metadata:{
62-
isHealthy:isMetadataHealthy
63-
}
61+
metadata: {
62+
isHealthy: isMetadataHealthy,
63+
},
6464
},
6565
})
6666
} catch (err: any) {

agent-node/.env.example

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
WS_URL=ws://localhost:3001
2-
AGENT_SECRET_KEY=
3-
NETWORK=
41
TOKEN=
2+
WS_URL=ws://localhost:3001

agent-node/README.md

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,36 @@
22

33
This project is a TypeScript client application that connects to a server via WebSocket and processes configurations sent by the server. It can schedule and trigger functions based on received configurations.
44

5-
## Table of Contents
6-
7-
- [Requirements](#requirements)
8-
- [Installation](#installation)
9-
- [Usage](#usage)
10-
- [Development](#development)
11-
125
## Requirements
136

147
- [Node.js](https://nodejs.org/) (v18.18.0 or higher)
158
- [yarn](https://yarnpkg.com/) package manager
9+
- `Agent-Manager` service
10+
- `Fronted` service
11+
- `Backend` service
12+
- `DbSync-api` service
1613

1714
## Installation
1815

19-
1. Clone the repository:
20-
21-
```shell
22-
git clone https://github.com/sireto/cardano-autonomous-agent.git
23-
cd cardano-autonomous-agent/agent-node
24-
```
25-
26-
2. Install dependencies using npm or yarn:
16+
1. Install dependencies using npm or yarn:
2717

2818
```shell
2919
yarn install
3020
```
3121

32-
## Usage
22+
2. Create new file `.env` and copy env variables form `.env.example` to `.env` and update the env variables.
3323

3424
### Setting up environment variables
3525

36-
Copy environment variables from `.env.example` to `.env` and update them as necessary.
26+
- **`TOKEN`**: Run the frontend and visit `My Agent` tab from left bottom section of the page. Then click `Run Agent` button on top right of the `Agent Overview` section. Copy the token part only and paste it in env.
27+
- **`WS_URL`**: `agent-manager` websocket url . Default on `ws://localhost:3001'
3728
38-
> **Note**: AGENT_ID if the ID of the agent created with API.
29+
**`Note`** - Remember to add `ws` as protocol in `WS_URL` instead of `http`.
3930
40-
### Development Mode
31+
Copy environment variables from `.env.example` to `.env` and update them as necessary.
4132
42-
To run the application in dev mode run the following command
33+
Finally run the agent by running below command.
4334
4435
```shell
45-
yarn dev
36+
yarn dev
4637
```
47-
48-
### Production Mode
49-
50-
1. Build the application using the following command:
51-
52-
```shell
53-
yarn build
54-
```
55-
56-
This will compile the TypeScript files into JavaScript and place the output in the `dist` directory.
57-
58-
2. Run the application with an agent ID as a command-line argument:
59-
60-
```shell
61-
yarn start
62-
```

agent-node/src/functions/proposalNewConstitution.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ export default async function handler(
2525
return await context.wallet
2626
.buildAndSubmit(req, true)
2727
.then((v) => v)
28-
.catch(async(e) => {
28+
.catch(async (e) => {
2929
if (e.includes('ProposalReturnAccountDoesNotExist')) {
3030
await context.builtins.registerStake().catch((e) => {
3131
throw e
3232
})
3333
return context.wallet
34-
.buildAndSubmit(req)
35-
.then((v) => v)
36-
.catch((e) => {
37-
throw e
38-
})
34+
.buildAndSubmit(req)
35+
.then((v) => v)
36+
.catch((e) => {
37+
throw e
38+
})
3939
} else {
4040
throw e
4141
}

agent-node/src/functions/treasuryWithdrawal.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ export default async function handler(
3333
},
3434
],
3535
}
36-
return await context.wallet.buildAndSubmit(req, false).catch(async(e)=>{
36+
return await context.wallet.buildAndSubmit(req, false).catch(async (e) => {
3737
if (e.includes('ProposalReturnAccountDoesNotExist')) {
3838
await context.builtins.registerStake().catch((e) => {
3939
throw e
4040
})
4141
return context.wallet
42-
.buildAndSubmit(req)
43-
.then((v) => v)
44-
.catch((e) => {
45-
throw e
46-
})
42+
.buildAndSubmit(req)
43+
.then((v) => v)
44+
.catch((e) => {
45+
throw e
46+
})
4747
} else {
4848
throw e
4949
}

agent-node/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ if (!wsUrl) {
3636
if (network && managerBaseDomain) {
3737
// This is set in docker file
3838
wsUrl = `wss://${network.toLowerCase()}.${managerBaseDomain}`
39-
}
40-
else if (managerBaseDomain){
39+
} else if (managerBaseDomain) {
4140
wsUrl = `ws://${managerBaseDomain}`
42-
}
43-
else {
41+
} else {
4442
wsUrl = 'ws://localhost:3001'
4543
}
4644
}

0 commit comments

Comments
 (0)