A modern, AI-powered payment soundbox application built with Next.js frontend and Express.js backend. This system provides dynamic QR code generation, real-time payment processing, and Text-to-Speech (TTS) announcements for payment confirmations.
- Modern UI: Beautiful, responsive interface with dark theme
- QR Code Generation: Dynamic QR codes for payment transactions
- Real-time Updates: Live payment status updates via WebSocket
- TTS Integration: Browser-based Text-to-Speech announcements
- Payment Dashboard: Analytics and transaction history
- Payment Status Display: Real-time payment status monitoring
- RESTful API: Complete payment management system
- WebSocket Support: Real-time communication with frontend
- SQLite Database: Persistent storage for payments and logs
- QR Code Generation: Server-side QR code creation
- TTS Integration: Text-to-Speech announcement system
- Payment Analytics: Comprehensive reporting and analytics
- Webhook Simulation: Payment confirmation simulation
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Frontend โ โ Backend โ โ Database โ
โ (Next.js) โโโโโบโ (Express.js) โโโโโบโ (SQLite) โ
โ โ โ โ โ โ
โ โข React UI โ โ โข REST API โ โ โข Payments โ
โ โข WebSocket โ โ โข WebSocket โ โ โข Logs โ
โ โข TTS Client โ โ โข QR Generation โ โ โข TTS History โ
โ โข State Mgmt โ โ โข TTS Server โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
- Next.js 16 - React framework
- TypeScript - Type safety
- Tailwind CSS - Styling
- Radix UI - Component library
- WebSocket - Real-time communication
- Web Speech API - Text-to-Speech
- Express.js - Web framework
- Node.js - Runtime environment
- SQLite3 - Database
- WebSocket - Real-time communication
- QRCode - QR code generation
- CORS - Cross-origin resource sharing
- Node.js 18+
- npm or pnpm
- Clone the repository
git clone <repository-url>
cd payment-soundbox- Install dependencies
npm install
# or
pnpm install- Start the development servers
Terminal 1 - Backend Server:
npm run dev:serverTerminal 2 - Frontend Server:
npm run dev- Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- Health Check: http://localhost:3001/api/health
- Open the frontend application
- Navigate to the QR Code Generator
- Enter customer name and amount
- Click "Generate QR Code"
- Use the backend integration example
- Click "Create Payment" to generate a test payment
- Click "Confirm" to simulate payment confirmation
- Listen for the TTS announcement
- Click "Test TTS" to trigger a test announcement
- Use "Simulate Payment" for a complete payment flow with TTS
GET /api/payments- Get all paymentsPOST /api/payments- Create new paymentGET /api/payments/:id- Get payment by IDPOST /api/payments/:id/confirm- Confirm paymentPOST /api/payments/:id/fail- Mark payment as failedGET /api/payments/analytics/summary- Get analytics
POST /api/qr/generate- Generate QR codePOST /api/qr/scan- Scan QR codePOST /api/qr/validate- Validate QR codeGET /api/qr/info/:paymentId- Get QR info
POST /api/tts/announce- Trigger TTS announcementPOST /api/tts/test- Test TTS functionalityPOST /api/tts/simulate-payment- Simulate payment with TTSGET /api/tts/status- Get TTS system status
GET /api/health- Server health check
The system broadcasts real-time events:
payment_created- New payment createdpayment_confirmed- Payment confirmedpayment_failed- Payment failedqr_generated- QR code generatedqr_scanned- QR code scannedtts_announcement- TTS announcement triggeredtts_status_update- TTS status updated
# Test the backend API
npm run test:api- Start both servers
- Open the frontend application
- Use the "Backend Integration Example" component
- Test payment creation, confirmation, and TTS
CREATE TABLE payments (
id TEXT PRIMARY KEY,
payer_name TEXT NOT NULL,
amount REAL NOT NULL,
status TEXT NOT NULL DEFAULT 'pending',
qr_code_data TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
confirmed_at DATETIME,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);CREATE TABLE payment_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
payment_id TEXT NOT NULL,
action TEXT NOT NULL,
details TEXT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (payment_id) REFERENCES payments (id)
);CREATE TABLE tts_announcements (
id INTEGER PRIMARY KEY AUTOINCREMENT,
payment_id TEXT NOT NULL,
message TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'pending',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
played_at DATETIME,
FOREIGN KEY (payment_id) REFERENCES payments (id)
);import { api, PaymentSoundboxWebSocket } from '@/lib/api'
// Create a payment
const payment = await api.createPayment('John Doe', 25.50)
// Confirm payment
await api.confirmPayment(payment.id, 'John Doe', 25.50)
// WebSocket connection
const ws = new PaymentSoundboxWebSocket()
ws.onMessage((data) => {
if (data.type === 'payment_confirmed') {
// Handle payment confirmation
}
})# Create payment
curl -X POST http://localhost:3001/api/payments \
-H "Content-Type: application/json" \
-d '{"payerName": "John Doe", "amount": 25.50}'
# Confirm payment
curl -X POST http://localhost:3001/api/payments/PAY-123/confirm \
-H "Content-Type: application/json" \
-d '{"payerName": "John Doe", "amount": 25.50}'
# Test TTS
curl -X POST http://localhost:3001/api/tts/test \
-H "Content-Type: application/json" \
-d '{"message": "Test announcement"}'PORT- Backend server port (default: 3001)NODE_ENV- Environment (development/production)CORS_ORIGIN- CORS origin for frontendTTS_ENABLED- Enable/disable TTS functionality
NEXT_PUBLIC_API_URL- Backend API URL- WebSocket URL:
ws://localhost:3001
# Build frontend
npm run build
# Start production server
npm run start# Backend Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY server/ ./server/
EXPOSE 3001
CMD ["npm", "run", "server"]- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
For support and questions:
- Check the documentation
- Review the API endpoints
- Test with the provided examples
- Check server logs for errors
- Real payment gateway integration
- Advanced TTS voice selection
- Payment analytics dashboard
- Mobile app support
- Multi-language support
- Payment receipt generation
- Advanced security features
- Payment history export
- Real-time notifications
- Payment scheduling
Built with โค๏ธ for modern payment processing