MedMarket is a medical education platform that combines live video broadcasting, real-time interactive quizzes, AI-powered video analysis, and blockchain-based payments. The platform enables medical professionals to conduct live educational sessions with audience participation, betting mechanics, and Solana cryptocurrency integration.
- Real-time video broadcasting with WebSocket support
- Multi-viewer live streaming capabilities
- Interactive live chat during broadcasts
- Support for medical video datasets (Echo, POCUS, Laparoscopy, Intrapartum)
- Real-time quiz broadcasting to multiple participants
- Live audience participation and scoring
- WebSocket-based quiz delivery
- User performance tracking in MongoDB
- SAM3 (Segment Anything Model) integration for medical video segmentation
- Object tracking and bounding box detection
- Frame-by-frame analysis and spatial data extraction
- JSON export of segmentation results
- Optimized for medical imaging (ultrasound, surgical videos)
- Mainnet-ready cryptocurrency payments
- User wallet creation and management
- Deposit and withdrawal functionality
- AI assistant unlock feature (0.4 SOL)
- Transaction verification on-chain
- Phantom wallet integration
- Live chat during broadcasts
- WebSocket-based messaging
- Multi-user chat rooms
- Real-time message synchronization
- Interactive betting panel for live events
- Token-based prediction mechanics
- User balance management
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- UI: React 19, Tailwind CSS 4
- Real-time: WebSocket connections
- Blockchain:
- @solana/web3.js
- @solana/wallet-adapter-react
- Phantom Wallet support
- AI: OpenAI SDK, Azure OpenAI
- Auth: JWT tokens via jose
- Database Client: MongoDB driver
- Language: Go 1.25.6
- Web Framework: Gorilla Mux
- Real-time: WebSocket hubs for broadcasting, chat, and quizzes
- Database: MongoDB (Go driver)
- Blockchain: Solana web3 integration
- Environment: dotenv for configuration
- Language: Python 3.8+
- Framework: FastAPI (for API endpoints)
- ML Model: Ultralytics SAM3 (Segment Anything Model)
- Video Processing: OpenCV, frame-by-frame analysis
- Output: JSON-based tracking data
- Primary: MongoDB Atlas
- Collections:
- Users (authentication, balances, profiles)
- Deposits (Solana transaction records)
- Withdrawals (payout tracking)
- Quiz results and scores
MedMarket/
├── frontend/ # Next.js React application
│ ├── app/ # App router pages and API routes
│ ├── components/ # React components (UI, broadcast, chat, quiz)
│ └── lib/ # Utility functions and helpers
│
├── backend/ # Go server
│ ├── server/ # Main server application
│ │ ├── main.go # Entry point, WebSocket hubs
│ │ ├── pkg/ # Core packages (chat, quiz, AI client, Solana)
│ │ ├── cryptostuff/ # Solana exchange logic
│ │ └── solana_routes.go # Blockchain API endpoints
│ ├── ai_service/ # Python AI service
│ │ ├── app.py # SAM3 video segmentation
│ │ └── main.py # FastAPI server
│ └── database/ # Database migrations
│
└── Dataset/ # Medical video datasets
├── Echo/ # Echocardiogram videos
├── POCUS/ # Point-of-care ultrasound
├── Lapchole/ # Laparoscopic cholecystectomy
└── Intrapartum/ # Obstetric videos
- Node.js 20+ (for frontend)
- Go 1.25+ (for backend server)
- Python 3.8+ (for AI service)
- MongoDB Atlas account or local instance
- Solana Wallet (for blockchain features)
- Phantom Wallet browser extension (for users)
git clone https://github.com/vlrr7/MedMarket.git
cd MedMarketcd backend
# Create .env file
cp .env.example .env
# Edit .env with your configuration:
# MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/
# MONGODB_DB=medmarket
# SOL_RECEIVER_ADDRESS=your_solana_public_key
# SOL_TREASURY_SECRET_KEY=[your_secret_key_array]
# SOLANA_RPC=https://api.mainnet-beta.solana.com
# AI_SERVICE_URL=http://localhost:8000
# Run the server
cd server
go run main.goServer will start on http://localhost:8080
cd frontend
# Install dependencies
npm install
# Create .env.local file
cat > .env.local << EOF
NEXT_PUBLIC_SOL_RECEIVER=YOUR_SOLANA_WALLET_ADDRESS
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/
MONGODB_DB=medmarket
EOF
# Run development server
npm run devFrontend will be available at http://localhost:3000
cd backend/ai_service
# Install dependencies
pip install -r requirements.txt
# Run the service
python app.py 706.5,442.5,905.25,555 598,635,725,750AI service runs on http://localhost:8000
See QUICKSTART.md for a 3-step quick start guide.
- Navigate to
/broadcasterpage - Start your video stream
- Launch interactive quizzes
- Monitor live chat and viewer engagement
- Sign up / Sign in to the platform
- Connect your Phantom wallet (optional)
- Deposit SOL to participate in betting
- Join live broadcasts at
/viewer - Answer quiz questions and earn tokens
- Chat with other participants
// Users connect Phantom wallet
// Send SOL to platform treasury address
// Backend verifies transaction on-chain
// User balance updated in MongoDB# Cost: 0.4 SOL per unlock
# Deducted from user balance
# Grants access to AI features# Request withdrawal from user balance
# Backend processes transaction
# SOL sent to user's wallet addressFor detailed Solana setup, see:
# Run video segmentation on medical footage
cd backend/ai_service
# Process video with bounding boxes
python app.py <bbox1> <bbox2> ...
# Example
python app.py 706.5,442.5,905.25,555 598,635,725,750
# Output: segmentation_results.jsonSee backend/ai_service/README.md for details.
POST /api/auth/signup- User registrationPOST /api/auth/signin- User loginPOST /api/auth/logout- User logoutGET /api/auth/me- Get current user
GET /api/user- Get user dataGET /api/user/profile- Get user profilePUT /api/user/profile- Update profile
GET /api/balance- Get user balancePOST /api/deposit- Record depositPOST /api/withdraw- Request withdrawalPOST /api/wallet/create- Create new walletPOST /api/wallet/regenerate- Regenerate walletPOST /api/wallet/deposit- Process deposit
POST /api/unlock-assistant- Unlock AI assistant (0.4 SOL)POST /api/bets- Place betPOST /api/tokens/purchase- Buy tokensPOST /api/chat- Send chat message
GET /broadcaster- Connect as broadcasterGET /viewer- Connect as viewerGET /chat- Join chat roomGET /quiz-broadcaster- Host quizGET /quiz-viewer- Join quiz as participant
GET /api/deposit- Get treasury addressPOST /api/deposit- Verify deposit transactionPOST /api/withdraw- Process withdrawalPOST /api/unlock-assistant- Charge for AI unlock
components/live-broadcast.tsx- Live video viewercomponents/video-broadcaster.tsx- Broadcasting interfacecomponents/quiz-broadcaster.tsx- Quiz hostingcomponents/quiz-panel.tsx- Quiz participation UIcomponents/betting-panel.tsx- Betting interfacecomponents/chat-widget.tsx- Chat UIcomponents/solana-deposit-card.tsx- Crypto deposit widgetcomponents/wallet-deposit-panel.tsx- Wallet management
pkg/ChatHub.go- Chat WebSocket hubpkg/QuizHub.go- Quiz WebSocket hubpkg/FeedForwarder.go- Video broadcast hubpkg/ai_client.go- AI service integrationpkg/solana_wallet.go- Blockchain wallet operationspkg/Questions.go- Quiz question management
app.py- Main video segmentation scriptmain.py- FastAPI server (if used)verify_stream.py- Stream verificationclient.py- Client utilities
cd backend/server
go test ./...cd frontend
npm test- Set up Devnet (for testing)
# Edit app/providers.tsx
const endpoint = "https://api.devnet.solana.com";
# Get devnet SOL
solana airdrop 2 <your_wallet_address> --url devnet-
Test Deposit Flow
- Connect Phantom wallet
- Switch to devnet in Phantom
- Send test transaction
- Verify backend logs
-
Test Unlock Assistant
- Ensure sufficient balance
- Click unlock button
- Verify 0.4 SOL deduction
See QUICKSTART.md for full testing checklist.
{
_id: ObjectId,
email: string,
passwordHash: string,
name: string,
balance: number, // SOL balance
assistant_unlocked_at: Date,
assistant_purchases: number,
created_at: Date,
updated_at: Date
}{
_id: ObjectId,
userId: ObjectId,
signature: string, // Unique Solana tx signature
walletAddress: string,
amount: number,
status: string, // "completed", "pending"
createdAt: Date
}{
_id: ObjectId,
userId: ObjectId,
amount: number,
walletAddress: string,
signature: string,
status: string, // "pending", "completed", "failed"
createdAt: Date
}MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/
MONGODB_DB=medmarket
SOL_RECEIVER_ADDRESS=<treasury_public_key>
SOL_TREASURY_SECRET_KEY=[secret_key_array]
SOLANA_RPC=https://api.mainnet-beta.solana.com
AI_SERVICE_URL=http://localhost:8000NEXT_PUBLIC_SOL_RECEIVER=<your_solana_wallet_address>
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/
MONGODB_DB=medmarketAdditional documentation files:
- QUICKSTART.md - Get started in 3 steps
- SOLANA_SETUP.md - Complete Solana setup guide
- SOLANA_INTEGRATION.md - Integration details
- SOLANA_STATUS.md - Current implementation status
- SOLANA_WALLET_SETUP.md - Wallet configuration
- PER_USER_WALLET_GUIDE.md - User wallet management
- API_INTEGRATION.md - Backend API details
- backend/ai_service/README.md - AI service docs
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes
- Test thoroughly
- Run Go tests
- Run frontend builds
- Test on devnet before mainnet
- Commit with clear messages
git commit -m "Add amazing feature" - Push to your fork
git push origin feature/amazing-feature
- Open a Pull Request
- Go: Follow standard Go conventions, use
gofmt - TypeScript/React: ESLint configuration included
- Python: PEP 8 style guide
"Please connect your wallet first"
- Install Phantom wallet extension
- Create or import wallet
- Ensure wallet is unlocked
"Transaction not confirmed yet"
- Normal behavior - Solana takes 5-10 seconds
- Check Solana Explorer for transaction status
"Verification failed"
- Ensure backend is running on port 8080
- Check CORS configuration
- Verify environment variables
Build errors in Next.js
rm -rf .next
npm run devMongoDB connection failed
- Verify MONGODB_URI in .env
- Check MongoDB Atlas IP whitelist
- Ensure database user has correct permissions
WebSocket connection failed
- Check backend is running
- Verify port 8080 is accessible
- Check firewall settings
- Solana Foundation - Blockchain infrastructure
- Ultralytics - SAM3 AI model
- MongoDB - Database platform
- Next.js Team - Frontend framework
- Go Community - Backend tools and libraries