BTX Exchange

BTX: Database & API

This page covers the database schema and API surface for BTX.


Database Schema

BTX uses 6 DynamoDB tables:

bizBtxProjects{ENV}

Stores each tradeable project.

FieldTypeDescription
projectId (PK)StringUnique ID (usually = team ID)
eventIdStringWhich event (e.g., "kickstart")
tickerStringStock ticker symbol (e.g., "TEAM1")
nameStringDisplay name
basePriceNumberBase price from seed
currentPriceNumberCurrent market price
netSharesNumberTotal bought minus total sold
seedAmountNumberFunding seed amount
totalVolumeNumberTotal shares ever traded
totalTradesNumberNumber of trades
isActiveBooleanWhether trading is open

GSI: byEvent lets you query all projects for an event.

bizBtxAccounts{ENV}

Virtual cash balances for each trader.

FieldTypeDescription
userId (PK)StringUser's email
cashBalanceNumberCurrent cash (starts at $2,500)
initialBalanceNumberStarting amount (for P&L calculation)

bizBtxHoldings{ENV}

Current share holdings per user per project.

FieldTypeDescription
userId (PK)StringUser's email
projectId (SK)StringWhich project
sharesNumberHow many shares held
avgPriceNumberAverage purchase price

GSI: byProject lets you query all holders of a project.

bizBtxTrades{ENV}

Trade history log.

FieldTypeDescription
projectId (PK)StringWhich project
tradeId (SK)Stringts#timestamp#uuid
userIdStringWho traded
sideString"BUY" or "SELL"
sharesNumberHow many shares
priceNumberExecution price
cashDeltaNumberCash change (negative for buys)

bizBtxPrices{ENV}

Price history for charts.

FieldTypeDescription
projectId (PK)StringWhich project
ts (SK)NumberTimestamp
priceNumberPrice at this moment
sourceStringWhat caused the change: "TRADE", "DRIFT", "SEED_UPDATE", "PHASE_BUMP", "PROJECT_CREATE"

bizBtxSockets{ENV}

Active WebSocket connections (same pattern as the Live Wall).

FieldTypeDescription
connectionId (PK)StringWS connection ID
eventIdStringSubscribed event

API Endpoints

Public Endpoints (No Auth Required)

MethodPathDescription
GET/btx/projectsList all projects for an event
GET/btx/market/snapshotGet all projects with current prices (triggers drift)
GET/btx/trades?projectId=XRecent trades for a project
GET/btx/price-history?projectId=XPrice history for charts
GET/btx/leaderboardTop and bottom traders

Authenticated Endpoints (Cognito)

MethodPathDescription
POST/btx/market/buyBuy shares - body: { projectId, shares }
POST/btx/market/sellSell shares - body: { projectId, shares }
GET/btx/portfolioGet current user's portfolio

Admin Endpoints

MethodPathDescription
POST/btx/admin/projectCreate or update a project
POST/btx/admin/seedUpdate a project's seed amount
POST/btx/admin/phase-bumpApply a phase bump to a project
POST/btx/admin/investment-impactApply investment impact to a project

WebSocket Routes

RouteHandlerDescription
$connectwsConnectRegister connection
$disconnectwsDisconnectClean up connection
subscribewsSubscribeSubscribe to an event's updates

WebSocket messages (server → client):

{
  "type": "priceUpdate",
  "projectId": "team-alpha",
  "ticker": "ALPHA",
  "currentPrice": 2.45,
  "basePrice": 1.50,
  "netShares": 47,
  "marketCap": 115.15,
  "source": "TRADE",
  "updatedAt": 1234567890
}
Previous
Price Mechanics