Skip to content

LoganthP/TradeDesk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ Trade Desk

AI-Powered Trading Terminal & Market Intelligence Platform




✨ Overview

Trade Desk is a modern AI-enhanced trading terminal designed for traders, analysts, and fintech enthusiasts.

It combines:

  • πŸ“Š Advanced financial charting
  • πŸ€– AI-assisted trading insights
  • ⚑ Real-time market simulation
  • πŸ’Ό Portfolio & order management
  • 🌐 WebSocket-powered live updates
  • 🧠 Persistent intelligent workspaces

The platform delivers a sleek institutional-grade experience inspired by modern trading terminals.


πŸš€ Core Features

πŸ“Š Advanced Trading Dashboard

  • Interactive market charts
  • Technical indicators
  • Responsive trading workspace
  • Real-time updates

πŸ€– AI Trading Assistant

  • Gemini AI integration
  • OpenRouter AI support
  • Context-aware market conversations
  • Persistent chat history

πŸ’Ό Portfolio Management

  • Create and manage portfolios
  • Simulated trading system
  • Pending orders
  • Market order execution

πŸ“ˆ Market Intelligence

  • Watchlists
  • Alerts system
  • Trading panels
  • Simulated market news

⚑ Real-Time Architecture

  • WebSocket communication
  • Live workspace synchronization
  • Persistent chart settings

πŸŒ™ Premium UI/UX

  • Modern fintech-inspired interface
  • Responsive layouts
  • Lazy-loaded modules
  • Smooth animations

🧠 System Architecture

flowchart TD

    A[πŸ‘€ Trader/User] --> B[βš›οΈ React + Vite Client]

    B --> C[πŸ“Š Trading Dashboard]
    B --> D[πŸ€– AI Assistant]
    B --> E[πŸ“ˆ Market Watchlists]
    B --> F[πŸ’Ό Portfolio Manager]

    C --> G[πŸ“‘ WebSocket Layer]
    D --> H[🧠 Gemini/OpenRouter APIs]

    G --> I[πŸ–₯️ Node.js + Express Server]

    I --> J[πŸ” Authentication Engine]
    I --> K[πŸ“‚ Trading APIs]
    I --> L[πŸ“¦ Portfolio Services]

    K --> M[(Prisma ORM)]
    L --> M

    M --> N[(SQLite / PostgreSQL)]

    B --> O[(Zustand Persistent Stores)]

    O --> P[Chart Preferences]
    O --> Q[AI Chat History]
    O --> R[Workspace State]
Loading

⚑ System Workflow

sequenceDiagram

    participant User
    participant Client
    participant Server
    participant Database
    participant AI

    User->>Client: Login / Trading Action
    Client->>Server: API Request
    Server->>Database: Fetch / Update Data
    Database-->>Server: Response
    Server-->>Client: Market / Portfolio Data

    User->>Client: Ask AI Assistant
    Client->>AI: AI Request
    AI-->>Client: Trading Insight

    Server-->>Client: WebSocket Updates
Loading

πŸ—οΈ Tech Stack

Technology Purpose
React 19 Frontend UI
TypeScript Type Safety
Vite Build Tool
Node.js Backend Runtime
Express.js API Layer
Prisma ORM Database ORM
SQLite / PostgreSQL Database
Zustand State Management
WebSockets Real-Time Updates
Gemini AI AI Assistant
Tailwind / CSS Styling

πŸ“‚ Project Structure

TerminalAlpha/
β”‚
β”œβ”€β”€ client/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ layouts/
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ stores/
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── styles/
β”‚   β”‚
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.ts
β”‚
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ websocket/
β”‚   β”‚   └── utils/
β”‚   β”‚
β”‚   β”œβ”€β”€ package.json
β”‚   └── tsconfig.json
β”‚
β”œβ”€β”€ README.md
└── package.json

πŸ“¦ Deployment Architecture

