This is the backend service for LeveledUp, a Solana trading workspace.
🌐 Website: https://leveledup.fun
Important Notice: This project is maintained. If you contribute to this project, you must give proper credits to the original author in your contributions and any derived works.
src/
├── app.ts # Main application setup and configuration
├── server.ts # Server entry point
├── routes/ # API route handlers
├── services/ # Business logic and external service integrations
├── middleware/ # Express middleware functions
├── utils/ # Utility functions and helpers
├── types/ # TypeScript type definitions
├── cache/ # Caching layer implementations
└── uploads/ # File upload storage directory
- Node.js (v16 or higher)
- npm or yarn
- TypeScript
- Install dependencies:
npm install- Set up environment variables:
Create a
.envfile in the root directory with the following variables:
# Database Configuration
MONGODB_URI=your_mongodb_connection_string
DB_NAME=your_database_name
# Authentication
JWT_SECRET=your_jwt_secret_key
SESSION_SECRET=your_session_secret
# API Keys
RAPID_API_KEY=your_rapid_api_key
COINGECKO_API_KEY=your_coingecko_api_key
SOLANA_TRACKER_API_KEY=your_solana_tracker_api_key
# Blockchain
RPC_URL=your_rpc_url
- Start the development server:
npm run dev-
POST /auth/register- Register a new user// Response { token: string; user: { _id: string; username: string; bio: string; name: string; profile_image_url: string; wallet_address: string | null; notifications: { price_alerts: boolean; transaction_updates: boolean; security_alerts: boolean; }; type: string; twoFactor: boolean; } }
-
POST /auth/login- User login// Response { token: string; user: { _id: string; username: string; bio: string; name: string; profile_image_url: string; wallet_address: string | null; notifications: { price_alerts: boolean; transaction_updates: boolean; security_alerts: boolean; }; type: string; twoFactor: boolean; } }
-
POST /auth/wallet/connect- Connect wallet to user account// Response { token: string; user: { _id: string; username: string; name: string; profile_image_url: string; wallet_address: string; twitter_id: string; type: string; twoFactor: boolean; notifications: { price_alerts: boolean; transaction_updates: boolean; security_alerts: boolean; }; } }
-
POST /2fa/setup- Generate 2FA secret and QR code// Response { success: boolean; qrCode: string; secret: string; // Backup key for manual entry }
-
POST /2fa/verify- Verify and enable 2FA// Response { success: boolean; message: string; }
-
POST /2fa/validate- Validate 2FA token for login// Response { success: boolean; message: string; }
-
POST /2fa/disable- Disable 2FA// Response { success: boolean; message: string; }
-
GET /2fa/status- Get 2FA status// Response { success: boolean; enabled: boolean; setupInProgress: boolean; }
-
POST /api/user/profile- Update user profile// Response { success: boolean; message: string; }
-
POST /api/user/avatar- Update user avatar// Response { success: boolean; message: string; profile_image_url: string; }
-
GET /api/portfolio- Get user's token portfolio// Response { // Portfolio data structure }
-
GET /api/prices- Get all token prices// Response { prices: Record<string, number>; }
-
GET /api/prices/:token- Get specific token price// Response { token: string; price: number; }
POST /api/otc/create- Create new OTC trade// Request Body { creator: { userId: string; walletAddress: string; }; token: { address: string; amount: string; recipient: string; metadata: any; }; solana: { amount: string; recipient: string; }; escrowWallet: string; } // Response { success: boolean; tradeId: string; escrowWallet: string; trade: OTCData; }
GET /api/otc- Get user's OTC trades// Response { success: boolean; trades: OTCData[]; }
GET /api/otc/trades/:tradeId- Get specific OTC trade// Response { success: boolean; trade: OTCData; }
GET /api/otc/validate/:walletAddress- Validate wallet address// Response { success: boolean; balance: number; }
POST /api/support- Create support ticket// Request Body { email: string; subject: string; message: string; category: string; priority: 'low' | 'medium' | 'high'; } // Response { success: boolean; message: string; ticketId: string; }
GET /api/support- Get user's support tickets// Response { success: boolean; tickets: SupportTicket[]; }
POST /api/support/:support_ticket_id/reply- Reply to support ticket// Request Body { message: string; } // Response { success: boolean; message: string; }
GET /api/support/:support_ticket_id- Get specific support ticket// Response { success: boolean; ticket: SupportTicket; }
POST /api/features- Submit feature request// Request Body { email: string; subject: string; message: string; category: string; priority: 'low' | 'medium' | 'high'; } // Response { success: boolean; message: string; featureId: string; }
GET /api/features- Get user's feature requests// Response { success: boolean; features: Feature[]; }
POST /api/journal- Create trade journal entry// Request Body { pair: string; type: string; entry: number; exit: number; amount: number; notes: string; status: string; } // Response { success: boolean; message: string; trade: TradeData; }
GET /api/journal- Get user's trade journal entries// Response { success: boolean; trades: TradeData[]; }
POST /api/calculators- Save calculation// Request Body { name: string; type: string; data: { entryPrice: string; stopLoss: string; takeProfit: string; positionSize: string; result: { riskPercent: number; riskAmount: number; gainAmount: number; ratio: number; breakeven: number; }; }; } // Response { success: boolean; message: string; calculation: CalculationData; }
GET /api/calculators- Get user's calculations// Response { success: boolean; calculations: CalculationData[]; }
PUT /api/calculators/:id- Update calculation// Request Body { name: string; type: string; data: CalculationData['data']; } // Response { success: boolean; message: string; calculation: CalculationData; }
DELETE /api/calculators/:id- Delete calculation// Response { success: boolean; message: string; calculation: any; }
GET /api/notifications- Get user's notifications// Response { success: boolean; notifications: Notification[]; settings: { price_alerts: boolean; transaction_updates: boolean; security_alerts: boolean; }; }
POST /api/notifications/mark-all-read- Mark all notifications as read// Response { success: boolean; message: string; }
POST /api/notifications/clear-all- Clear all notifications// Response { success: boolean; message: string; }
POST /api/notifications/:id/read- Mark notification as read// Response { success: boolean; message: string; }
DELETE /api/notifications/:id- Delete notification// Response { success: boolean; message: string; }
POST /api/notifications/:type/toggle- Toggle notification type// Response { success: boolean; message: string; notifications: { price_alerts: boolean; transaction_updates: boolean; security_alerts: boolean; }; }
GET /api/news- Get latest news// Response { // News data structure }
POST /swap/execute- Execute token swap// Request Body { signedTransaction: string; fromToken: string; toToken: string; amount: string; } // Response { success: boolean; signature: string; fromToken: string; toToken: string; amount: string; }
GET /files/:file_id- Serve file
# Database Configuration
MONGODB_URI=your_mongodb_connection_string
DB_NAME=your_database_name
# Authentication
JWT_SECRET=your_jwt_secret_key
SESSION_SECRET=your_session_secret
# API Keys
RAPID_API_KEY=your_rapid_api_key
COINGECKO_API_KEY=your_coingecko_api_key
SOLANA_TRACKER_API_KEY=your_solana_tracker_api_key
# Blockchain
RPC_URL=your_rpc_url- Follow TypeScript best practices
- Use ESLint for code linting
- Follow the existing project structure
# Run tests
npm test
# Run tests with coverage
npm run test:coveragenpm run buildThe application can be deployed using:
- Docker
- Traditional Node.js hosting
- Serverless platforms
# Build the Docker image
docker build -t leveledup-backend .
# Run the container
docker run -p 3000:3000 leveledup-backend- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.