CloudForge Dev 05ffa628c6
Some checks failed
Build and Deploy Backend (Podman) / build (push) Failing after 3m0s
Build and Deploy Backend (Podman) / deploy (push) Has been skipped
Build and Deploy Backend (Podman) / verify (push) Has been skipped
Changed to build image from local podman
2025-11-19 17:21:21 +08:00

Dashboard Backend

Real-time cryptocurrency price streaming server built with Express.js and Socket.IO

🎯 Features

  • Real-time cryptocurrency prices via WebSocket
  • CoinGecko API integration (free, no API key needed)
  • Automatic data refresh every 5 seconds
  • CORS enabled for cross-origin requests
  • Connection tracking and client count broadcasting
  • Graceful error handling
  • Automatic reconnection support

🛠 Tech Stack

  • Framework: Express.js v4.18+
  • Real-time: Socket.IO v4.5+
  • HTTP Client: Axios v1.5+
  • Environment: Dotenv v16+
  • CORS: CORS middleware v2.8+

📋 Prerequisites

  • Node.js v16.0.0 or higher
  • npm v8.0.0 or higher

🚀 Quick Start

1. Installation

npm install

2. Environment Setup

Create a .env file:

PORT=5000
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000

3. Start Development Server

npm run dev

Server will run on http://localhost:5000

4. Start Production Server

npm start

📡 WebSocket Events

Client → Server

requestData

  • Payload: { dataType: 'crypto' }
  • Description: Client requests crypto data

Server → Client

data

  • Payload: Real-time cryptocurrency data
  • Emitted: Every 5 seconds

clientCount

  • Payload: { count: number }
  • Description: Total connected clients

error

  • Payload: { message: string, details: string }
  • Description: Error occurred

📊 Data Response Format

{
  "type": "crypto",
  "timestamp": "2025-10-28T12:00:00.000Z",
  "prices": {
    "bitcoin": {
      "usd": 42500.50,
      "usd_market_cap": 850000000000,
      "usd_24h_vol": 25000000000,
      "usd_24h_change": 2.5
    },
    "ethereum": {
      "usd": 2300.75,
      "usd_market_cap": 280000000000,
      "usd_24h_vol": 15000000000,
      "usd_24h_change": 1.8
    }
  }
}

🔄 Supported Cryptocurrencies

  • Bitcoin (BTC)
  • Ethereum (ETH)
  • Cardano (ADA)
  • Solana (SOL)
  • Ripple (XRP)

🔒 Security

  • Environment variables for sensitive data
  • CORS restrictions configurable
  • Input validation on events
  • Error messages sanitized
  • No sensitive data exposed

🐛 Debugging

Enable Verbose Logging

The server logs all important events:

  • Client connections/disconnections
  • Data requests
  • API calls
  • Errors

Check console output for troubleshooting

Common Issues

Port Already in Use

# Mac/Linux
lsof -i :5000

# Windows
netstat -ano | findstr :5000

CORS Errors

API Not Responding

  • Check internet connection
  • CoinGecko API may be rate-limited
  • Server will auto-retry

📈 Performance

  • Lightweight and fast
  • Handles multiple concurrent connections
  • Efficient data updates (5-second intervals)
  • Minimal bandwidth usage

🚀 Deployment Ready

Tested and ready for deployment on:

  • Railway.app
  • Render.com
  • Heroku
  • DigitalOcean
  • AWS

📝 API Health Check

curl http://localhost:5000/health

Response:

{
  "status": "OK",
  "message": "Server is running",
  "timestamp": "2025-10-28T12:00:00.000Z"
}

📄 License

ISC

👤 Author

CloudForge Dev Team


Status: Production Ready Last Updated: 2025-10-28

Description
Real-time cryptocurrency price streaming server
Readme 76 KiB
Languages
JavaScript 100%