Skip to content
NotVadushaPublic

About

The experiment app focused on predicting crypto prices based on sentiment and previous history. Tried ML and LLM approach.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Crypto Bro

An AI-powered cryptocurrency trading recommendation platform that analyzes market data and social sentiment to provide buy/sell/hold recommendations for cryptocurrencies.

Overview

Crypto Bro combines real-time market data from CoinGecko, social sentiment from Twitter/X, and OpenAI's language models to generate intelligent trading recommendations. The platform stores predictions in PostgreSQL and provides observability through Langfuse.

How It Works

  1. User selects a cryptocurrency in the frontend
  2. Backend fetches data from multiple sources:
    • Market data (price, volume, market cap) from CoinGecko
    • Social sentiment from Twitter/X API
    • Historical data and technical indicators
  3. AI generates recommendation using OpenAI with a structured prompt
  4. Prediction is stored in PostgreSQL with metadata (risk level, rationale, trace ID)
  5. Results are displayed in the frontend with detailed analysis

Repository Structure

This is a monorepo containing three main components:

Directory Purpose
crypto-bro-frontend React + Vite + TypeScript SPA with Tailwind CSS, TanStack Query, and shadcn-style UI components. Handles user interactions and displays AI predictions.
crypto-bro-backend NestJS REST API with TypeORM and PostgreSQL. Integrates with CoinGecko, Twitter/X, OpenAI, and Langfuse. Serves prediction endpoints and manages data persistence.
crypto-bro-ml-model Python workspace for data collection and machine learning experiments. Contains Kaggle datasets, data aggregation scripts (gather_data.py), and training scripts in previous_attempts/.

Architecture Flow

graph LR
    Frontend[React Frontend] -->|API Calls| Backend[NestJS Backend]
    Backend -->|Market Data| CoinGecko[CoinGecko API]
    Backend -->|Sentiment| Twitter[Twitter/X API]
    Backend -->|AI Analysis| OpenAI[OpenAI API]
    Backend -->|Store| PostgreSQL[(PostgreSQL)]
    Backend -->|Observability| Langfuse[Langfuse]
Loading

Tech Stack

Frontend

  • React 19 - UI framework
  • Vite - Build tool and dev server
  • TypeScript - Type safety
  • Tailwind CSS - Styling
  • TanStack Query - Data fetching and caching
  • shadcn/ui - UI component library

Backend

  • NestJS - Node.js framework
  • TypeORM - ORM for PostgreSQL
  • PostgreSQL - Database
  • OpenAI AI SDK - AI model integration
  • Langfuse - LLM observability
  • CoinGecko API - Cryptocurrency market data
  • Twitter/X API - Social sentiment data
  • Tardis - Exchange and symbol data

ML/Data

  • Python 3 - Data processing
  • pandas - Data manipulation
  • TensorFlow - Machine learning
  • scikit-learn - ML utilities
  • ta - Technical analysis indicators

Quickstart Guide

Prerequisites

  • Node.js (v18 or higher) - For frontend and backend
  • PostgreSQL (v12 or higher) - For backend database
  • Python 3 (optional) - For ML/data scripts

Backend Setup

  1. Create the database:

    CREATE DATABASE crypto_bro;
  2. Navigate to backend directory:

    cd crypto-bro-backend
  3. Install dependencies:

    npm install
  4. Configure environment variables:

    Create a .env file in crypto-bro-backend/ with the following variables:

    # Database Configuration
    DB_HOST=localhost
    DB_PORT=5432
    DB_USERNAME=postgres
    DB_PASSWORD=postgres
    DB_NAME=crypto_bro
    
    # Server Configuration
    PORT=4000
    NODE_ENV=development
    
    # OpenAI Configuration
    OPENAI_API_KEY=your_openai_api_key_here
    
    # Langfuse Configuration (for observability)
    LANGFUSE_SECRET_KEY=your_langfuse_secret_key
    LANGFUSE_PUBLIC_KEY=your_langfuse_public_key
    LANGFUSE_URL=https://cloud.langfuse.com
    
    # CoinGecko API Configuration
    COINGECKO_API_URL=https://api.coingecko.com/api/v3
    COINGECKO_API_KEY=your_coingecko_api_key_here
    
    # Twitter/X API Configuration
    TWITTER_IO_API_URL=your_twitter_io_api_url
    TWITTER_IO_API_KEY=your_twitter_io_api_key
  5. Start the backend server:

    npm run start:dev

    The API will be available at http://localhost:4000

Frontend Setup

  1. Navigate to frontend directory:

    cd crypto-bro-frontend
  2. Install dependencies:

    pnpm install

    Or using npm:

    npm install
  3. Configure environment variables:

    Create a .env or .env.local file in crypto-bro-frontend/:

    VITE_CRYPTO_BRO_BACKEND_URL=http://localhost:4000
  4. Start the development server:

    pnpm dev

    Or using npm:

    npm run dev

    The frontend will be available at http://localhost:5173 (or the port shown in terminal)

ML/Data Setup (Optional)

  1. Navigate to ML model directory:

    cd crypto-bro-ml-model
  2. Create a virtual environment:

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Run data scripts as needed:

    python gather_data.py

API Endpoints

The backend provides the following main endpoints:

  • GET /ai-predictions - Get all predictions (with pagination)
  • GET /ai-predictions/:id - Get a specific prediction by ID
  • POST /ai-predictions/:assetId - Generate a new AI prediction for the specified cryptocurrency

For detailed API documentation, see crypto-bro-backend/README.md.

Database Schema

The ai_predictions table stores all generated predictions with the following structure:

Column Type Description
id uuid Primary key
crypto_symbol varchar(10) Cryptocurrency symbol (e.g., BTC, ETH)
langfuse_trace_id uuid Trace ID for Langfuse monitoring
generated_at timestamp When the prediction was generated
recommendation enum Buy, Sell, or Hold
summary text Detailed analysis and rationale
risk_level enum Low, Medium, or High

Additional Resources

  • Backend README - Detailed backend setup, database configuration, and API documentation
  • Frontend README - Frontend development guidelines and ESLint configuration

Development

Running Tests

Backend:

cd crypto-bro-backend
npm run test          # Unit tests
npm run test:e2e      # End-to-end tests
npm run test:cov      # Coverage report

Frontend:

cd crypto-bro-frontend
npm run lint          # Lint code

Building for Production

Backend:

cd crypto-bro-backend
npm run build
npm run start:prod

Frontend:

cd crypto-bro-frontend
npm run build
npm run preview      # Preview production build

License

This project is private and unlicensed.

About

The experiment app focused on predicting crypto prices based on sentiment and previous history. Tried ML and LLM approach.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages