How conorwd/pump.fun-and-dexscreener-twitter-bot works
Project Type and Purpose
• This is a full-stack, React/Next.js application with server-side API routes.
• Purpose: monitor Twitter for Pump.fun token links and automatically execute Solana trades based on configurable criteria, while providing a modern web UI for monitoring and control.
File Structure
• Top-level files: Next.js config (next.config.js, tsconfig.json), build scripts, README.md, .env.
• src/app: Next.js App Router directory, holding pages, layout, providers, metadata.
• src/app/api/pump-proxy: serverless API route for proxying Pump.fun trades.
• src/components: React UI components for settings, order status, feeds, etc.
• src/contexts: React Contexts for global state (wallet, trading, blacklist, buylist).
• src/services & clients: wrappers around external services (Helius RPC, Twitter WS, DexScreener, PumpFun).
• Constants, types, CSS, Tailwind config.
README for Insights
• Describes real-time Twitter monitoring via WebSocket backend.
• Automatic token purchases through Helius RPC.
• UI for configuration (follower filter, slippage, blacklist/buylist).
• Uses a WebSocket URL (NEXT_PUBLIC_TWITTER_WS_URL) to receive events.
Main Components in the System
a. Browser / Client
• Next.js React app
• React Contexts & UI Components
b. Next.js Server
• API Route: /api/pump-proxy/route.ts (trade proxy)
• Server-side rendering for initial page loads
c. External Services
• Twitter WebSocket feed (real-time tweets)
• Helius RPC endpoint (Solana transaction gateway)
• Pump.fun API (token purchase endpoints)
• DexScreener API (price data)
Relationships and Data Flow
1. User opens browser → Next.js serves React pages (SSR/CSR).
2. React Contexts fetch initial config & status (optional GET to API routes).
3. Client establishes WebSocket to NEXT_PUBLIC_TWITTER_WS_URL.
4. Incoming tweets containing Pump.fun links are streamed to client.
5. Client logic (via twitterService) filters by follower count, buylist/blacklist.
6. Upon match, client calls /api/pump-proxy → Next.js server route.
7. Server route (pumpFunClient + heliusService) constructs and signs purchase TX via Helius RPC.
8. Confirmation/status flows back to client, UI updates order status component.
9. DexScreener calls provide price charts/data in UI.
Architectural Patterns & Design Principles
• Component-based UI (React) with Context for global state.
• Lightweight API layer in Next.js for secure secret handling (RPC calls).
• Service abstraction: each external system has a client/service wrapper.
• Separation of concerns: UI, state management, API proxy, external integration.
• Real-time event handling via WebSocket.
Elements
• Labels for each major component and sub-component.
• Env-var boundary: separate what uses NEXT_PUBLIC_ vs. server-only secrets.
• State stores (Contexts) that mediate between UI and services.