Real-time cryptocurrency arbitrage detection system across multiple Iranian exchanges
Stream-Coin is a high-performance, asynchronous cryptocurrency market data aggregator built with Rust. It connects to multiple Iranian cryptocurrency exchanges, streams real-time price data into Kafka, and enables instant arbitrage opportunity detection through stream processing.
Stream-Coin solves the challenge of identifying price discrepancies across multiple cryptocurrency exchanges in real-time. By leveraging event streaming and async processing, the system can detect arbitrage opportunities within milliseconds.
- Asynchronous Architecture: Built on Tokio for non-blocking, concurrent operations
- Multi-Exchange Support: Integrates with 8+ Iranian cryptocurrency exchanges
- Real-time Streaming: Kafka-based event streaming for low-latency data processing
- Persistent Storage: MySQL database with SeaORM for reliable data persistence
- High-Performance Caching: Redis integration for fast data access
- Clean Architecture: Domain-driven design with clear separation of concerns
- API-First Design: RESTful API with Actix-web and comprehensive Swagger documentation
┌─────────────────┐
│ Exchanges │
│ (WebSocket/ │
│ REST APIs) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Stream-Coin │
│ (Rust App) │
│ │
│ ┌───────────┐ │
│ │ Actix │ │ ◄── REST API
│ │ Web │ │
│ └───────────┘ │
│ │
│ ┌───────────┐ │
│ │ Tokio │ │ ◄── Async Runtime
│ │ Runtime │ │
│ └───────────┘ │
└────────┬────────┘
│
├──────────────┐
▼ ▼
┌─────────────┐ ┌─────────────┐
│ Kafka │ │ Redis │
│ (Streams) │ │ (Cache) │
└─────────────┘ └─────────────┘
│
▼
┌─────────────────┐
│ MySQL │
│ (SeaORM) │
└─────────────────┘
| Component | Technology |
|---|---|
| Language | Rust 🦀 |
| Async Runtime | Tokio |
| Web Framework | Actix-web |
| Message Broker | Apache Kafka |
| Cache | Redis |
| Database | MySQL |
| ORM | SeaORM |
| Container Runtime | Docker / Nerdctl |
-
Clone the repository
git clone https://github.com/yourusername/stream-coin.git cd stream-coin -
Set up infrastructure
Using Docker:
sudo docker compose up -d
Using Nerdctl (containerd):
sudo nerdctl compose -f ./docker-compose.yml up -d
-
Configure environment
cp .env.example .env # Edit .env with your configuration -
Run database migrations
cargo run --bin migrate
-
Start the application
cargo run --bin stream-coin
Once the application is running, access the interactive API documentation:
- Swagger UI: http://localhost:8080/swagger-ui/
- Kafka UI: http://localhost:8083/ui/
- Redis Insight: http://localhost:8082/
Enable debug logging in your code:
use log::debug;
debug!("Payload: {}", payload);Run with RUST_LOG environment variable:
RUST_LOG=debug cargo run --bin stream-coinStream-Coin currently integrates with the following Iranian cryptocurrency exchanges:
| Exchange | API Documentation | Status |
|---|---|---|
| Wallex | docs | ✅ Active |
| Bitpin | docs | ✅ Active |
| Aban Tether | docs | ✅ Active |
| Ramzinex | docs | ✅ Active |
| Exir | docs | ✅ Active |
| Nobitex | docs | ✅ Active |
| Tetherland | docs | ✅ Active |
| Tabdeal | docs | ✅ Active |
| Bit24 | docs | ✅ Active |
stream-coin/
├── src/
│ ├── api/ # API layer (Actix-web routes & handlers)
│ ├── application/ # Application services & use cases
│ ├── domain/ # Domain models & business logic
│ ├── infrastructure/ # External integrations (Kafka, Redis, DB)
│ ├── exchanges/ # Exchange-specific implementations
│ └── main.rs # Application entry point
├── migrations/ # Database migrations
├── docker-compose.yml # Infrastructure setup
├── Cargo.toml # Rust dependencies
└── README.md
- Domain Layer: Core business logic and entities
- Application Layer: Use cases and application-specific business rules
- Infrastructure Layer: External concerns (database, message brokers, APIs)
- API Layer: HTTP interface and presentation logic
# Run all tests
cargo test
# Run specific test suite
cargo test --test integration_tests
# Run with output
cargo test -- --nocapture# Format code
cargo fmt
# Run linter
cargo clippy
# Check for issues
cargo check# Optimized release build
cargo build --release
# Run release binary
./target/release/stream-coin- Update readme
- Create output variable standardization
- Fix Redis Insight configuration
- Add Postman API collection
- Complete Swagger documentation for all endpoints
- WebSocket support for real-time client updates
- Machine learning-based opportunity prediction
- Multi-region deployment support
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Rust naming conventions
- Write comprehensive tests
- Document public APIs
- Keep functions focused and small
- Use meaningful variable names
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.