CryptaLearn Node is a high-performance Elixir backend that orchestrates privacy-preserving federated learning across distributed OCaml clients. Built as the central coordination hub for the CryptaLearn library, it provides secure model aggregation, differential privacy budget management, and fault-tolerant federated training coordination.
- Elixir 1.15+ and Erlang/OTP 26+
- PostgreSQL 15+
# Install dependencies
mix deps.get
# Setup database
mix ecto.setup
# Set up environment variables (recommended for development)
# Create a .env file with the following variables:
# export DEV_DB_USERNAME=your_username
# export DEV_DB_PASSWORD=your_password
# export DEV_SECRET_KEY_BASE=$(mix phx.gen.secret)
# export TEST_DB_USERNAME=your_username
# export TEST_DB_PASSWORD=your_password
# export TEST_SECRET_KEY_BASE=$(mix phx.gen.secret)
# Start the server
mix phx.serverFor security best practices, sensitive information such as database credentials and secret keys are loaded from environment variables. To set up your local environment:
-
Copy the example configuration files:
cp config/dev.exs.example config/dev.exs cp config/test.exs.example config/test.exs
-
Create a
.envfile in the project root (this file is git-ignored):# Development environment export DEV_DB_USERNAME=postgres export DEV_DB_PASSWORD=your_password export DEV_SECRET_KEY_BASE=$(mix phx.gen.secret) # Test environment export TEST_DB_USERNAME=postgres export TEST_DB_PASSWORD=your_password export TEST_SECRET_KEY_BASE=$(mix phx.gen.secret)
-
Source the environment variables before starting the server:
source .env mix phx.server
Visit localhost:4000/api/v1/health to verify installation.
# Register a node
curl -X POST http://localhost:4000/api/v1/nodes/register \
-H "Content-Type: application/json" \
-d '{"node_id": "test-node", "capabilities": ["fl", "dp"]}'
# List active nodes
curl http://localhost:4000/api/v1/nodes
# Send heartbeat
curl -X POST http://localhost:4000/api/v1/nodes/test-node/heartbeat
# Get node status
curl http://localhost:4000/api/v1/nodes/test-node/status
# Health check
curl http://localhost:4000/api/v1/health# Run all tests
mix test
# Run with coverage
mix test --coverVisit localhost:4000/dev/dashboard for real-time system metrics and monitoring.
- Node Registration & Management - Secure client session handling
- Session Tracking - Heartbeat monitoring and automatic cleanup
- RESTful API - Complete HTTP endpoints with error handling
- Database Foundation - PostgreSQL schemas for nodes, rounds, models
- Health Monitoring - System health checks and observability
- Process Supervision - Fault-tolerant OTP architecture
- Testing Framework - Unit and integration tests
- JWT Authentication - Secure API endpoints
- Training Rounds - Federated learning coordination
- OCaml Integration - Bridge to CryptaLearn library
- Privacy Management - Differential privacy budget tracking
# Database commands
mix ecto.create # Create database
mix ecto.migrate # Run migrations
mix ecto.reset # Reset database
# Server commands
mix phx.server # Start server
iex -S mix phx.server # Start with interactive shell
mix format # Format codeTo start your Phoenix server:
- Run
mix setupto install and setup dependencies - Start Phoenix endpoint with
mix phx.serveror inside IEx withiex -S mix phx.server
Now you can visit localhost:4000 from your browser.
Ready to run in production? Please check our deployment guides.
- Official website: https://www.phoenixframework.org/
- Guides: https://hexdocs.pm/phoenix/overview.html
- Docs: https://hexdocs.pm/phoenix
- Forum: https://elixirforum.com/c/phoenix-forum
- Source: https://github.com/phoenixframework/phoenix