flowchart TB

    subgraph USER_LAYER["πŸ‘€ User Layer"]
        U1[πŸ’» Desktop Browser]
        U2[πŸ“± Mobile Browser]
        U3[πŸ“Š Trading Workspace]
    end

    subgraph FRONTEND["βš›οΈ Frontend Layer (Vercel / Netlify)"]
        F1[React + Vite Client]
        F2[Trading Dashboard]
        F3[AI Assistant UI]
        F4[Chart Engine]
        F5[Zustand Persistent Stores]
    end

    subgraph REALTIME["⚑ Real-Time Communication"]
        W1[WebSocket Gateway]
    end

    subgraph BACKEND["πŸ–₯️ Backend Layer (Railway / Render)"]
        B1[Node.js + Express API]
        B2[Authentication Service]
        B3[Trading Engine]
        B4[Portfolio Manager]
        B5[Market Simulation Service]
        B6[Alert & Watchlist Service]
    end

    subgraph DATABASE["πŸ—„οΈ Database Layer"]
        D1[(PostgreSQL)]
        D2[(Redis Cache - Optional)]
    end

    subgraph AI["πŸ€– AI Layer"]
        A1[Gemini API]
        A2[OpenRouter Models]
    end

    subgraph STORAGE["☁️ Persistence & State"]
        S1[LocalStorage]
        S2[Session Persistence]
    end

    subgraph DEVOPS["πŸš€ DevOps & Monitoring"]
        M1[GitHub Actions]
        M2[Health Checks]
        M3[Logging & Monitoring]
    end

    %% USER FLOW
    U1 --> F1
    U2 --> F1
    U3 --> F2

    %% FRONTEND
    F1 --> F2
    F1 --> F3
    F1 --> F4
    F1 --> F5

    %% API COMMUNICATION
    F1 -->|HTTPS REST API| B1
    F1 -->|WebSocket| W1

    %% REALTIME
    W1 --> B1

    %% BACKEND SERVICES
    B1 --> B2
    B1 --> B3
    B1 --> B4
    B1 --> B5
    B1 --> B6

    %% DATABASE
    B2 --> D1
    B3 --> D1
    B4 --> D1
    B5 --> D1
    B6 --> D1

    %% REDIS CACHE
    B1 --> D2

    %% AI
    F3 --> A1
    F3 --> A2

    %% STORAGE
    F5 --> S1
    F5 --> S2

    %% DEVOPS
    M1 --> FRONTEND
    M1 --> BACKEND

    M2 --> B1
    M3 --> B1
Loading

🌐 Production Deployment Flow

sequenceDiagram

    participant User
    participant Frontend
    participant API
    participant WebSocket
    participant Database
    participant AI

    User->>Frontend: Open Trading Terminal

    Frontend->>API: Authenticate User
    API->>Database: Validate Credentials
    Database-->>API: User Data
    API-->>Frontend: JWT Token

    Frontend->>API: Request Portfolio
    API->>Database: Fetch Portfolio
    Database-->>API: Portfolio Data
    API-->>Frontend: Portfolio Response

    Frontend->>WebSocket: Connect Real-Time Channel
    WebSocket-->>Frontend: Market Updates

    User->>Frontend: Execute Trade
    Frontend->>API: Submit Order
    API->>Database: Save Order
    API-->>Frontend: Order Confirmation

    User->>Frontend: Ask AI Assistant
    Frontend->>AI: AI Trading Request
    AI-->>Frontend: Trading Insight
Loading

☁️ Recommended Hosting Architecture

Layer Recommended Platform
Frontend Vercel / Netlify
Backend API Railway / Render
Database Neon PostgreSQL / Supabase
WebSockets Railway Persistent Services
AI Providers Gemini
CI/CD GitHub Actions
Monitoring UptimeRobot + Railway Metrics

πŸ” Security Architecture

flowchart LR

    A[πŸ‘€ User Login] --> B[πŸ” JWT Authentication]

    B --> C[πŸ›‘οΈ Protected API Routes]

    C --> D[πŸ“¦ Express Middleware]

    D --> E[(PostgreSQL)]

    C --> F[⚑ Rate Limiting]

    C --> G[🌐 CORS Protection]

    C --> H[πŸ”’ Environment Variables]
Loading

πŸš€ CI/CD Pipeline

flowchart LR

    A[πŸ‘¨β€πŸ’» Developer Push] --> B[GitHub Repository]

    B --> C[GitHub Actions]

    C --> D[Run Tests]
    C --> E[Build Client]
    C --> F[Build Server]

    E --> G[Vercel Deployment]
    F --> H[Railway Deployment]

    G --> I[🌐 Live Frontend]
    H --> J[πŸ–₯️ Live API]
