Production-grade backend for prediction market trading platform with Polymarket integration, Solana permissions, and automated trading strategies.
- Framework: NestJS (TypeScript)
- Database: PostgreSQL with Prisma ORM
- Cache/PubSub: Redis
- WebSockets: Socket.IO
- Queue: BullMQ (optional)
- Blockchain: Solana Web3.js
- Market Domain: Normalized market data from Polymarket, Kalshi, and simulated sources
- Conviction Strategy Domain: Automated thematic trading with real-time execution
- Arbitrage Domain: Cross-market arbitrage detection and execution
- Analytics Domain: PnL calculations, payoff curves, scenario modeling
- Execution Domain: Immutable execution logs with Solana integration
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration
# Set up database
npx prisma generate
npx prisma migrate dev
# Start development server
npm run start:devGET /markets- List all marketsGET /markets/:id- Get market details
POST /conviction- Create strategyGET /conviction- List strategiesPOST /conviction/:id/pause- Pause strategy
GET /arbitrage/opportunities- List opportunitiesPOST /arbitrage/simulate- Simulate arbitrage trade
GET /analytics/pnl- Get PnL metricsGET /analytics/payoff- Get payoff curvesGET /analytics/scenario- Run scenario analysis
/ws/markets- Real-time market updates/ws/conviction- Strategy execution events/ws/arbitrage- Arbitrage opportunity alerts
- Deterministic calculations
- Financial correctness > speed
- Clear logs for every trade decision
- Idempotent and replayable execution