Skip to content

Latest commit

Β 

History

History
434 lines (329 loc) Β· 8.14 KB

File metadata and controls

434 lines (329 loc) Β· 8.14 KB

Getting Started with Galaxy DevKit

Welcome to Galaxy DevKit! This guide will help you get up and running with the complete development framework for Stellar ecosystem.

πŸš€ Quick Start

Prerequisites

Before you begin, make sure you have the following installed:

Installation

  1. Clone the repository:

    git clone https://github.com/galaxy-devkit/galaxy-devkit.git
    cd galaxy-devkit
  2. Install dependencies:

    npm install
  3. Bootstrap the monorepo:

    npm run bootstrap
  4. Start development:

    npm run dev

πŸ—οΈ Project Structure

Galaxy DevKit is organized as a monorepo with the following structure:

galaxy-devkit/
β”œβ”€β”€ packages/                 # Core packages
β”‚   β”œβ”€β”€ core/               # Core functionality
β”‚   β”œβ”€β”€ contracts/          # Smart contracts
β”‚   β”œβ”€β”€ api/               # API packages
β”‚   β”œβ”€β”€ sdk/               # SDK packages
β”‚   └── templates/         # Project templates
β”œβ”€β”€ tools/                  # Development tools
β”œβ”€β”€ docs/                  # Documentation
β”œβ”€β”€ examples/              # Example projects
└── tests/                 # Test suites

πŸ”§ Configuration

Environment Setup

  1. Create environment file:

    cp .env.example .env
  2. Configure environment variables:

    # Galaxy API Configuration
    GALAXY_API_URL=http://localhost:3001
    GALAXY_WEBSOCKET_URL=ws://localhost:3001
    GALAXY_NETWORK=testnet
    
    # Supabase Configuration
    SUPABASE_URL=your-supabase-url
    SUPABASE_ANON_KEY=your-supabase-anon-key
    SUPABASE_SERVICE_ROLE_KEY=your-supabase-service-role-key
    
    # Stellar Configuration
    STELLAR_NETWORK=testnet
    STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org

Supabase Setup

  1. Create Supabase project:

    • Go to supabase.com
    • Create a new project
    • Get your project URL and API keys
  2. Initialize Supabase:

    supabase init
  3. Start Supabase locally:

    supabase start
  4. Run migrations:

    supabase db push

πŸš€ Creating Your First Project

Using the CLI

Option 1: Using CLI from the Monorepo (Recommended for Contributors)

  1. Build the CLI:

    npm run build
  2. Create a new project:

    node tools/cli/dist/tools/cli/src/index.js create my-dapp --template basic
  3. Or link the CLI globally:

    cd tools/cli
    npm run build
    npm link
    cd ../..
  4. Now you can use the galaxy command:

    galaxy create my-dapp --template basic
  5. Navigate to project:

    cd my-dapp
  6. Install dependencies:

    npm install
  7. Start development server:

    npm run dev

Option 2: Using Published CLI (For End Users)

  1. Install Galaxy CLI globally:

    npm install -g @galaxy/cli
  2. Create a new project:

    galaxy create my-dapp --template basic
  3. Navigate to project:

    cd my-dapp
  4. Install dependencies:

    npm install
  5. Start development server:

    npm run dev

Manual Setup

  1. Create project directory:

    mkdir my-dapp
    cd my-dapp
  2. Initialize project:

    galaxy init --template basic
  3. Install dependencies:

    npm install
  4. Start development:

    npm run dev

πŸ“± Available Templates

Basic Template

A simple Stellar DApp with wallet connection and basic operations.

Features:

  • Wallet connection
  • Balance display
  • Send payments
  • Transaction history

DeFi Template

A DeFi application with advanced features.

Features:

  • Smart contracts
  • Automated trading
  • Liquidity management
  • Price oracles

NFT Template

An NFT marketplace template.

Features:

  • NFT creation
  • Marketplace functionality
  • Royalty management
  • Metadata handling

Enterprise Template

An enterprise-grade application template.

Features:

  • Multi-tenant architecture
  • Advanced security
  • Compliance features
  • Analytics dashboard

πŸ› οΈ Development Workflow

Working with Packages

  1. Navigate to package:

    cd packages/core/stellar-sdk
  2. Start development:

    npm run dev
  3. Run tests:

    npm run test
  4. Build package:

    npm run build

Adding New Features

  1. Create feature branch:

    git checkout -b feature/my-feature
  2. Make changes:

    • Add new functionality
    • Write tests
    • Update documentation
  3. Test changes:

    npm run test
    npm run lint
  4. Commit changes:

    git add .
    git commit -m "feat: add my feature"
  5. Push changes:

    git push origin feature/my-feature

πŸ§ͺ Testing

Running Tests

# Run all tests
npm run test

# Run tests for specific package
cd packages/core/stellar-sdk
npm run test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

Test Structure

tests/
β”œβ”€β”€ unit/                 # Unit tests
β”‚   β”œβ”€β”€ stellar-sdk.test.ts
β”‚   β”œβ”€β”€ invisible-wallet.test.ts
β”‚   └── automation.test.ts
β”œβ”€β”€ integration/         # Integration tests
β”‚   β”œβ”€β”€ api.test.ts
β”‚   β”œβ”€β”€ contracts.test.ts
β”‚   └── sdk.test.ts
β”œβ”€β”€ e2e/                 # End-to-end tests
β”‚   β”œβ”€β”€ wallet-flow.test.ts
β”‚   └── payment-flow.test.ts
└── setup.ts             # Test setup

πŸ“¦ Building and Deployment

Building

# Build all packages
npm run build

# Build specific package
cd packages/core/stellar-sdk
npm run build

Deployment

# Deploy to testnet
galaxy deploy --network testnet

# Deploy to mainnet
galaxy deploy --network mainnet

# Deploy specific contract
galaxy deploy --contract my-contract

πŸ” Debugging

Development Tools

  1. VS Code Extensions:

    • TypeScript
    • ESLint
    • Prettier
    • Stellar
  2. Browser DevTools:

    • Network tab for API calls
    • Console for logs
    • Application tab for storage
  3. Stellar Laboratory:

Common Issues

  1. Connection Issues:

    • Check network configuration
    • Verify API endpoints
    • Check firewall settings
  2. Build Issues:

    • Clear node_modules
    • Check TypeScript errors
    • Verify dependencies
  3. Test Issues:

    • Check test environment
    • Verify mocks
    • Check test data

πŸ“š Next Steps

Now that you have Galaxy DevKit set up, here are some next steps:

  1. Explore the Examples:

    • Check out the examples/ directory
    • Run example projects
    • Study the code
  2. Read the Documentation:

  3. Join the Community:

  4. Contribute:

    • Fork the repository
    • Create a feature branch
    • Submit a pull request

πŸ†˜ Getting Help

If you run into issues:

  1. Check the Documentation:

    • This getting started guide
    • API reference
    • SDK documentation
  2. Search Issues:

  3. Ask for Help:


Happy coding with Galaxy DevKit! πŸš€