Skip to content

Youssef-joe/Ayno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polyglot Realtime Engine

A multi-tenant realtime platform built with Elixir Phoenix, supporting WebSocket and HTTP APIs for chat, trading, gaming, and any realtime application.

npm version

Architecture

  • Elixir Gateway: Phoenix WebSocket/HTTP server with multi-tenant channels
  • Go Processor: Event processing and analytics (HTTP on port 8080)
  • C++ Driver: Ultra-low latency processing (optional)
  • Storage: Postgres for tenant/API/user records, Redis for sessions/ephemeral state, optional ClickHouse analytics sink in Go processor

Quick Start

Using Docker (Recommended)

docker-compose up --build

This starts:

  • Nginx load balancer on http://localhost
  • Elixir server on localhost:4000 (internal)
  • Go processor on localhost:8080 (internal)
  • PostgreSQL on localhost:5432 (internal)
  • Redis on localhost:6379 (internal)

Scaling

Scale services with Docker Compose:

# Scale Elixir servers
docker-compose up --scale polyglot=3

# Scale Go processors
docker-compose up --scale go-processor=2

The load balancer automatically distributes traffic.

Manual Setup

  1. Build components:
make all  # or manually: cd go_processor && go build -o processor .
  1. Start services:
# Terminal 1: Go Processor
cd go_processor && ./processor

# Terminal 2: Elixir Gateway
mix deps.get
mix ecto.setup
mix phx.server
  1. Test:
# Health check
curl http://localhost:4000/health

# Publish event
curl -X POST http://localhost:4000/apps/demo-app/channels/room:test/publish \
  -H "Content-Type: application/json" \
  -H "X-API-Key: demo-app-local-key" \
  -d '{"type": "message", "data": {"text": "Hello World"}}'

# Get history
curl http://localhost:4000/apps/demo-app/channels/room:test/history

API

WebSocket

import { Socket } from "phoenix";

const socket = new Socket("ws://localhost:4000/socket", {
  params: { app_id: "your-app", token: "valid_token_user123" }
});

socket.connect();

const channel = socket.channel("room:lobby", {});
channel.join();
channel.on("event", (event) => console.log(event));

HTTP

# Publish
curl -X POST /apps/{app_id}/channels/{channel}/publish \
  -H "X-API-Key: <postgres-backed-api-key>" \
  -d '{"type": "message", "data": {"text": "Hello"}}'

# History
curl /apps/{app_id}/channels/{channel}/history

Client SDKs

Examples

See examples/ directory for client implementations in HTML/JavaScript and Python.

Testing

Run benchmarks:

mix run benchmarks/benchmark.exs

Run tests:

mix test

Development

  • Elixir 1.17+
  • Go 1.21+
  • PostgreSQL
  • Redis
  • ClickHouse (optional, when ANALYTICS_BACKEND=clickhouse)

License

MIT

About

The open-source Pusher alternative built for high-performance workloads

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors