Developer Guide¶

This guide provides comprehensive information for developers who want to contribute to or extend the Velocimex platform.

Table of Contents¶

Development Environment¶

Prerequisites¶

  • Go 1.21 or later

  • Node.js 18 or later

  • Docker and Docker Compose

  • Git

  • Make

Setting Up the Environment¶

  1. Clone the Repository

git clone https://github.com/velocimex/velocimex.git
cd velocimex
  1. Install Dependencies

# Install Go dependencies
go mod download

# Install Node.js dependencies
cd frontend
npm install
  1. Environment Variables Create a .env file in the root directory:

VELOCIMEX_ENV=development
VELOCIMEX_DEBUG=true
VELOCIMEX_DB_HOST=localhost
VELOCIMEX_DB_PORT=5432
VELOCIMEX_DB_USER=postgres
VELOCIMEX_DB_PASSWORD=your_password

Building from Source¶

Backend¶

# Build the backend
make build-backend

# Run tests
make test-backend

# Run linter
make lint-backend

Frontend¶

# Build the frontend
make build-frontend

# Run tests
make test-frontend

# Run linter
make lint-frontend

Docker¶

# Build all containers
make docker-build

# Run the application
make docker-up

Testing¶

Unit Tests¶

# Run all unit tests
go test ./...

# Run tests with coverage
go test -cover ./...

# Run specific package tests
go test ./pkg/marketdata

Integration Tests¶

# Run integration tests
make test-integration

# Run specific integration test
go test -tags=integration ./tests/integration/marketdata

Performance Tests¶

# Run performance benchmarks
go test -bench=. ./...

# Run specific benchmark
go test -bench=BenchmarkOrderBook ./pkg/marketdata

Contributing Guidelines¶

Code Style¶

  • Follow Go standard formatting (go fmt)

  • Use meaningful variable and function names

  • Write comprehensive comments

  • Follow the project’s coding conventions

Git Workflow¶

  1. Create a Branch

git checkout -b feature/your-feature-name
  1. Make Changes

  • Write code

  • Add tests

  • Update documentation

  1. Commit Changes

git add .
git commit -m "feat: add new feature"
  1. Push Changes

git push origin feature/your-feature-name
  1. Create Pull Request

  • Fill out the PR template

  • Request review

  • Address feedback

Documentation¶

  • Update relevant documentation

  • Add examples where necessary

  • Include API changes

  • Document new features

Plugin Development¶

Creating a New Plugin¶

  1. Create Plugin Structure

mkdir -p plugins/your-plugin
cd plugins/your-plugin
  1. Implement Plugin Interface

package yourplugin

import (
    "github.com/velocimex/plugin"
)

type YourPlugin struct {
    // Plugin fields
}

func (p *YourPlugin) Initialize(config plugin.Config) error {
    // Initialize plugin
    return nil
}

func (p *YourPlugin) Start() error {
    // Start plugin
    return nil
}

func (p *YourPlugin) Stop() error {
    // Stop plugin
    return nil
}
  1. Register Plugin

func init() {
    plugin.Register("your-plugin", func() plugin.Plugin {
        return &YourPlugin{}
    })
}

Plugin Configuration¶

plugins:
  your-plugin:
    enabled: true
    config:
      setting1: value1
      setting2: value2

Performance Optimization¶

Backend Optimization¶

  1. Profiling

# Generate CPU profile
go test -cpuprofile=cpu.prof -bench=.

# Generate memory profile
go test -memprofile=mem.prof -bench=.
  1. Benchmarking

func BenchmarkOrderBook(b *testing.B) {
    for i := 0; i < b.N; i++ {
        // Benchmark code
    }
}

Frontend Optimization¶

  1. Bundle Analysis

npm run build -- --analyze
  1. Performance Monitoring

// Add performance monitoring
performance.mark('start');
// Your code
performance.mark('end');
performance.measure('operation', 'start', 'end');

Database Optimization¶

  1. Indexing

CREATE INDEX idx_trades_timestamp ON trades(timestamp);
CREATE INDEX idx_orders_status ON orders(status);
  1. Query Optimization

EXPLAIN ANALYZE SELECT * FROM trades WHERE timestamp > NOW() - INTERVAL '1 day';

Best Practices¶

  1. Code Quality

    • Write clean, maintainable code

    • Follow SOLID principles

    • Use design patterns appropriately

  2. Testing

    • Write comprehensive tests

    • Maintain high test coverage

    • Include edge cases

  3. Documentation

    • Keep documentation up-to-date

    • Include examples

    • Document API changes

  4. Security

    • Follow security best practices

    • Regular security audits

    • Input validation

  5. Performance

    • Profile regularly

    • Optimize critical paths

    • Monitor resource usage

For more information about specific components, refer to the Technical Documentation.