Trade Engine AI Fullstack Docs

ENGINE TRADE AI

An autonomous crypto trading engine. Mechanical precision meets AI execution.

Scroll · enter the docs

01 — Mission

Overview

Next.js fullstack product: bullish marketing machine in front, serious trading desk behind the login — charts, signals, radar, and an AI agent.

Network Solana
Ticker $ETAI
Supply 1B
Tax 0.5%

Public machine

Landing chapters sell the thesis with motion and scene snap.

Access doors

Email, Google OAuth, and Solana wallet — one desk identity.

Neural desk

Cockpit with charts, signals, radar, and AI tool calling.

Thesis: Volume fuels tax → treasury → vaults. AI execution compounds edge for $ETAI alignment.

02 — Surfaces

Product surfaces

Landing — /

Full-viewport chapter experience: Home, About, Systems, Features, Tiers, Tokenomics, End. Motion-first. Brand-first. No scroll spam — scene snap.

Auth — /login · /signup

Email + password, Google OAuth, and Solana wallet sign-in (Phantom / Solflare / Wallet Standard). One desk, three doors.

Cockpit — /app

Authenticated trading desk: charts, signals, radar, watchlist, history, and AI chat rail with tool-calling power.

Landing chapters

Scene ID What it sells
Home home ENGINE / sphere / TRADE AI lockup — brand as the hero
About about Terminal narrative + DEX banner — how the engine boots
Systems features Animated systems terminal — live-feel market machinery
Features how-it-works Listing radar, signals, vaults, treasury rails
Tiers tiers Hold-to-unlock: Basic → Pro → Elite → Whale
Tokenomics tokenomics $ETAI sheet — supply, tax, tier holdings
End end Close the loop — CTA + social (X)

03 — Stack

Tech stack

Production-grade TypeScript fullstack. Fast to ship. Hard to fake.

Next.js 15 React 19 Auth.js v5 PostgreSQL 16 Drizzle ORM Solana OpenRouter Hyperliquid twitterapi.io Docker + nginx
Layer Choice Where
Framework Next.js App Router, Turbopack, standalone output package.json, next.config.ts
Auth next-auth beta + Drizzle adapter, JWT sessions src/auth.ts, src/auth.config.ts
Database Postgres + Drizzle Kit migrations src/db/, drizzle/
Wallets Solana wallet-adapter + ed25519 verify src/components/auth/, src/lib/auth/
Charts lightweight-charts v5 src/components/platform/ChartPlane.tsx
AI OpenRouter chat + tool calling src/app/api/chat/, src/lib/agent/
Markets Hyperliquid market REST src/lib/hyperliquid/
Social intel twitterapi.io + curated handle list src/lib/twitter/, src/lib/signals/
Motion / UI Framer Motion, GSAP, custom cyan/mint CSS src/app/globals.css
Deploy Docker Compose + nginx + certbot scripts/deploy.sh

04 — System

Architecture

One Next.js process owns the UI and the API. Postgres holds users, chats, preferences, and listing memory. External rails feed markets and social heat. Nginx terminates TLS in production.

Edge middleware

src/middleware.ts protects /app and redirects logged-in users away from login/signup. Config is edge-safe; full authorize lives in Node.

IPv4-first DNS

src/instrumentation.ts prefers IPv4 so Google OIDC discovery doesn’t die on broken IPv6 hosts.

05 — Access

Authentication

Three doors. One session. Desk ready.

01
Email / password Signup hashes with bcrypt (12) via POST /api/auth/signup, creates user + trial subscription, then credentials sign-in.
02
Google OAuth Enabled when AUTH_GOOGLE_ID / AUTH_GOOGLE_SECRET are set. Redirect URI: /api/auth/callback/google. Email linking allowed.
03
Solana wallet SIWS-style message + signMessage. Server verifies ed25519, checks domain against AUTH_URL, upserts walletAddress.

Launch trial

Full features unlock for 7 days from LAUNCH_DATE / NEXT_PUBLIC_LAUNCH_DATE. After that, the product narrative gates on $ETAI holdings or subscription — soft-allow remains until billing ships (src/lib/access.ts).

06 — Desk

Cockpit

The cockpit is the money seat. Multi-pane Hyperliquid futures charts, live HUD, signal heat, listing radar, watch alerts, and a chat rail that can move the desk.