Loading

πŸ” Environment Variables

🌐 Client

VITE_API_URL="https://your-api.example.com/api"
VITE_WS_URL="wss://your-api.example.com"
VITE_GEMINI_API_KEY="your-gemini-api-key-here"

πŸ–₯️ Server

DATABASE_URL="file:./dev.db"
JWT_SECRET="use-a-long-random-production-secret"
JWT_EXPIRES_IN="7d"
PORT=3001
NODE_ENV="production"
CORS_ORIGIN="https://your-client.example.com"

πŸš€ Server Setup Guide

πŸ“ Required Folder Structure

server/
β”‚
β”œβ”€β”€ prisma/
β”‚   └── schema.prisma
β”‚
β”œβ”€β”€ src/
β”‚
β”œβ”€β”€ .env
β”‚
β”œβ”€β”€ package.json
β”‚
└── dev.db

βš™οΈ Step 1 β€” Create .env

Inside the server folder create:

.env

Add:

DATABASE_URL="file:./dev.db"

JWT_SECRET="supersecretkey123"

πŸ› οΈ Step 2 β€” Generate Prisma Client

npx prisma generate

πŸ—„οΈ Step 3 β€” Create & Sync Database

npx prisma db push

πŸ“¦ Step 4 β€” Install Dependencies

npm install

▢️ Step 5 β€” Start Server

npm run dev

βœ… Expected Output

πŸš€ Paper Trading Server is running on port 3001
πŸ‘‰ CORS Origin allowed: http://localhost:5173

πŸ”„ Full Startup Commands

npx prisma generate

npx prisma db push

npm install

npm run dev

❗ If bcrypt Error Occurs

Install bcrypt packages:

npm install bcryptjs

npm install -D @types/bcryptjs

🌐 Frontend API URL

Inside client/.env:

VITE_API_URL="http://localhost:3001/api"

πŸ§ͺ Verify Backend

Open:

http://localhost:3001

If you see:

Cannot GET /

the backend is running correctly.


πŸ› οΈ Installation

Clone Repository

git clone https://github.com/LoganthP/TradeDesk.git

Install Client

cd client
npm install

Install Server

cd ../server
npm install

▢️ Run Development Environment

Start Client

cd client
npm run dev

Start Server

cd server
npm run dev

πŸš€ Production Build

Build Client

cd client
npm run build

Build Server

cd server
npm run build
npm run start

πŸ€– AI Integration

Supported AI Providers

  • Gemini API

AI Features

  • Trading conversations
  • Market explanations
  • Strategy discussions
  • Persistent AI history

πŸ”₯ Performance Optimizations

  • ⚑ Route-level lazy loading
  • ⚑ Vite manual chunk splitting
  • ⚑ Zustand persistence
  • ⚑ Optimized production builds
  • ⚑ WebSocket live updates

πŸ“ˆ Production Readiness

βœ… Validated

  • TypeScript strict mode enabled
  • Production builds passing
  • Secure environment handling
  • Persistent state architecture
  • Lazy-loaded routing
  • Optimized bundle splitting

⚠️ Follow-Up Work

  • Replace simulated data with real providers
  • Improve ESLint compliance
  • Add provider-specific deployment configs
  • Institutional-grade QA testing

πŸ§ͺ Deployment Checklist

cd client
npm run build

cd ../server
npm run build

βœ… Smoke Tests

  • Authentication flow
  • Dashboard rendering
  • Trading operations
  • Portfolio reset
  • AI assistant responses
  • Responsive layouts
  • WebSocket updates

🌟 Future Roadmap

  • πŸ“‘ Real market data integration
  • 🏦 Brokerage connectivity
  • πŸ“Š Institutional analytics
  • πŸ€– Advanced AI trading agents
  • ☁️ Cloud workspace sync
  • πŸ“± Mobile application
  • πŸ”” Real push notifications

🀝 Contributing

Contributions are welcome!

Fork β†’ Clone β†’ Create Branch β†’ Commit β†’ Push β†’ Pull Request

πŸ“œ License

This project is licensed under the MIT License.

About

A modern AI-powered trading terminal with real-time market simulation, advanced charting, portfolio management, intelligent watchlists, and integrated AI trading assistance built using React, Vite, Node.js, Express, Prisma, and WebSockets.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages