cryptocurrency-trading-ai

byingabire noel olivier

# Comprehensive System Prompt: NexTrade AI Trading & Investment Platform Build "NexTrade AI", an advanced web-based cryptocurrency trading, AI automated strategies, and affiliate investment platform. The UI must feature a premium, sleek dark-mode aesthetic (deep slate/charcoal background `#0B0E11`, primary emerald green accent `#00C076`, warning red `#FF3B30`, and subtle gray text muted elements) with high-density data visualizations. --- ## 1. Authentication & Security Structure - **Dual-Mode Auth Component (`LoginSignUp`):** - Switchable tabs ("Sign In" / "Create Account") driven by active tab state. - **Sign In Form:** Email, Password, "Forgot Password?" trigger, and "Sign In to NexTrade AI" primary submit. - **Create Account Form:** Full Name, Email, Password, Confirm Password, optional Referral Code field, and "Create Account" primary submit. - Third-party SSO option buttons for Google and Apple ID. - **Role-Based Access Control (RBAC):** - Roles: `user` and `admin`. - Secure routes requiring JWT session tokens. - Profile completion & mandatory KYC verification status toggle (`unverified`, `pending`, `verified`). --- ## 2. Database Schema (Supabase / PostgreSQL) Create the following relational tables with full Row-Level Security (RLS) enabled: 1. `profiles`: - `id` (uuid, Primary Key, refs auth.users) - `full_name` (text) - `email` (text, unique) - `avatar_url` (text) - `kyc_status` (enum: unverified, pending, verified) - `referral_code` (text, unique) - `referred_by` (uuid, refs profiles.id) - `created_at` (timestamp) 2. `wallets`: - `id` (uuid, Primary Key) - `user_id` (uuid, refs profiles.id) - `asset` (text, e.g., 'USDT', 'BTC', 'ETH') - `available_balance` (numeric, default 0.00) - `locked_balance` (numeric, default 0.00) - `updated_at` (timestamp) 3. `ai_bots` / `trading_strategies`: - `id` (uuid, Primary Key) - `name` (text, e.g., 'Alpha Momentum Grid', 'Quant Scalper AI') - `risk_level` (enum: Low, Medium, High) - `min_investment` (numeric) - `expected_daily_roi` (numeric, percentage) - `active_users_count` (integer) - `is_active` (boolean) 4. `investments`: - `id` (uuid, Primary Key) - `user_id` (uuid, refs profiles.id) - `bot_id` (uuid, refs ai_bots.id) - `invested_amount` (numeric) - `current_profit` (numeric) - `status` (enum: active, paused, closed) - `started_at` (timestamp) 5. `trades`: - `id` (uuid, Primary Key) - `user_id` (uuid, refs profiles.id) - `symbol` (text, e.g., 'BTCUSDT') - `side` (enum: BUY, SELL) - `type` (enum: MARKET, LIMIT) - `entry_price` (numeric) - `exit_price` (numeric, nullable) - `quantity` (numeric) - `pnl` (numeric) - `status` (enum: OPEN, CLOSED, CANCELLED) - `created_at` (timestamp) 6. `transactions`: - `id` (uuid, Primary Key) - `user_id` (uuid, refs profiles.id) - `type` (enum: DEPOSIT, WITHDRAWAL, TRADING_PROFIT, REFERRAL_BONUS, LEVEL_BONUS) - `amount` (numeric) - `asset` (text) - `tx_hash` (text, nullable) - `status` (enum: PENDING, COMPLETED, FAILED) - `created_at` (timestamp) 7. `referrals_and_bonuses`: - `id` (uuid, Primary Key) - `referrer_id` (uuid, refs profiles.id) - `referee_id` (uuid, refs profiles.id) - `level` (integer, e.g., 1, 2, 3) - `bonus_amount` (numeric) - `source_transaction_id` (uuid, refs transactions.id) - `created_at` (timestamp) --- ## 3. External API Integrations & Real-Time Data 1. **Binance API Integration (Market Data & Real-Time Feeds):** - Connect to Binance Public REST API & WebSockets (`wss://stream.binance.com:9443/ws`). - Implement real-time ticker stream (`<symbol>@ticker`) for live price updates (BTC/USDT, ETH/USDT, SOL/USDT, BNB/USDT). - Fetch historical candlestick data (`GET /api/v3/klines`) to render lightweight TradingView charts. - Secure private API key storage (AES-256 encrypted) in user settings for automated API execution on user exchange accounts if enabled. 2. **Crypto Payment Gateway:** - Integrate Web3 Wallet Connect (or NOWPayments / Binance Pay API) for deposit address generation (TRC20, BEP20, ERC20). - Direct deposit webhook handler to auto-credit `wallets.available_balance` upon receiving blockchain confirmations. --- ## 4. Business Logic & Automated Calculations 1. **Trade P&L & Net Return Engine:** - Write edge functions to compute real-time Profit and Loss: $$\text{Unrealized PnL} = (\text{Current Price} - \text{Entry Price}) \times \text{Quantity} \quad \text{(for BUY positions)}$$ - Automatically deduct protocol execution fees (0.1%) on closed trades. 2. **3-Tier Affiliate & Level Commission Engine:** - Automate multi-level referral reward distributions whenever a user deposits or earns trading yield: - **Level 1 (Direct Referral):** Earn **7%** bonus on deposit / bot daily yields. - **Level 2 (Indirect Referral):** Earn **3%** bonus on deposit / bot daily yields. - **Level 3 (Sub-referral):** Earn **1%** bonus on deposit / bot daily yields. - Create a database trigger function: Upon any yield generation or deposit completed, automatically compute Level 1–3 parents, create corresponding `transactions` record (`type = REFERRAL_BONUS`), and credit the referrer’s USDT wallet. 3. **AI Automated Bot Execution Logic:** - Daily cron job / schedule edge function to process active `investments`: - Calculate daily percentage yield based on the bot's configured ROI range. - Credit user wallet with yield and register a `TRADING_PROFIT` transaction. - Trigger referral commission calculations up the 3-tier tree. --- ## 5. UI Page & Navigation Structure - **Navbar / Sidebar:** Logo, Live Market Ticker, Navigation Links (Dashboard, AI Trading, Market, Wallet, Affiliate, Settings), Profile Avatar dropdown, Dark Mode toggle, Logout. - **Page 1: Auth View (`/login`):** Modern tabbed login/signup card with smooth visibility transitions. - **Page 2: Main Overview Dashboard (`/dashboard`):** Total Portfolio Balance, Net PnL card, Active AI Strategy cards, Recent Transactions table. - **Page 3: Live Market & Trading (`/market`):** Embedded live candle chart, Order Book, Real-Time Trade Stream, Market/Limit Buy & Sell Execution Panel. - **Page 4: AI Trading Bots (`/ai-trading`):** Catalog of available trading bots, performance metrics, "Invest Now" modal with flexible allocation input. - **Page 5: Wallet & Funds (`/wallet`):** Asset balance breakdown, Deposit modal with single-use crypto QR code generation, Withdrawal request form. - **Page 6: Multi-Level Affiliate Dashboard (`/affiliate`):** Unique referral link sharing widget, total team volume counter, Tier 1/2/3 breakdown table with active team count and bonus earnings. - **Page 7: User Profile & Security Settings (`/settings`):** KYC document upload portal, Binance API key management, Security 2FA setup.

