PRA Nexus is a complete, production-grade ecosystem for the PRA token exchange platform. It integrates everything from smart contracts to backend services, databases, APIs, monitoring, logging, and CI/CD pipelines into a single, unified system.
This is not a toy project. PRA Nexus demonstrates enterprise-level blockchain engineering, including:
- 🔗 Smart Contracts – ERC-20 token + Escrow for atomic swaps
- 🚀 Go Backend – Modular, concurrent, production-ready
- 📡 Real-time Events – WebSocket listener with goroutines
- 🗄️ Persistent Storage – PostgreSQL with GORM
- 📊 REST API – Fully documented with Swagger
- 🤖 Telegram Notifications – Real-time alerts
- 🐳 Containerized Deployment – Docker & Docker Compose
- ⚙️ CI/CD Pipeline – GitHub Actions (test, build, deploy)
- 📈 Monitoring – Prometheus + Grafana (3 dashboards)
- 📜 Centralized Logging – ELK Stack (5 dashboards)
- 📦 One-Command Setup – Makefile for everything
┌─────────────────────────────────────────────────────────────────────────────┐ │ PRA NEXUS │ ├─────────────────────────────────────────────────────────────────────────────┤ │ │ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ │ │ Smart Contract │ │ Go Backend │ │ PostgreSQL │ │ │ │ ┌───────────┐ │ │ ┌───────────┐ │ │ ┌───────────┐ │ │ │ │ │PRA Token │ │ │ │Converter │ │ │ │ Trades │ │ │ │ │ │ (ERC20) │ │ │ │Wallet Mgr │ │ │ │ Transfers │ │ │ │ │ └───────────┘ │ │ │Trading Svc│ │ │ │ Notifs │ │ │ │ │ ┌───────────┐ │ │ └───────────┘ │ │ └───────────┘ │ │ │ │ │ Escrow │ │ └─────────────────┘ └─────────────────┘ │ │ │ │(Atomic) │ │ │ │ │ │ │ └───────────┘ │ ┌─────────────────┐ ┌─────────────────┐ │ │ └─────────────────┘ │ REST API │ │ Telegram Bot │ │ │ │ │ (Gin/Swagger) │ │ Notifications │ │ │ ▼ └─────────────────┘ └─────────────────┘ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ Blockchain (Ethereum/L2) │ │ │ │ WebSocket Listener · Event Handler · goroutines │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ ├─────────────────────────────────────────────────────────────────────────────┤ │ MONITORING & LOGGING │ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ │ │ Prometheus │ │ Grafana │ │ ELK Stack │ │ │ │ Metrics │◄───│ ├─System │ │ ├─Elasticsearch│ │ │ │ Alerts │ │ ├─Security │ │ ├─Logstash │ │ │ └─────────────────┘ │ └─Blockchain │ │ └─Kibana │ │ │ └─────────────────┘ └─────────────────┘ │ │ │ ├─────────────────────────────────────────────────────────────────────────────┤ │ DEPLOYMENT & CI/CD │ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ │ │ Docker │ │ Docker Compose │ │ GitHub Actions │ │ │ │ Container │ │ Multi-Service │ │ ├─Test & Lint │ │ │ └─────────────────┘ └─────────────────┘ │ ├─Build Image │ │ │ │ └─Deploy to VPS│ │ │ └─────────────────┘ │ └─────────────────────────────────────────────────────────────────────────────┘
| Contract | Description |
|---|---|
| PRAToken | ERC-20 token with mint/burn, Ownable |
| PRAEscrow | Atomic swap escrow for PRA/IRR trades |
| Module | Description |
|---|---|
| Converter | IRR ↔ PRA conversion logic |
| WalletManager | Blockchain connection, transfers, balance checks |
| TradingService | BuyPRA / SellPRA workflows |
- WebSocket connection to blockchain (geth)
- Goroutine-based event listener
- Handlers for:
TradeCreated,PaymentConfirmed,TradeCompleted,TokenTransfer
- Trades table (pending, paid, completed, cancelled)
- TransferEvents table (all PRA transfers)
- Notifications table (audit log)
- GORM for ORM
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| GET | /api/trades |
List all trades |
| GET | /api/trades/:id |
Get trade by ID |
| GET | /api/transfers/:address |
Get transfers by address |
| GET | /api/stats |
Platform statistics |
| POST | /api/trade |
Create new trade |
- Automatic alerts for: new trades, payments, completions, cancellations
- Configurable bot token and chat ID
- Dockerfile for Go backend (multi-stage, optimized)
- Docker Compose for all services (API, DB, Redis, PgAdmin)
- Environment variables via
.env
- Runs on
pushtomain/develop - Steps: Lint → Test → Build Docker image → Push to registry → Deploy to VPS
- Security scan with Trivy
- Telegram notification on pipeline status
| Dashboard | Metrics |
|---|---|
| System | CPU, Memory, Disk, API response time, TPS |
| Security | Failed requests, suspicious IPs, rate limiting, invalid signatures |
| Blockchain | Latest block, mempool size, peer count, gas price, reorgs |
| Component | Role |
|---|---|
| Filebeat | Collect logs from Docker containers |
| Logstash | Parse, filter, enrich log lines |
| Elasticsearch | Store and index logs |
| Kibana | 5 dashboards: Main, Errors, Trades, Blockchain, Security |
🚀 Quick Start Prerequisites Go 1.21+
Docker & Docker Compose
PostgreSQL (or use Docker)
Node.js (for frontend, optional)
📂 Project Structure pra-nexus/ ├── smart-contracts/ │ ├── PRAToken.sol │ └── PRAEscrow.sol ├── backend-go/ │ ├── main.go │ ├── config/ │ ├── service/ │ ├── listener/ │ ├── database/ │ └── api/ ├── monitoring/ │ ├── prometheus/ │ ├── grafana/ │ │ └── dashboards/ │ └── docker-compose.monitoring.yml ├── logging/ │ ├── elasticsearch/ │ ├── logstash/ │ ├── kibana/ │ ├── filebeat/ │ └── docker-compose.elk.yml ├── deployment/ │ ├── Dockerfile │ ├── docker-compose.yml │ └── .env.example ├── .github/ │ └── workflows/ │ └── deploy.yml ├── Makefile ├── go.mod └── README.md
📈 Monitoring Dashboards Grafana (http://localhost:3000) Login: admin / admin123
Dashboards:
PRA Exchange - System Monitoring PRA Exchange - Security & Threats PRA Exchange - Blockchain Node
Prometheus (http://localhost:9090) Query examples: up{job="pra-backend"} rate(pra_transactions_processed_total[5m]) pra_p2p_peers
Alerts (via Telegram)
API down High CPU / memory / disk Database down Slow transaction rate High trade failure rate Blockchain disconnected
📜 Logging with ELK Stack Kibana (http://localhost:5601) Login: elastic / changeme Index Pattern: pra-logs-* Dashboards (5): PRA Exchange - Main Dashboard Error Analysis Trade Monitoring Blockchain Node Security Monitoring
Sample Log Queries
log_level: "ERROR" AND service_name: "pra*"
message: "Trade*" AND @timestamp > now-1h
message: "invalid signature" OR message: "rate limit"
⚙️ CI/CD Pipeline (GitHub Actions)
jobs: test: # Lint + Test + Race build: # Build Docker image security: # Trivy vulnerability scan deploy: # SSH to VPS and deploy notify: # Telegram status update Secrets required:
DOCKER_USERNAME, DOCKER_PASSWORD VPS_HOST, VPS_USER, VPS_SSH_KEY TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID
🛡️ Security Features Layer Protection Smart Contracts ReentrancyGuard, Ownable, pull payment pattern Go Backend Environment variables, no hardcoded secrets API Input validation, rate limiting (optional) Database Parameterized queries (GORM) Network Docker internal networks, no exposed DB ports Monitoring Alert on suspicious patterns (invalid sigs, rate limit hits) Logging Centralized, tamper-proof (Elasticsearch)
📊 Performance Benchmarks Operation Average Time Transaction validation < 10ms Mempool insertion < 5ms API response (cached) < 15ms Block propagation < 50ms to 10 peers Kibana search (1 day) < 200ms
🔗 Related Projects Project Description HashCore Blockchain simulator on Remix RPCraft Ethereum RPC client PeerForge P2P node with libp2p MempoolForge Mempool + transaction propagation PRA Nexus Complete production ecosystem (this project)
🤝 Contributing Contributions are welcome!
Fork the repository Create a feature branch (git checkout -b feature/amazing) Commit your changes (git commit -m 'Add amazing feature') Push to the branch (git push origin feature/amazing) Open a Pull Request Guidelines: Run make test before committing Follow Go and Solidity best practices Update documentation for any new feature
📄 License This project is licensed under the MIT License - see the LICENSE file for details.
👨💻 Author Parsa Abolhasani Rad – Senior Blockchain Engineer
🔗 www.linkedin.com/in/parsa-abolhasani-rad- 💻 https://github.com/ParsaAbolhasani ✉️ parsaabolhasani9@gmail.com
⭐ Show Your Support If you find PRA Nexus useful for your learning or projects, please give it a ⭐ on GitHub! It helps others discover this work and motivates further development.
📌 Disclaimer This project is for educational and portfolio purposes. While it follows production-grade patterns, it requires additional security audits before use in financial systems handling real value.
Built with ❤️ and ☕ by Parsa Abolhasani Rad — What initially seemed like a small, simple task that an employer hesitated to fund became a complete, production-grade ecosystem, built from zero in less than 15 days, just to prove what dedication and passion can achieve. Thank you for your attention to this work