Торговая платформа бинарных опционов. Вся логика (баланс, цены, расчёт сделок) выполняется на бэкенде. Пополнение и вывод — через HighHelp (P2P, RUB). Документация HighHelp: docs.highhelp.io.
Боевой режим: для работы пополнения и вывода в
backend/.envзадайтеHIGHHELP_PROJECT_ID,HIGHHELP_PRIVATE_KEY_PEMиBACKEND_PUBLIC_URL. Подробно см. PRODUCTION.md.
- Frontend: Next.js (App Router, TypeScript, Tailwind, Zustand)
- Backend: Node.js + Express + Prisma
- DB: PostgreSQL
- Auth: JWT (Bearer)
- Realtime: WebSocket (
ws)
frontend– Next.js app (UI, auth pages, trading screen, charts)backend– Express API + Prisma + WebSocket + trade enginedocker-compose.yml– Postgres + backend + frontend
Usermodel with demo balance (default 1000.00)TradingPairmodel with server-side current priceTrademodel with statuses:ACTIVE,WIN,LOSS- All monetary and trade calculations are performed only on the server.
POST /auth/register– email + password, returns JWT + user (with demo balance)POST /auth/login– login, returns JWT + userGET /me– current user & balance (JWT required)GET /trading-pairs– available pairs + current pricesPOST /trade/open– open a trade (balance check, entry price, expiry time, balance deduction)GET /trades/active– active tradesGET /trades/completed– historical trades (WIN/LOSS)
- On open:
- Server verifies JWT, reads user from DB
- Checks demo balance
- Reads current price from server-side price service
- Deducts stake from demo balance
- Creates
Tradewith statusACTIVE,entryPrice,expiresAt
- Background settlement (interval):
- Finds expired
ACTIVEtrades - Fixes
closePricefrom current server price - Computes
WIN/LOSSon server - Updates user balance (
WIN= returns 2× stake; stake already deducted on open) - Broadcasts trade update via WebSocket
- Finds expired
- Backend runs a mock price feed (simple random walk per trading pair)
- Server holds the authoritative current price in memory + DB
- WebSocket broadcasts:
{"type":"price","pairId", "price"}{"type":"tradeUpdate","trade":{...}}
- Auth pages:
/login,/register - Protected trading screen:
/trade - State management: Zustand store:
- auth (JWT + user)
- balance
- trading pairs
- prices (per pair, time series)
- active & completed trades
- Chart:
- SVG-based
- Combined line + minimalist “candles”
- Real-time updates from WebSocket
- Trading UI:
- Pair selection
- Current price display
- Amount input + quick presets
- Expiry input (seconds)
LONG/SHORTbuttons calling backend/trade/open- Active trades list with countdown timers
- Completed trades with
WIN/LOSSlabels
Requirements:
- Docker & Docker Compose
Обычный запуск (образы собираются, код внутри образа):
cd path/to/TradingNew
docker compose up --buildРежим разработки — изменения в коде видны без пересборки (исходники монтируются с хоста). Рекомендуется для Docker Desktop, иначе правки в коде не попадут в контейнеры:
cd path/to/TradingNew
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -dПосле правок в коде: обновить страницу в браузере с полной перезагрузкой (Ctrl+Shift+R). Перезапуск контейнеров (например после git pull): та же команда docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d.
Services:
- Frontend: http://localhost:3000
- Backend API: http://localhost:4000
- Postgres: localhost:5432
Note: Prisma migrations are not auto-applied in this MVP image.
For local development you should run them once (see below).
You can still use the postgres service in docker-compose.yml:
docker compose up postgresEnvironment (matches docker-compose.yml defaults):
POSTGRES_USER=mvp_userPOSTGRES_PASSWORD=mvp_passwordPOSTGRES_DB=mvp_trading
cd backend
npm install
# Set DATABASE_URL (if not using Docker defaults)
set DATABASE_URL=postgresql://mvp_user:mvp_password@localhost:5432/mvp_trading?schema=public
npx prisma generate
npx prisma migrate dev --name init
npm run devBackend will listen on http://localhost:4000.
cd frontend
npm install
set NEXT_PUBLIC_API_BASE_URL=http://localhost:4000
set NEXT_PUBLIC_WS_URL=ws://localhost:4000
npm run devFrontend will listen on http://localhost:3000.
- Registration & Balance
- Open
http://localhost:3000 - Go to Create demo account
- Confirm you receive default demo balance (~1000)
- Open
- Login
- Sign out, then sign in via
/login
- Sign out, then sign in via
- Open Trade
- Go to
/trade - Select a pair
- Choose amount and expiry
- Click
LONGorSHORT - Balance decreases by stake amount
- Go to
- Auto Settlement
- Wait until expiry
- Trade moves from Active to History
- Status becomes
WINorLOSS - Balance is updated on server
- Realtime UI
- Prices on chart and current price label update in real time
- Active and completed trades update automatically via WebSocket
- MVP only:
- No deposit/withdrawal
- No admin panel
- No real-data price feed (mock only)
- Security (MVP level):
- JWT stored client-side, sent as
Authorization: Bearer <token> - Passwords hashed with
bcrypt - All sensitive logic (balances, trade outcomes, prices) lives on backend
- JWT stored client-side, sent as