No preview

Comments (0)

No comments yet. Be the first!

Project Tasks

23 planning tasks
#1

Generate system requirement document

1m 34s0.2 cr used
Done
#2

Generate personas & user flows

0m 26s0.2 cr used
Done
#7

Create flow for Trader / Investor (user)

0m 24sCredits in parent
Done
#8

Create flow for Platform Administrator (admin)

0m 24sCredits in parent
Done
#9

Landing

0m 42sCredits in subtasks
Paused
#24

Landing / Navigation

1.6 cr needed
Paused
#20

Landing / Hero Split

1.6 cr needed
Paused
#21

Landing / Readout Strip

1.6 cr needed
Paused
#22

Landing / Capability Band

1.6 cr needed
Paused
#23

Landing / Entry Actions

1.6 cr needed
Paused
#25

Landing / Footer

1.6 cr needed
Paused
#10

/login

Credits in subtasks
Paused
#11

/dashboard

Credits in subtasks
Paused
#12

/market

Credits in subtasks
Paused
#13

/ai-trading

Credits in subtasks
Paused
#14

/wallet

Credits in subtasks
Paused
#15

/affiliate

Credits in subtasks
Paused
#16

/settings

Credits in subtasks
Paused
#17

Users

Credits in subtasks
Paused
#18

Bot Management

Credits in subtasks
Paused
#19

Transactions

Credits in subtasks
Paused
#5

Architecture

0.2 cr needed
Paused
#6

Workspace task plan

0.2 cr needed
Paused

No completed page designs yet.

Completed design pages will appear here when they are ready to preview.

Landing: Read product proposition
/login: Open Sign In tab
/login: Enter email and password
/login: Submit sign in
Users: 1. Review user accounts and KYC
Users: Approve pending KYC submission
Users: 2. Retry user list load
Users: 3. Inspect referral lineage
Bot Management: 4. Review bot catalog
Bot Management: 5. Toggle bot is_active
Bot Management: 6. Retry catalog load
Transactions: 7. Review transactions by type
Transactions: 8. Act on pending or failed record
Transactions: 9. Trace bonus to source transaction
Transactions: 10. Retry transaction load

No completed page designs yet.

Completed design pages will appear here when they are ready to preview.

Landing: Read product proposition
/login: Open Sign In tab
/login: Enter email and password
/login: Submit sign in
Users: 1. Review user accounts and KYC
Users: Approve pending KYC submission
Users: 2. Retry user list load
Users: 3. Inspect referral lineage
Bot Management: 4. Review bot catalog
Bot Management: 5. Toggle bot is_active
Bot Management: 6. Retry catalog load
Transactions: 7. Review transactions by type
Transactions: 8. Act on pending or failed record
Transactions: 9. Trace bonus to source transaction
Transactions: 10. Retry transaction load