π DigitalFortune - Crypto Trading Platform# π DigitalFortune - Crypto Trading Platform# π DigitalFortune - Real-Time Crypto Trading Platform
git clone https://github.com/abdulbaqui17/DigitalFortune.git
cd DigitalFortune
docker-compose up -d --build
Full-stack real-time cryptocurrency trading platform built with React, TypeScript, and microservices****Full-stack cryptocurrency trading platform with real-time features and microservices architecture
Visit http://localhost β New users get $5,000 demo balance!
Frontend
-
React 19 + TypeScript------
-
Vite (build tool)
-
Tailwind CSS (styling)
-
Framer Motion (animations)
-
Zustand (state management)## β‘ Quick Start## β‘ Quick Start
Backend
-
Node.js + Express.js
-
TypeScript
bashbash -
WebSocket (real-time data)
-
JWT + bcrypt (auth)git clone https://github.com/abdulbaqui17/DigitalFortune.gitgit clone https://github.com/abdulbaqui17/DigitalFortune.git
Databasecd DigitalFortunecd DigitalFortune
-
PostgreSQL (users, orders, positions)
-
Redis (sessions, cache)docker-compose up -d --builddocker-compose up -d --build
DevOps``````
-
Docker + Docker Compose
-
Nginx (reverse proxy)
---Open http://localhost β Sign up β Get $5,000 demo balance β Start trading!Open http://localhost - Every new user gets $5,000 demo balance!
Trading Platform------
-
Real-time candlestick charts (1m to 1D)
-
Market/limit/stop-loss/take-profit orders
-
Up to 100x leverage trading
-
Live P&L tracking## β¨ Features## β¨ Key Features
-
Automated liquidation engine
-
Position management
Security & Auth****Trading### Trading
-
JWT token authentication
-
bcrypt password encryption- Real-time candlestick charts (1m to 1D timeframes)- Real-time candlestick charts with multiple timeframes
-
Protected API routes
-
User-isolated trading accounts- Market, limit, stop-loss, take-profit orders- Market, limit, stop-loss, and take-profit orders
UI/UX- Up to 100x leverage with margin tracking- Up to 100x leverage trading
-
Animated landing page (20+ floating particles)
-
3D effects with parallax scrolling- Live P&L and position management- Live P&L tracking and position management
-
Responsive mobile design
-
Real-time balance updates- Automated liquidation system- Automated liquidation engine
React Client (Nginx)
β- WebSocket real-time data streaming- WebSocket real-time data streaming
HTTP API + WebSocket + Poller
β- Microservices architecture (6 containers)- Microservices architecture (HTTP, WS, Poller services)
PostgreSQL + Redis
```- PostgreSQL + Redis persistence- PostgreSQL + Redis for data persistence
**6 Docker Containers:**- Framer Motion landing page animations- Framer Motion animations on landing page
1. **Client** - React SPA
2. **HTTP Server** - REST API, auth, orders- Responsive design with Tailwind CSS
3. **WebSocket** - Real-time price streaming
4. **Poller** - Market data aggregation
5. **PostgreSQL** - Persistent storage
6. **Redis** - Session cache---
------
## π Structure## π οΈ Tech Stack
```## π οΈ Tech Stack
DigitalFortune/
βββ client/ # React + TypeScript frontend**Frontend:** React 19, TypeScript, Vite, Tailwind CSS, Framer Motion, Zustand
βββ httpserver/ # Express.js API
βββ wsserver/ # WebSocket server**Backend:** Node.js, Express.js, TypeScript, WebSocket **Frontend:** React 19, TypeScript, Vite, Tailwind CSS, Framer Motion, Zustand
βββ poller/ # Market data service
βββ db/ # PostgreSQL schemas**Database:** PostgreSQL, Redis **Backend:** Node.js, Express.js, TypeScript, WebSocket
βββ docker-compose.yml
```**DevOps:** Docker, Docker Compose, Nginx**Database:** PostgreSQL, Redis
---**DevOps:** Docker, Docker Compose, Nginx
## π§ Development---
```bash## οΏ½οΈ Architecture
# Start services
docker-compose up -d## ποΈ Architecture
# View logsMicroservices setup with 6 Docker containers:
docker-compose logs -f
```- **Client** - React SPA with Nginx
# Stop services
docker-compose downβββββββββββββββ- **HTTP Server** - REST API, auth, orders (Express.js)
β React SPA β (Nginx :80)- WebSocket Server - Real-time data streaming
ββββββββ¬βββββββ- Poller - Market data aggregation
β- **PostgreSQL** - User accounts, orders, positions
Abdul Baqui
GitHub: @abdulbaqui17 βββββ΄βββββββββββββ¬ββββββββββββββ- Redis - Session cache
--- β β β
Built with React, TypeScript, Docker & PostgreSQLβ HTTP API β β WebSocketβ β Poller β
β Star this repo if you find it useful!β :3001 β β :3002 β β (Background)β```bash
β β βdocker-compose up -d
βββββββββββ¬ββββ΄βββββββββββββββ
β# View logs
ββββββββ΄βββββββdocker-compose logs -f httpserver
β β
ββββββΌβββββ ββββββΌβββββ# Stop services
βPostgreSQLβ β Redis βdocker-compose down
β :5432 β β :6379 β```
βββββββββββ βββββββββββ
**Services:**## π Project Structure
- **Client** - React SPA with landing page + trading dashboard
- **HTTP Server** - REST API, auth, order management, risk engine```
- **WebSocket Server** - Real-time price updates and trade eventsDigitalFortune/
- **Poller** - Market data aggregation and candle generationβββ client/ # React Frontend
- **PostgreSQL** - User accounts, orders, positionsβ βββ src/
- **Redis** - Session storage and cachingβ β βββ components/ # Reusable components
β β β βββ landing/ # Landing page components
---β β β β βββ LandingNavbar.tsx
β β β β βββ HeroSection.tsx (with animations)
## π Project Structureβ β β β βββ FeaturesSection.tsx
β β β β βββ DashboardPreview.tsx (3D effects)
```β β β β βββ LandingFooter.tsx
DigitalFortune/β β β βββ chart/ # Trading chart components
βββ client/ # React frontend (Vite + TypeScript)β β β βββ orders/ # Order management UI
βββ httpserver/ # Express.js API serverβ β β βββ positions/ # Position tracking UI
βββ wsserver/ # WebSocket serverβ β βββ pages/
βββ poller/ # Market data pollerβ β β βββ Landing.tsx # Landing page
βββ db/ # PostgreSQL init scriptsβ β β βββ Dashboard.tsx # Trading dashboard
βββ docker-compose.ymlβ β βββ hooks/ # Custom React hooks
```β β βββ lib/ # Utilities & helpers
β β βββ store/ # Zustand state management
---β β βββ types/ # TypeScript definitions
β βββ Dockerfile
## π§ Developmentβ βββ package.json
β βββ vite.config.ts
```bashβ
# Start all servicesβββ httpserver/ # HTTP API Server
docker-compose up -dβ βββ src/
β β βββ index.ts # Main server & routes
# View logsβ β βββ riskEngine.ts # Risk management
docker-compose logs -f httpserverβ β βββ sl_tp_watcher.ts # Stop-loss/Take-profit watcher
β β βββ engine/
# Rebuild specific serviceβ β β βββ margin.ts # Margin calculations
docker-compose up -d --build clientβ β β βββ simpleMargin.ts
β β βββ lib/
# Stop everythingβ β β βββ liquidation.ts
docker-compose downβ β β βββ money.ts
```β β β βββ risk.ts
β β βββ risk/
**Access Points:**β β βββ liquidation.ts
- Frontend: http://localhostβ β βββ liquidator.ts
- API: http://localhost:3001β β βββ snapshot.ts
- WebSocket: ws://localhost:3002β βββ Dockerfile
β βββ package.json
---β
βββ wsserver/ # WebSocket Server
## π¦ What's Insideβ βββ src/
β β βββ index.ts # WebSocket handler
**Landing Page**β β βββ alerts.ts # Alert system
- Eye-catching hero with 20+ floating particlesβ βββ Dockerfile
- Feature cards with hover animationsβ βββ package.json
- 3D dashboard preview with parallax scrollingβ
- Mobile-responsive designβββ poller/ # Market Data Poller
β βββ src/
**Trading Dashboard**β β βββ index.ts # Price polling & candles
- Left sidebar: Instrument listβ βββ Dockerfile
- Center: Real-time charts + positions panelβ βββ package.json
- Right sidebar: Order panel with leverage sliderβ
- Live balance and margin displayβββ db/
β βββ init.sql # Database schema
**Backend**β
- JWT auth with 7-day token expirationβββ docker-compose.yml # Service orchestration
- User-specific order isolationβββ README.md # This file
- Real-time margin monitoring```
- Automated stop-loss/take-profit execution
- Liquidation engine triggers at 0% margin---
---## π‘ API Documentation
## π Deployment### Authentication Endpoints
### Docker (Recommended)#### `POST /api/v1/signup`
```bashRegister a new user (receives $5,000 demo balance).
# On your server
git clone https://github.com/abdulbaqui17/DigitalFortune.git**Request:**
cd DigitalFortune```json
docker-compose up -d --build{
``` "email": "user@example.com",
"password": "securePassword123",
### Manual "username": "trader123"
```bash}
# Install dependencies```
cd client && npm install && cd ..
cd httpserver && npm install && cd ..**Response:**
cd wsserver && npm install && cd ..```json
cd poller && npm install && cd ..{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
# Start services "user": {
docker-compose up -d postgres redis "id": 1,
cd httpserver && npm start & "email": "user@example.com",
cd wsserver && npm start & "username": "trader123"
cd poller && npm start & }
cd client && npm run build && npx serve dist}
---#### POST /api/v1/signin
Login existing user.
Request:
-
Fork the repo```json
-
Create feature branch (
git checkout -b feature/amazing){ -
Commit changes (
git commit -m 'Add amazing feature') "email": "user@example.com", -
Push to branch (
git push origin feature/amazing) "password": "securePassword123" -
Open Pull Request}
---
---
## π License
### Account Endpoints
MIT License - feel free to use for your projects!
#### `GET /api/v1/account`
---Get account balance and margin info.
## π¨βπ» Author**Headers:** `Authorization: Bearer {token}`
**Abdul Baqui** **Response:**
GitHub: [@abdulbaqui17](https://github.com/abdulbaqui17)```json
{
--- "balance": 5000.00,
"equity": 5234.50,
<div align="center"> "free": 4500.00,
"used": 734.50,
### β Star this repo if you find it helpful! "upnl": 234.50,
"level": 712.5,
Built with β€οΈ using React, TypeScript, and Docker "maintenance": 367.25
}
</div>```
---
### Trading Endpoints
#### `POST /api/v1/orders`
Place a new order.
**Request:**
```json
{
"symbol": "BTCUSDT",
"side": "buy",
"type": "market",
"quantity": 0.1,
"leverage": 10,
"stopLoss": 45000,
"takeProfit": 55000
}
Get open orders.
Get open positions with P&L.
Close a position.
Get historical candles.
Query Params:
interval: 1m, 5m, 15m, 1h, 4h, 1dlimit: Number of candles (default: 100)
Client β Server:
// Subscribe to market data
ws.send(JSON.stringify({
type: 'subscribe',
symbol: 'BTCUSDT'
}));Server β Client:
// Price update
{
type: 'price',
symbol: 'BTCUSDT',
price: 43521.50,
timestamp: 1699267200000
}
// Trade execution
{
type: 'trade',
orderId: 123,
status: 'filled',
price: 43521.50
}
// Position update
{
type: 'position',
positionId: 456,
upnl: 234.50,
roe: 4.69
}npm run dev # Start dev server (Vite)
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLintnpm run dev # Start with nodemon (auto-reload)
npm run build # Compile TypeScript
npm start # Start production serverCreate .env files in each service directory:
httpserver/.env:
DATABASE_URL=postgresql://postgres:postgres@postgres:5432/trading
JWT_SECRET=your-super-secret-jwt-key-change-in-production
PORT=3001
REDIS_URL=redis://redis:6379wsserver/.env:
WS_PORT=3002
REDIS_URL=redis://redis:6379# On your server
git clone https://github.com/abdulbaqui17/DigitalFortune.git
cd DigitalFortune
# Configure environment variables
nano .env
# Build and start services
docker-compose -f docker-compose.yml up -d --build
# Setup Nginx reverse proxy (optional)
sudo nano /etc/nginx/sites-available/tradingSample Nginx config:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /ws {
proxy_pass http://localhost:3002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}docker swarm init
docker stack deploy -c docker-compose.yml tradingkubectl apply -f k8s/- Eye-catching hero section with 20 floating particles
- Animated gradients and pulsing orbs
- 3D dashboard preview with parallax scrolling
- Feature cards with hover effects
- Real-time candlestick charts
- Order panel with leverage slider
- Position tracking with live P&L
- Balance display with margin info
By exploring this project, you'll understand:
-
Full-Stack TypeScript Development
- Type-safe frontend and backend
- Shared types between services
- Advanced TypeScript patterns
-
Real-Time Systems
- WebSocket implementation
- Event-driven architecture
- Live data streaming
-
Microservices Architecture
- Service separation
- Inter-service communication
- Docker orchestration
-
Advanced Frontend
- Complex state management
- Real-time UI updates
- Performance optimization
- Advanced animations
-
Trading Systems
- Order matching engines
- Margin calculations
- Risk management
- Liquidation logic
-
DevOps Practices
- Containerization
- Multi-stage Docker builds
- Service orchestration
- Production deployment
Contributions are welcome! Here's how:
- Fork the repository
- Create a feature branch
git checkout -b feature/AmazingFeature
- Commit your changes
git commit -m 'Add some AmazingFeature' - Push to the branch
git push origin feature/AmazingFeature
- Open a Pull Request
- Add more cryptocurrency pairs
- Implement order book visualization
- Add trading indicators (RSI, MACD, etc.)
- Implement social trading features
- Add mobile app (React Native)
- Integrate real exchange APIs
- Add backtesting functionality
- Implement trading bots
This project is licensed under the MIT License - see the LICENSE file for details.
Abdul Baqui
- GitHub: @abdulbaqui17
- Project: DigitalFortune
- TradingView for Lightweight Charts
- Framer Motion for animation library
- Tailwind Labs for Tailwind CSS
- Vercel for Zustand state management
- The open-source community
- Lines of Code: ~15,000+
- Components: 40+
- API Endpoints: 20+
- WebSocket Events: 10+
- Database Tables: 8
- Docker Services: 6
- Technologies Used: 15+
- Phase 1: Real exchange integration (Binance API)
- Phase 2: Mobile app development
- Phase 3: Social trading features
- Phase 4: Algorithmic trading bots
- Phase 5: Copy trading functionality
- Phase 6: NFT marketplace integration
π Live Demo | Documentation | Issues
Built with β€οΈ by Abdul Baqui