guicybercode/potential-adventure
A high-performance real-time data processing pipeline combining Elixir, Rust, and Zig for processing financial trading data from Kafka with full obser...
A high-performance real-time data processing pipeline combining Elixir, Rust, and Zig for processing financial trading data from Kafka with full observability and fault tolerance.
π New here? Check the Quick Start Guide for the easiest way to get started!
βββββββββββ
β Kafka βββββ
βββββββββββ β
βΌ
βββββββββββββββββββ
β Broadway (Elixir)β
β Kafka Consumer β
ββββββββββ¬βββββββββββ
β
ββββββββββ΄βββββββββββ
β β
βΌ βΌ
βββββββββββ βββββββββββ
β Zig NIF β βRust NIF β
β Parser β βAggregateβ
βββββββββββ βββββββββββ
β β
ββββββββββ¬βββββββββββ
βΌ
βββββββββββββββββββ
β Phoenix API β
β LiveView UI β
βββββββββββββββββββ
β
ββββββββββ΄βββββββββββ
β β
βΌ βΌ
βββββββββββ βββββββββββ
βPrometheusβ β Grafana β
βββββββββββ βββββββββββ
# Start everything (Docker + Phoenix)
./start.sh
# Check status of all services
./status.sh
# Stop everything
./stop.sh
docker-compose up -d
This will start:
mix deps.get
cd native/rust_processor && cargo build --release
docker-compose up -d kafka zookeeper
docker exec -it kafka kafka-topics --create --topic trades --bootstrap-server localhost:9092
docker exec -it kafka kafka-topics --create --topic orders --bootstrap-server localhost:9092
mix phx.server
python generator.py
elixir_rust_zig/
βββ apps/
β βββ realtime_processor/ # Phoenix + Broadway app
β βββ lib/
β β βββ realtime_processor/
β β β βββ pipeline/ # Broadway pipeline
β β β βββ metrics.ex # Telemetry metrics
β β β βββ rust_processor.ex
β β β βββ zig_nifs.ex
β β βββ realtime_processor_web/
β β βββ controllers/
β β βββ live/
β βββ mix.exs
βββ native/
β βββ rust_processor/ # Rust aggregation/anomaly detection
β β βββ src/
β β β βββ lib.rs
β β β βββ aggregation.rs
β β β βββ anomaly.rs
β β βββ Cargo.toml
β βββ zig_nifs/ # Zig binary parsing
β βββ src/
β β βββ nif.zig
β β βββ parser.zig
β β βββ checksum.zig
β βββ build.zig
βββ benchmark/ # Performance benchmarks
βββ docker-compose.yml
βββ Dockerfile
βββ .github/workflows/ci.yml
βββ .gitlab-ci.yml
Returns Prometheus metrics in text format.
Returns OHLC aggregations for a given symbol.
Example:
curl http://localhost:4000/api/aggregations/BTCUSD
Returns detected anomalies for a given symbol.
Example:
curl http://localhost:4000/api/anomalies/BTCUSD
{
"symbol": "BTCUSD",
"price": 45000.50,
"quantity": 0.25,
"timestamp": 1699632000000,
"side": "buy"
}
FIX protocol messages use SOH (0x01) as field delimiter:
8=FIX.4.2<SOH>9=178<SOH>35=D<SOH>...
Run benchmarks:
mix run benchmark/run_benchmarks.exs
Results are saved to benchmark/results.md.
realtime_processor_messages_total - Total messages processedrealtime_processor_anomalies_total - Total anomalies detectedrealtime_processor_batch_duration_microseconds - Batch processing latencyrealtime_processor_message_duration_microseconds - Per-message latencyAccess at http://localhost:3000 (admin/admin)
Structured JSON logging configured via logger_json.
mix test
cd native/rust_processor && cargo test
mix format
cd native/rust_processor && cargo fmt
cd native/zig_nifs && zig fmt .
mix credo
Automated testing, formatting checks, and benchmarks on push/PR.
Similar pipeline with Docker image building for main/master branches.
Ensure Rust and Zig toolchains are properly installed:
rustc --version
zig version
Verify Kafka is running:
docker-compose ps
docker logs kafka
Modify ports in docker-compose.yml if 4000, 9092, 9090, or 3000 are in use.
MIT
"λν¬λ λ΄κ° λν¬μκ² λͺ λ Ήν λͺ¨λ κ²μ μ§μΌ ννλΌ. κ·Έκ²μ λνκ±°λ λΉΌμ§ λ§λΌ." (μ λͺ κΈ° 12:32)