Getting Started

This guide will help you set up your development environment and understand the basic architecture of the Ava Portfolio Manager project.

Prerequisites

Before you begin, ensure you have the following installed on your system:

Setting Up Your Development Environment

1. Clone the Repository

git clone https://github.com/your-org/ava-portfolio-manager.git
cd ava-portfolio-manager

2. Install Dependencies

The project is structured as a monorepo with two main directories:

  • server/ - Backend Node.js server

  • frontend/ - Next.js frontend application

Install dependencies for both:

3. Set Up Environment Variables

Create the necessary environment files:

Edit the .env.local files with your specific configuration values.

4. Start Development Servers

You can start both the frontend and backend in development mode:

The backend server will be available at http://localhost:3001 and the frontend at http://localhost:3000.

Project Structure

Backend (Server)

The backend is organized as follows:

Frontend

The frontend is built with Next.js and organized as follows:

Core Concepts

Agent System

The Ava Portfolio Manager is built around a multi-agent system:

  1. Eliza Agent - The primary conversational interface that processes natural language and coordinates between other agents.

  2. Sonic Agent - Handles DeFi protocol interactions, including transactions and data fetching.

  3. Move Agent - Provides portfolio analysis, strategy suggestions, and financial modeling.

  4. Task Manager Agent - Coordinates tasks between agents and manages the workflow.

Event Bus

Agents communicate through a central event bus, which follows a publish-subscribe pattern:

Plugin System

The Sonic Agent uses a plugin system to interact with different DeFi protocols:

Development Workflow

Adding a New Feature

  1. Create a branch:

  2. Implement your changes:

    • For new agent capabilities, add methods to the relevant agent class

    • For new UI features, add components and update pages

    • Add tests for your changes

  3. Run tests:

  4. Submit a pull request:

    • Ensure your code follows the project's style guide

    • Include a description of your changes

    • Reference any related issues

Adding a New Protocol Integration

To add support for a new DeFi protocol:

  1. Create a new plugin in server/src/agents/plugins/:

  2. Implement the plugin with necessary methods:

  3. Update the Sonic Agent to use your plugin:

Testing

Unit Tests

Run unit tests for a specific component:

Integration Tests

Integration tests can be run with:

End-to-End Tests

End-to-end tests use Cypress:

Debugging

Server Debugging

For detailed server logs:

Transaction Debugging

To debug blockchain transactions:

Frontend Debugging

For frontend debugging, use the browser's developer tools. The application also provides debug information in the browser console when running in development mode.

Common Issues and Solutions

"Cannot find module" Error

If you encounter a "Cannot find module" error:

Server Connection Issues

If the frontend can't connect to the backend:

  1. Check that both servers are running

  2. Verify the API URL in the frontend's .env.local

  3. Check for any CORS issues in the browser console

Database Connection Issues

If there are database connection errors:

  1. Check your database configuration in server/.env.local

  2. Ensure the database server is running

  3. Try resetting the database with bun run db:reset

Next Steps

Once you have your development environment set up, you can:

Contributing

Before submitting your changes, please:

  1. Ensure all tests pass

  2. Update documentation if necessary

  3. Follow the coding style guidelines

  4. Write meaningful commit messages

Need Help?

If you need assistance:

Last updated