How favoursui/bagsflow works
Purpose and Deployment Boundary
BAGS//FLOW is a single-origin Solana/Bags.fm trading dashboard: it displays live Bags-token order flow and lets a connected browser wallet execute swaps. Nginx serves the compiled static UI and reverse-proxies API and WebSocket traffic to FastAPI. Deployment is containerized through docker-compose.yaml, with proxy behavior in nginx.conf.
Browser Application
The frontend is a static Vanilla JS application using Chart.js and Tailwind-generated CSS. Dashboard code consumes live events, maintains feed/chart/leaderboard views, and surfaces token launches; swap code handles wallet connection, quote interaction, transaction signing, and Solscan links.
• frontend/build/index.html
• frontend/build/js/dashboard.js
• frontend/build/js/swap.js
FastAPI Application and Entry Points
The backend application is initialized in FastAPI, registers HTTP route modules, and owns lifecycle work such as the launch poller and real-time stream startup. It is runnable directly or as the backend container.
• backend/app/main.py
• backend/run.py
• backend/app/api/routes.py
HTTP API: Token, Analytics, and Swap Workflows
The API boundary separates browser-facing operations from upstream providers. Token endpoints validate token addresses and retrieve metadata/quotes; swap endpoints obtain executable swap transactions and support submission flow; analytics exposes aggregated session-facing data. Browser wallet signing remains client-side, while the backend brokers provider requests.
• backend/app/api/tokens.py
• backend/app/api/swap.py
• backend/app/api/analytics.py
Real-Time Trade Pipeline
A Helius WebSocket subscription watches Solana program logs relevant to Meteora DBC and Bags activity. Streamed logs are parsed/enriched into trade events, classified for whale thresholds, and distributed to connected dashboard clients through the backend WebSocket endpoint. This isolates chain-stream/provider protocol handling from browser presentation.
• backend/app/services/bitquery.py
• backend/app/core/websocket.py
• backend/app/main.py
Provider Integration Layer
Service clients encapsulate external dependencies: Bags.fm REST for token/swap functionality, Helius RPC/DAS for chain and token metadata access, and related provider handling for streaming/enrichment. Environment-backed settings centralize API keys, RPC URL, browser origin, and whale threshold.
• backend/app/services/bags.py
• backend/app/services/helius.py
• backend/app/core/config.py
Runtime and External Infrastructure
The production path is browser → Nginx → FastAPI for /api/, while /ws is proxied bidirectionally for live events. FastAPI runs on Python/uvicorn; frontend assets require no application server beyond Nginx. Core external systems are Solana mainnet RPC, Helius WebSocket/DAS APIs, Bags.fm APIs, Meteora DAMM v2 routing/liquidity, and browser wallets such as Phantom, Backpack, or Solflare.
Main entry points: routes.py Route registration · main.py FastAPI application · nginx.conf Nginx reverse proxy · index.html Static dashboard
Components 16
Browser UI
- Static dashboard
frontend/build/index.html - Live dashboard · Maintains feed, chart, leaderboard, and launch views.
frontend/build/js/dashboard.js - Wallet swap flow · Connects wallets, requests quotes, signs transactions, and shows Solscan links.
frontend/build/js/swap.js - Browser wallet · Signs swap transactions client-side.
FastAPI backend
- FastAPI application · Registers routes and starts launch polling and real-time streaming.
backend/app/main.py - Backend runner
backend/run.py - Route registration
backend/app/api/routes.py - Token API · Validates addresses and retrieves token metadata and quotes.
backend/app/api/tokens.py - Swap API · Brokers executable swap transactions and submission flow.
backend/app/api/swap.py - Analytics API · Exposes aggregated session-facing data.
backend/app/api/analytics.py - Trade stream processor · Subscribes, parses, enriches, and classifies Bags/Meteora trades.
backend/app/services/bitquery.py - Dashboard WebSocket hub · Broadcasts trade events to connected dashboard clients.
backend/app/core/websocket.py
Chain & trading providers
- Bags.fm API
backend/app/services/bags.py - Helius RPC, DAS & WebSocket
backend/app/services/helius.py - Solana mainnet · Includes Meteora DAMM v2 liquidity and routing.
Other components
- Nginx reverse proxy · Serves the static UI and proxies API and WebSocket traffic.
nginx.conf
Connections 21
- Nginx reverse proxy → Static dashboard: serves static assets
- Static dashboard → Live dashboard: loads
- Static dashboard → Wallet swap flow: loads
- Live dashboard → Nginx reverse proxy: HTTP API and /ws
- Wallet swap flow → Nginx reverse proxy: swap and token API
- Wallet swap flow → Browser wallet: requests transaction signature
- Nginx reverse proxy → FastAPI application: proxies /api and /ws
- Backend runner → FastAPI application: runs
- FastAPI application → Route registration: registers
- Route registration → Token API: routes requests
- Route registration → Swap API: routes requests
- Route registration → Analytics API: routes requests
- FastAPI application → Trade stream processor: starts
- Trade stream processor → Dashboard WebSocket hub: trade events
- Dashboard WebSocket hub → Live dashboard: live events
- Token API → Bags.fm API: token data and quotes
- Swap API → Bags.fm API: swap transactions
- Token API → Helius RPC, DAS & WebSocket: token metadata
- Trade stream processor → Helius RPC, DAS & WebSocket: program-log subscription
- Helius RPC, DAS & WebSocket → Solana mainnet: RPC and chain data
- Browser wallet → Solana mainnet: submits signed swaps