Skip to content

Latest commit

 

History

History
276 lines (228 loc) · 7.44 KB

File metadata and controls

276 lines (228 loc) · 7.44 KB

Tesla Trading & Mining Investment Broker 🚀

A professional full-stack web application for cryptocurrency trading, mining operations management, and investment brokerage with Tesla-inspired design.

✨ Features

🎯 Core Features

  • Real-time Trading Dashboard - Live market data with WebSocket updates
  • Mining Operations Monitor - Track mining rigs, hashrate, and earnings in real-time
  • Smart Wallet Management - Secure deposit, withdraw, and asset management
  • Portfolio Tracking - Real-time position tracking and P&L calculations
  • Advanced Order Management - Market, limit, stop-loss orders with execution
  • Analytics & Reports - Customizable performance and tax reports
  • User Authentication - Secure login with JWT and MFA support

🎨 Design

  • Tesla-Inspired UI - Minimalist, dark mode aesthetic
  • Responsive Design - Works seamlessly on desktop, tablet, mobile
  • Real-time Updates - WebSocket-based live data streaming
  • Professional Charts - Interactive candlestick and technical analysis

🔒 Security

  • JWT authentication with refresh tokens
  • Password hashing with bcrypt
  • CORS protection
  • Input validation and sanitization
  • Rate limiting on API endpoints
  • Environment-based configuration

🛠 Technology Stack

Backend

  • Runtime: Node.js (ES Modules)
  • Framework: Express.js
  • Database: PostgreSQL
  • Cache: Redis
  • Real-time: Socket.io
  • Authentication: JWT + bcryptjs

Frontend

  • Framework: React 18 + TypeScript
  • Build: Vite
  • Styling: Tailwind CSS + Dark Mode
  • State Management: Redux Toolkit
  • Charts: Recharts / Chart.js
  • Real-time: Socket.io Client

📁 Project Structure

.
├── server.js                      # Main server entry point
├── middleware/
│   ├── auth.js                   # JWT authentication middleware
│   └── errorHandler.js           # Global error handling
├── routes/
│   ├── auth.js                   # Authentication endpoints
│   ├── trading.js                # Trading endpoints
│   ├── mining.js                 # Mining operations endpoints
│   ├── wallet.js                 # Wallet management
│   ├── portfolio.js              # Portfolio endpoints
│   └── analytics.js              # Analytics endpoints
├── controllers/
│   ├── authController.js
│   ├── tradingController.js
│   ├── miningController.js
│   ├── walletController.js
│   ├── portfolioController.js
│   └── analyticsController.js
├── models/
│   ├── User.js
│   ├── Order.js
│   ├── MiningRig.js
│   ├── Wallet.js
│   └── Transaction.js
├── services/
│   ├── marketService.js
│   ├── miningService.js
│   ├── walletService.js
│   └── notificationService.js
├── config/
│   ├── database.js
│   └── redis.js
├── utils/
│   ├── validators.js
│   ├── helpers.js
│   └── logger.js
└── client/
    ├── src/
    │   ├── components/
    │   │   ├── Dashboard/
    │   │   ├── Trading/
    │   │   ├── Mining/
    │   │   ├── Wallet/
    │   │   ├── Portfolio/
    │   │   └── Charts/
    │   ├── pages/
    │   │   ├── Home.tsx
    │   │   ├── Trading.tsx
    │   │   ├── Mining.tsx
    │   │   ├── Portfolio.tsx
    │   │   └── Settings.tsx
    │   ├── store/
    │   │   ├── slices/
    │   │   └── hooks/
    │   ├── hooks/
    │   │   ├── useWebSocket.ts
    │   │   ├── useAuth.ts
    │   │   └── useMarketData.ts
    │   ├── services/
    │   │   ├── api.ts
    │   │   ├── websocket.ts
    │   │   └── auth.ts
    │   ├── styles/
    │   │   ├── globals.css
    │   │   └── tailwind.css
    │   └── App.tsx
    └── public/

🚀 Getting Started

Prerequisites

  • Node.js 16+
  • PostgreSQL 12+
  • Redis 6+
  • npm or yarn

Installation

  1. Clone the repository:
git clone https://github.com/timalen99-commits/solid-octo-goggles
cd solid-octo-goggles
  1. Install dependencies:
npm install
cd client && npm install && cd ..
  1. Create .env file:
cp .env.example .env
  1. Configure environment variables in .env

  2. Setup database:

psql -U postgres -f scripts/init.sql
  1. Start development servers:
npm run dev

📡 API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • POST /api/auth/refresh - Refresh JWT token
  • POST /api/auth/logout - Logout user
  • GET /api/auth/verify - Verify token

Trading

  • GET /api/trading/markets - Get live market data
  • POST /api/trading/orders - Create new order
  • GET /api/trading/orders - Get user orders
  • DELETE /api/trading/orders/:id - Cancel order
  • GET /api/trading/history - Trading history

Mining

  • GET /api/mining/rigs - Get mining rigs
  • POST /api/mining/rigs - Add mining rig
  • GET /api/mining/earnings - Mining earnings
  • PUT /api/mining/rigs/:id - Update rig settings
  • DELETE /api/mining/rigs/:id - Remove rig

Wallet

  • GET /api/wallet/balance - Get wallet balance
  • POST /api/wallet/deposit - Deposit funds
  • POST /api/wallet/withdraw - Withdraw funds
  • GET /api/wallet/transactions - Transaction history
  • GET /api/wallet/addresses - Get deposit addresses

Portfolio

  • GET /api/portfolio/summary - Portfolio summary
  • GET /api/portfolio/holdings - Current holdings
  • GET /api/portfolio/performance - Performance metrics
  • GET /api/portfolio/allocation - Asset allocation

Analytics

  • GET /api/analytics/reports - Generate reports
  • GET /api/analytics/statistics - Performance statistics
  • GET /api/analytics/tax-report - Tax report generation

🔄 WebSocket Events

Subscribe:

  • subscribe_market - Market data updates
  • subscribe_portfolio - Portfolio changes
  • subscribe_mining - Mining status updates

Listen:

  • market_update - Price and volume updates
  • portfolio_update - Position and balance changes
  • mining_update - Rig status and earnings updates
  • order_filled - Order execution notifications

🧪 Development

Running Tests

npm test

Code Linting

npm run lint

Building for Production

npm run build
npm start

📚 Database Setup

The database includes tables for:

  • Users (authentication & profiles)
  • Orders (trading history)
  • Mining Rigs (rig configurations & status)
  • Wallets (user balances & addresses)
  • Transactions (deposits, withdrawals, trades)
  • Portfolio Snapshots (historical data)

🤝 Contributing

  1. Create a feature branch:
git checkout -b feature/amazing-feature
  1. Commit your changes:
git commit -m 'Add amazing feature'
  1. Push to branch:
git push origin feature/amazing-feature
  1. Open a Pull Request

📝 License

MIT License - see LICENSE file for details

📧 Support

For issues and questions, please create an issue in the GitHub repository.


Built with ❤️ by timalen99-commits

Professional trading & mining platform inspired by Tesla's minimalist design philosophy