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¶
Clone the Repository
git clone https://github.com/velocimex/velocimex.git
cd velocimex
Install Dependencies
# Install Go dependencies
go mod download
# Install Node.js dependencies
cd frontend
npm install
Environment Variables Create a
.envfile 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¶
Create a Branch
git checkout -b feature/your-feature-name
Make Changes
Write code
Add tests
Update documentation
Commit Changes
git add .
git commit -m "feat: add new feature"
Push Changes
git push origin feature/your-feature-name
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¶
Create Plugin Structure
mkdir -p plugins/your-plugin
cd plugins/your-plugin
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
}
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¶
Profiling
# Generate CPU profile
go test -cpuprofile=cpu.prof -bench=.
# Generate memory profile
go test -memprofile=mem.prof -bench=.
Benchmarking
func BenchmarkOrderBook(b *testing.B) {
for i := 0; i < b.N; i++ {
// Benchmark code
}
}
Frontend Optimization¶
Bundle Analysis
npm run build -- --analyze
Performance Monitoring
// Add performance monitoring
performance.mark('start');
// Your code
performance.mark('end');
performance.measure('operation', 'start', 'end');
Database Optimization¶
Indexing
CREATE INDEX idx_trades_timestamp ON trades(timestamp);
CREATE INDEX idx_orders_status ON orders(status);
Query Optimization
EXPLAIN ANALYZE SELECT * FROM trades WHERE timestamp > NOW() - INTERVAL '1 day';
Best Practices¶
Code Quality
Write clean, maintainable code
Follow SOLID principles
Use design patterns appropriately
Testing
Write comprehensive tests
Maintain high test coverage
Include edge cases
Documentation
Keep documentation up-to-date
Include examples
Document API changes
Security
Follow security best practices
Regular security audits
Input validation
Performance
Profile regularly
Optimize critical paths
Monitor resource usage
For more information about specific components, refer to the Technical Documentation.