Finalex is a comprehensive, high-performance cryptocurrency exchange platform built with Go, featuring advanced trading engines, comprehensive compliance systems, and enterprise-grade security.
Major Legacy Code Cleanup Completed - We've successfully consolidated and modernized our codebase:
- β Unified Error Handling: RFC 7807 compliant error responses across all APIs
- β Consolidated Validation: Streamlined validation middleware system
- β Structured API Layer: Organized handlers, middleware, and responses
- β 40% Code Reduction: Eliminated duplications while improving functionality
π View Full Cleanup Report | See Changelog
Finalex/
βββ π api/ # Unified API layer (NEW)
β βββ handlers/ # Request handlers
β βββ middleware/ # API middleware
β βββ responses/ # Standardized responses
β βββ routes/ # Route definitions
βββ π₯οΈ cmd/ # Application entry points
β βββ pincex/ # Main exchange application
β βββ run_trading_tests/ # Trading system tests
βββ π οΈ common/ # Shared utilities
β βββ apiutil/ # API utilities
β βββ auth/ # Authentication
β βββ cfg/ # Configuration
β βββ dbutil/ # Database utilities
βββ π internal/ # Private application code
β βββ accounts/ # Account management
β βββ compliance/ # Regulatory compliance
β βββ trading/ # Trading engine
β βββ userauth/ # User authentication
β βββ wallet/ # Wallet management
βββ π¦ pkg/ # Public packages
βββ errors/ # Unified error handling
βββ logger/ # Logging framework
βββ marketdata/ # Market data client
βββ metrics/ # Metrics collection
βββ models/ # Data models
βββ validation/ # Input validation
- High-frequency trading support with microsecond latency
- Multiple order types: Market, Limit, Stop-Loss, Take-Profit
- Advanced matching engine with price-time priority
- Real-time market data streaming via WebSocket
- Cross-pair arbitrage detection and execution
- Multi-factor authentication (2FA/MFA) required
- KYC/AML compliance with automated screening
- Rate limiting and DDoS protection
- End-to-end encryption for sensitive data
- Comprehensive audit trails with trace IDs
- Real-time price feeds from multiple sources
- Advanced charting with technical indicators
- Historical data storage and analysis
- Market manipulation detection systems
- Risk management with position limits
- Multi-currency support (crypto and fiat)
- Hot/cold wallet management
- Automated settlement systems
- Liquidity management across pairs
- Transaction batching for efficiency
- Go 1.21+ installed
- PostgreSQL 14+ for data storage
- Redis 7+ for caching and sessions
- Docker (optional, for containerized deployment)
-
Clone the repository
git clone https://github.com/Aidin1998/finalex.git cd finalex -
Install dependencies
go mod download go mod tidy
-
Build the application
go build ./...
-
Run the main application
go run cmd/pincex/main.go
-
Run the admin API (separate terminal)
go run -tags admin cmd/pincex/admin_api_main.go
The application uses YAML configuration files located in the configs/ directory:
transaction-manager.yaml- Core transaction settingsrisk-management.yaml- Risk parameters and limitsfee-config.yaml- Trading fee structureaml-us.yaml/aml-eu.yaml- Regional compliance rules
All API responses follow our standardized format:
{
"success": true,
"data": { ... },
"message": "Operation completed successfully",
"timestamp": "2025-06-09T10:30:00Z",
"trace_id": "req_abc123def456"
}{
"type": "https://api.finalex.io/problems/insufficient-funds",
"title": "Insufficient Funds",
"status": 422,
"detail": "Account balance insufficient for order placement",
"instance": "/api/v1/trading/orders",
"trace_id": "req_abc123def456"
}| Endpoint | Method | Description |
|---|---|---|
/api/v1/trading/orders |
POST | Place a new order |
/api/v1/trading/orders |
GET | List user orders |
/api/v1/trading/orders/{id} |
GET | Get order details |
/api/v1/trading/orders/{id} |
DELETE | Cancel an order |
/api/v1/marketdata/symbols |
GET | List trading pairs |
/api/v1/marketdata/ticker/{symbol} |
GET | Get ticker data |
/api/v1/wallet/balances |
GET | Get account balances |
π Complete API Documentation
import "github.com/Aidin1998/finalex/pkg/errors"
// Create business-specific errors
err := errors.NewInsufficientFundsError("Balance too low", "/api/v1/orders")
// Use in API responses
responses.Error(c, err)import "github.com/Aidin1998/finalex/pkg/validation"
// Apply unified validation with different profiles
router.Use(validation.UnifiedMiddleware(validation.ConfigMedium))import "github.com/Aidin1998/finalex/api/responses"
// Success responses
responses.Success(c, orderData, "Order placed successfully")
// Error responses with problem details
responses.Error(c, errors.NewValidationError("Invalid input", path))# Run all tests
go test ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# Run trading system tests
go run cmd/run_trading_tests/main.go# Build all components
go build ./...
# Build specific components
go build -o finalex cmd/pincex/main.go
go build -o admin-api -tags admin cmd/pincex/admin_api_main.go
# Build for production
go build -ldflags="-w -s" -o finalex cmd/pincex/main.go# Build production image
docker build -f Dockerfile.production -t finalex:latest .
# Run with docker-compose
docker-compose up -d# Deploy to Kubernetes
kubectl apply -f infra/k8s/deployments/
kubectl apply -f infra/k8s/monitoring/# Deploy infrastructure
cd infra/terraform
terraform init
terraform plan
terraform apply| Variable | Description | Default |
|---|---|---|
DB_HOST |
PostgreSQL host | localhost |
DB_PORT |
PostgreSQL port | 5432 |
REDIS_HOST |
Redis host | localhost |
REDIS_PORT |
Redis port | 6379 |
API_PORT |
API server port | 8080 |
ADMIN_PORT |
Admin API port | 8081 |
LOG_LEVEL |
Logging level | info |
ENABLE_MARKET_MAKING- Enable automated market makingENABLE_CROSS_PAIR_ARBITRAGE- Enable arbitrage detectionSTRICT_VALIDATION- Use strict validation profileENABLE_METRICS- Enable Prometheus metrics
- Trading metrics: Orders, fills, volume
- System metrics: Latency, errors, throughput
- Business metrics: Revenue, fees, user activity
- Trace ID integration for request tracking
- Structured JSON logging format
- Log levels: Debug, Info, Warn, Error
- Audit trail for compliance
- Liveness probe:
/health/live - Readiness probe:
/health/ready - Dependency checks: Database, Redis, external APIs
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Follow code standards: Use unified error handling and validation
- Add tests: Ensure > 80% coverage
- Update documentation: Keep README and API docs current
- Submit pull request: Include detailed description
- Use unified error handling:
pkg/errorspackage only - Follow RFC 7807: For all error responses
- Use structured logging: With trace IDs
- Add comprehensive tests: Unit and integration
- Document public APIs: With examples
- Unit tests:
*_test.gofiles alongside source - Integration tests:
test/directory - Benchmark tests: For performance-critical code
- Mock external dependencies: Use interfaces
- API Documentation - Complete API reference
- Validation Guide - Validation system
- Migration Guide - Update existing code
- Operational Guide - Production operations
- Legacy Cleanup Report - Recent improvements
Please report security vulnerabilities to: security@finalex.io
- Rate limiting on all endpoints
- Input validation and sanitization
- SQL injection prevention
- XSS protection for web interfaces
- CORS configuration for API access
- TLS encryption for all communications
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: docs/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@finalex.io
- GraphQL API implementation
- Advanced order types (Iceberg, TWAP)
- Mobile API optimization
- Institutional features (block trading)
- DeFi integration protocols
- Layer 2 scaling solutions
- Advanced analytics dashboard
- Multi-region deployment
Built with β€οΈ by the Finalex Team
Last Updated: June 9, 2025