Stage tabs

Charts · Signals · Radar · Watch · History

Layouts

1 / 2 / 4 panes — default 4: BTC · ETH · SOL · ADA @ Min15

HUD

Mark, 24h change, funding, OI, depth, setup lines, optional liq zones

Persistence

Desk prefs via /api/user/desk-preferencesuser.chartPreferences JSON

Key UI modules

  • Cockpit / ChartPlane / DeskRail / ChatRailsrc/components/platform/
  • AlertEngine — polls watchlist / alerts client-side
  • TrialBanner + UserDock — launch status and session
  • Signals / Radar / Watch / History panels — moduleized desk views

07 — Intelligence

AI agent & tools

The chat agent is not a toy chatbot. It calls real tools against Hyperliquid and X, then can act on the desk — set charts, propose setups, compare panes.

Tool Power
list_or_search_symbols Discover Hyperliquid market symbols
get_klines / get_market_snapshot OHLCV + mark/funding/OI style context
get_orderbook_summary Depth pressure at a glance
compute_indicators Technical readouts from candle data
get_trade_signals / search_x Curated + global X intel
get_funding_history / get_long_short_ratio Derivatives positioning
set_chart / propose_setup / compare_panes Direct desk actions from chat

Route: POST /api/chat — auth required, streams responses, persists threads/messages, model via OPENROUTER_MODEL.

08 — Routes

API map

Route Role
/api/auth/[...nextauth] Auth.js handlers
/api/auth/signup Email registration
/api/chat OpenRouter agent + tools
/api/chats, /api/chats/[id] Thread CRUD
/api/market/symbols|klines|snapshot(s)|listings Hyperliquid market rails
/api/signals/feed Curated X signal feed
/api/user/desk-preferences Desk layout / prefs
/api/dex-icon/[slug] Proxied DEX icons for landing

09 — Persistence

Database

Drizzle schema in src/db/schema.ts. Migrations under drizzle/.

Table Purpose
user Profile, password hash, wallet, chart preferences JSON
account / session / verificationToken Auth.js adapter tables
chat / message Agent threads and turns
subscription Trial / plan / holdings qualification stubs
listing_seen Radar memory — first-seen Hyperliquid symbols
tweet_cache Cached tweets by handle / id

10 — $ETAI

Token & tiers

Alignment is the product. Hold more. Unlock more. Fuel the engine.

Basic

Hold 0.1%

Core signals & standard tools

Pro

Hold 0.25%

Advanced indicators & vaults

Elite

Hold 0.5%

Deep analytics & higher limits

Whale

Hold 1%

Everything unlocked · priority

Contract address: coming soon on Pons Family

11 — Config

Environment

Copy from .env.example. Never commit .env.

Variable Purpose
NEXT_PUBLIC_APP_URL Public origin
AUTH_URL / AUTH_SECRET Canonical auth URL + signing secret
AUTH_GOOGLE_ID / SECRET Optional Google OAuth
DATABASE_URL Postgres connection
OPENROUTER_API_KEY / MODEL LLM access (default gpt-4o-mini)
TWITTERAPI_IO_KEY X / Twitter data
LAUNCH_DATE Trial window start

In Docker, compose forces DATABASE_URL=postgresql://engine:engine@postgres:5432/enginetrade.

12 — Ship

Deploy

One script. Nginx. TLS. Containers. Live.

chmod +x ./scripts/deploy.sh
./scripts/deploy.sh tradeengineai.com you@email.com
01
Prereqs DNS A record → server IP. Ports 80/443 open.
02
Script Installs Docker / nginx / certbot if needed, syncs AUTH_URL + app URL, writes nginx reverse proxy to 127.0.0.1:3000.
03
Compose up docker compose up -d --build — app + Postgres. Container runs migrations then node server.js.
04
Certbot HTTPS + redirect. Fill remaining .env keys, rebuild if needed.

Local fast path

docker compose up -d postgres
npm run db:push
npm run dev
# or: ./START-WEBSITE.sh

Google OAuth on production

  • Origin: https://tradeengineai.com
  • Redirect: https://tradeengineai.com/api/auth/callback/google
TRADE ENGINE AI — fullstack documentation · brand cyan #4de8f0 · mint #5ff5c8 · void black · live at /docs
Scroll · next chapter