Backend API service for TruffleBox UI - the web interface for BharatML Stack. Provides REST APIs and data management capabilities to support the frontend dashboard.
Horizon serves as the backend infrastructure for TruffleBox UI, offering:
- REST API Layer: Provides endpoints for the TruffleBox UI frontend
- Data Management: Handles feature store metadata and configuration
- Authentication & Authorization: Manages user access and permissions
- Integration Layer: Connects with BharatML Stack components
- Monitoring & Analytics: Provides insights and monitoring capabilities
┌─────────────────┐ HTTP/REST ┌─────────────────┐
│ TruffleBox UI │ ◄─────────────► │ Horizon │
│ (Frontend) │ │ (Backend) │
└─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ BharatML Stack │
│ Components │
└─────────────────┘
- RESTful APIs: Clean HTTP APIs for frontend integration
- High Performance: Built with Go for optimal performance
- Scalable: Designed for horizontal scaling
- Database Integration: Persistent storage for configuration and metadata
- CORS Support: Proper cross-origin resource sharing for web frontend
- Monitoring: Built-in observability and health checks
- Docker Ready: Containerized for easy deployment
Horizon provides various API endpoints to support TruffleBox UI functionality:
/api/v1/features- Feature management APIs/api/v1/models- Model metadata and serving/api/v1/health- Health check endpoints/api/v1/metrics- Monitoring and analytics/api/v1/auth- Authentication endpoints
- Go 1.22 or later
- Database (PostgreSQL/MySQL)
- Docker (optional, for containerization)
- Start the infrastructure using quick-start interactive startup
# Clone and navigate to the project
cd horizon
# Install dependencies
go mod download
# Set up environment variables
cp env.example ./cmd/horizon/.env
# Edit .env with your configuration
# Run tests
go test -v ./...
# Build the application
go build -v ./cmd/horizon
# Run the service
bash -c 'set -a; source ./cmd/horizon/.env; set +a; exec go run ./cmd/horizon'Create a .env file or set environment variables:
# APPLICATION CONFIGURATION - Basic app settings
APP_NAME=horizon
APP_ENVIRONMENT=PROD
APP_ENV=production
APP_PORT=8082
APP_LOG_LEVEL=DEBUG
# Optional - Performance tuning parameters
APP_METRIC_SAMPLING_RATE=1
APP_GC_PERCENTAGE=1
# MYSQL DATABASE CONFIGURATION - Primary data storage
# Master Database (required for write operations)
MYSQL_MASTER_HOST=127.0.0.1
MYSQL_MASTER_PORT=3306
MYSQL_MASTER_USERNAME=root
MYSQL_MASTER_PASSWORD=root
MYSQL_MASTER_MAX_POOL_SIZE=5
MYSQL_MASTER_MIN_POOL_SIZE=2
# Slave Database (optional for read-only operations)
MYSQL_SLAVE_HOST=127.0.0.1
MYSQL_SLAVE_PORT=3306
MYSQL_SLAVE_USERNAME=root
MYSQL_SLAVE_PASSWORD=root
MYSQL_SLAVE_MAX_POOL_SIZE=5
MYSQL_SLAVE_MIN_POOL_SIZE=2
MYSQL_DB_NAME=testdb
# ETCD CONFIGURATION - Distributed configuration management
ETCD_WATCHER_ENABLED=true
ETCD_SERVER=127.0.0.1:2379
# CORS CONFIGURATION - Cross-origin resource sharing for frontend
CORS_ORIGINS=http://localhost:3000,http://localhost:8080
# ONLINE FEATURE STORE INTEGRATION - BharatML Stack component integration
ONLINE_FEATURE_STORE_APP_NAME=onfs
# REDIS FAILOVER CONFIGURATION - Distributed caching or redis storage layer
# Can be used for either distributed caching or as a redis storage layer
STORAGE_REDIS_FAILOVER_2_SENTINEL_ADDRESSES=localhost:26379
STORAGE_REDIS_FAILOVER_2_DB=0
STORAGE_REDIS_FAILOVER_2_DISABLE_IDENTITY=true
STORAGE_REDIS_FAILOVER_2_MASTER_NAME=mymaster
STORAGE_REDIS_FAILOVER_2_MAX_IDLE_CONN=32
STORAGE_REDIS_FAILOVER_2_MIN_IDLE_CONN=20
STORAGE_REDIS_FAILOVER_2_MAX_ACTIVE_CONN=32
STORAGE_REDIS_FAILOVER_2_MAX_RETRY=-1
STORAGE_REDIS_FAILOVER_2_POOL_FIFO=false
STORAGE_REDIS_FAILOVER_2_READ_TIMEOUT_IN_MS=3000
STORAGE_REDIS_FAILOVER_2_WRITE_TIMEOUT_IN_MS=3000
STORAGE_REDIS_FAILOVER_2_POOL_TIMEOUT_IN_MS=3000
STORAGE_REDIS_FAILOVER_2_POOL_SIZE=32
STORAGE_REDIS_FAILOVER_2_CONN_MAX_IDLE_TIMEOUT_IN_MINUTES=15
STORAGE_REDIS_FAILOVER_2_CONN_MAX_AGE_IN_MINUTES=30
# SCYLLA DATABASE CONFIGURATION - NoSQL storage for features
STORAGE_SCYLLA_1_CONTACT_POINTS=127.0.0.1
STORAGE_SCYLLA_1_KEYSPACE=onfs
STORAGE_SCYLLA_1_NUM_CONNS=1
STORAGE_SCYLLA_1_PORT=9042
STORAGE_SCYLLA_1_TIMEOUT_IN_MS=10000
STORAGE_SCYLLA_1_USERNAME=
STORAGE_SCYLLA_1_PASSWORD=
# ACTIVE STORAGE CONFIGURATION - Which storage backends to use
STORAGE_SCYLLA_ACTIVE_CONFIG_IDS=1
STORAGE_REDIS_FAILOVER_ACTIVE_CONFIG_IDS=2# Run all tests
go test -v ./...
# Run tests with coverage
go test -v -cover ./...
# Run specific test package
go test -v ./pkg/api/...
# Run integration tests
go test -v -tags=integration ./...# Clone and navigate to the project
cd horizon
# Build for current platform
go build -v ./cmd/horizon
# Build for production
make build
# Build for specific platform
GOOS=linux GOARCH=amd64 go build -v ./cmd/horizon# Clone and navigate to the project
cd horizon
# Build Docker image
docker build -t horizon -f cmd/horizon/Dockerfile .
# Run container with environment variables
docker run -p 8080:8080 \
--env-file ./cmd/horizon/.env \
--network onfs-network \
horizonHorizon is designed to work seamlessly with TruffleBox UI:
-
Start Horizon Backend:
cd horizon go run ./cmd/horizon # Backend runs on http://localhost:8080
-
Start TruffleBox UI Frontend:
cd trufflebox-ui npm install npm start # Frontend runs on http://localhost:3000
-
Configure API Base URL in TruffleBox UI:
// trufflebox-ui/.env REACT_APP_API_BASE_URL=http://localhost:8080/api/v1
curl http://localhost:8080/api/v1/health# Get all features
curl http://localhost:8080/api/v1/features
# Get specific feature
curl http://localhost:8080/api/v1/features/{feature_id}# Login
curl -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "user", "password": "pass"}'# Clone and navigate to the project
cd horizon
# Build production image
docker build -t horizon:latest -f cmd/horizon/Dockerfile .
# Run in production mode
docker run -d \
--name horizon \
-p 8080:8080 \
--env-file ./cmd/horizon/.env \
horizon:latest- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for your changes
- Ensure all tests pass (
go test -v ./...) - Update API documentation if needed
- Submit a pull request
- TruffleBox UI: Frontend web interface that uses this backend
- Online Feature Store: Core feature store service
- Python SDK: Python client libraries
We welcome contributions from the community! Please see our Contributing Guide for details on how to get started.
- 💬 Discord: Join our community chat
- 🐛 Issues: Report bugs and request features on GitHub Issues
- 📧 Email: Contact us at ml-oss@meesho.com
BharatMLStack is open-source software licensed under the BharatMLStack Business Source License 1.1.