Advanced Production-ready Elixir eXtensions
A comprehensive framework for building robust OTP applications with advanced monitoring, testing, and web interface capabilities.
- π― MetaProgramming Framework: Automatically generate REST APIs from OTP operations
- ποΈ Isolated Sandbox Management: Hot-reload capabilities with version management
- π§ͺ Distributed Testing: Comprehensive cluster testing with automatic provisioning
- π Phoenix Integration: Seamless web interface with Plug adapters
- π Advanced UI Components: Real-time monitoring dashboards with terminal aesthetics
- π§ Modular Architecture: Use individual packages or the complete framework
APEX consists of five focused packages that can be used independently or together:
Package | Description | Use Case |
---|---|---|
Arsenal | Metaprogramming framework for automatic REST API generation | Transform OTP operations into HTTP endpoints |
Sandbox | Isolated OTP application management with hot-reload | Development and testing with live code updates |
ClusterTest | Distributed test cluster management via Mix tasks | Integration testing across multiple nodes |
ArsenalPlug | Phoenix/Plug adapter for exposing Arsenal operations | Web framework integration |
ApexUI | Advanced web UI components with real-time monitoring | Production dashboards and visualizations |
def deps do
[
{:apex, "~> 0.0.1"}
]
end
def deps do
[
{:arsenal, "~> 0.0.1"}, # Core operations framework
{:arsenal_plug, "~> 0.0.1"}, # Phoenix integration
{:apex_ui, "~> 0.0.1"}, # Web UI components
{:cluster_test, "~> 0.0.1"}, # Distributed testing
{:sandbox, "~> 0.0.1"} # Hot-reload capabilities
]
end
# Start all available APEX packages
{:ok, services} = Apex.start()
# Check what's available
Apex.info()
# => %{
# apex_version: "0.0.1",
# packages: [...],
# available_count: 5
# }
# Define an operation
defmodule MyApp.Operations.GetUser do
@behaviour Arsenal.Operation
def rest_config do
%{
method: :get,
path: "/api/v1/users/:id",
summary: "Get user information",
parameters: [
%{name: "id", location: "path", type: "string", required: true}
]
}
end
def validate_params(params) do
case params["id"] do
id when is_binary(id) -> {:ok, %{id: id}}
_ -> {:error, "Invalid user ID"}
end
end
def execute(%{id: id}) do
case MyApp.Users.get_user(id) do
nil -> {:error, :user_not_found}
user -> {:ok, user}
end
end
def format_response(user) do
%{data: %{id: user.id, name: user.name, email: user.email}}
end
end
# Register and expose via HTTP
Apex.start_arsenal()
Apex.register_operation(MyApp.Operations.GetUser)
# Now available at: GET /api/v1/users/123
# In your router
defmodule MyAppWeb.Router do
use MyAppWeb, :router
# Arsenal API routes
pipeline :arsenal do
plug :accepts, ["json"]
plug ArsenalPlug
end
scope "/api/v1", MyAppWeb do
pipe_through [:api, :arsenal]
# Documentation endpoints
get "/arsenal/docs", ArsenalPlug.ArsenalController, :docs
get "/arsenal/operations", ArsenalPlug.ArsenalController, :list_operations
# Catch-all for Arsenal operations
match :*, "/*path", ArsenalPlug.ArsenalController, :operation_handler
end
end
defmodule MyAppWeb.DashboardLive do
use MyAppWeb, :live_view
def render(assigns) do
~H"""
<div class="grid grid-cols-2 gap-4 p-4">
<.live_component
module={ApexUI.Components.Widgets.ChartWidget}
id="system-metrics"
chart_type={:line}
data={@metrics_data}
title="System Performance"
real_time={true}
height={400}
/>
<.live_component
module={ApexUI.Components.Widgets.ChartWidget}
id="process-distribution"
chart_type={:pie}
data={@process_data}
title="Process Distribution"
color_scheme={:multi}
/>
</div>
"""
end
def mount(_params, _session, socket) do
if connected?(socket) do
:timer.send_interval(1000, self(), :update_metrics)
end
{:ok, assign(socket, metrics_data: [], process_data: [])}
end
end
# Start a test cluster
mix cluster_test start --size 3
# Run distributed tests
mix cluster_test run MyApp.DistributedTest
# Check cluster status
mix cluster_test status
# Stop cluster
mix cluster_test stop
# Create an isolated sandbox
{:ok, sandbox} = Apex.create_sandbox(:my_sandbox, MyApp)
# Hot-reload code without restarting
new_beam = File.read!("path/to/updated_module.beam")
Apex.hot_reload_sandbox(:my_sandbox, new_beam)
# Test in isolation
result = Sandbox.call_in_sandbox(:my_sandbox, MyModule, :my_function, [args])
Configure APEX in your config/config.exs
:
config :apex,
# Arsenal configuration
arsenal: [
auto_register: true,
openapi_version: "3.0.0"
],
# UI configuration
ui: [
theme: :terminal_green,
real_time_updates: true,
chart_defaults: %{
height: 300,
animated: true,
color_scheme: :green
}
],
# Cluster test configuration
cluster_test: [
default_cluster_size: 3,
startup_timeout: 30_000
],
# Sandbox configuration
sandbox: [
hot_reload: true,
version_management: true
]
APEX follows a modular architecture where each package focuses on a specific concern:
APEX Framework
βββ π― Arsenal (Core operations & metaprogramming)
β βββ Operation behavior definition
β βββ Registry for operation management
β βββ Automatic API documentation
βββ π ArsenalPlug (Phoenix/HTTP integration)
β βββ Dynamic request routing
β βββ Parameter validation & merging
β βββ Error handling with proper HTTP codes
βββ π ApexUI (Web interface & visualizations)
β βββ LiveView components & widgets
β βββ Real-time charts & dashboards
β βββ Terminal-themed UI system
βββ π§ͺ ClusterTest (Distributed testing)
β βββ Automated cluster provisioning
β βββ Health monitoring & diagnostics
β βββ Mix task integration
βββ ποΈ Sandbox (Hot-reload & isolation)
βββ Isolated OTP application management
βββ Module version management
βββ Hot-reload capabilities
- Arsenal README - Core operations framework
- Sandbox README - Isolated application management
- ClusterTest README - Distributed testing
- ArsenalPlug README - Phoenix integration
- ApexUI README - Advanced web UI components
Generate comprehensive API docs:
mix docs
Run the complete test suite:
# Run all tests
mix test
# Run with coverage
mix test --cover
# Run distributed tests
mix cluster_test run
Test individual packages:
cd arsenal && mix test
cd sandbox && mix test
cd cluster_test && mix test
cd arsenal_plug && mix test
cd apex_ui && mix test
- Memory Management: Use
max_data_points
in UI components to prevent memory growth - Operation Registry: Limit auto-registration in production for security
- Cluster Testing: Use dedicated test environments for distributed testing
- Sandbox Usage: Prefer sandbox for development/staging, not production hot-reload
- Arsenal Operations: Validate all inputs and implement proper authorization
- Web Interface: Use authentication middleware for sensitive operations
- Cluster Testing: Isolate test clusters from production networks
- Sandbox Management: Restrict sandbox creation in production environments
# Telemetry integration
:telemetry.attach_many(
"apex-metrics",
[
[:apex, :arsenal, :operation, :execute, :stop],
[:apex, :sandbox, :hot_reload, :stop],
[:apex, :cluster_test, :start, :stop]
],
&MyApp.MetricsHandler.handle_event/4,
[]
)
# Clone the repository
git clone https://github.com/apex-framework/apex.git
cd apex
# Install dependencies for all packages
mix deps.get
# Run tests
mix test
# Start development server
mix phx.server
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Write tests for your changes
- Ensure all tests pass (
mix test
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Follow Elixir style guide and use
mix format
- Add comprehensive documentation for new features
- Include tests for all new functionality
- Update relevant README files
- Ensure backward compatibility
- GitHub: apex-framework
- Issues: Bug Reports & Feature Requests
- Discussions: GitHub Discussions
- Discord: APEX Community
MIT License - see LICENSE for details.
- Built with β€οΈ using Elixir and Phoenix
- Inspired by OTP design principles and production-ready patterns
- Special thanks to the Elixir community for feedback and contributions
APEX Framework - Elevating your Elixir applications to production excellence.