Skip to content

Modern e-commerce platform with WhatsApp & Telegram bot integration, dynamic QRIS payment, and automated notifications.

License

Notifications You must be signed in to change notification settings

raistech/rsastore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ RSA Store - E-Commerce Platform with Bot Integration

Modern e-commerce platform with WhatsApp & Telegram bot integration, dynamic QRIS payment, and automated notifications.

Node.js License Status


✨ Features

πŸ›’ E-Commerce Core

  • Product Management - Categories, variants, stock tracking
  • Shopping Cart - Session-based cart system
  • Order Processing - Invoice generation, order tracking
  • Admin Panel - Complete dashboard for store management
  • Blog System - Built-in CMS for content marketing
  • SEO Optimized - Meta tags, sitemap, structured data

πŸ’³ Payment System

  • Dynamic QRIS - Real-time QR code generation with unique amounts
  • Payment Webhook - Auto-detect payment completion
  • Multiple Payment Methods - Ready for expansion
  • Automated Invoicing - Email & WhatsApp notifications

πŸ€– Bot Integration (Multi-Channel Sales)

  • WhatsApp Bot - Browse, search, checkout via WhatsApp
  • Telegram Bot - Interactive inline keyboard interface
  • QRIS Direct Sending - QR code sent directly in chat
  • 24/7 Automation - Auto-response, order tracking
  • Payment Notifications - Instant WhatsApp alerts on successful payment

πŸ“§ Notification System

  • Email Notifications - SMTP integration (Gmail, SendGrid, etc.)
  • WhatsApp Notifications - Auto-send on payment success
  • Admin Alerts - New order, low stock notifications
  • Customer Engagement - Order updates, download links

πŸ”’ Security & Performance

  • Rate Limiting - DDoS protection, API throttling
  • CSRF Protection - Secure forms and AJAX requests
  • IP Whitelist - Admin access control
  • Session Management - Secure encrypted sessions
  • Input Sanitization - SQL injection & XSS prevention
  • PM2 Process Management - Auto-restart, monitoring, clustering

πŸš€ Quick Start

Prerequisites

  • Node.js v16+ and npm
  • Python 3.8+ (for QRIS service)
  • PM2 (for production deployment)
  • SQLite3 (included)
  • Chromium (for WhatsApp bot)

Installation

  1. Clone the repository

    git clone https://github.com/raistech/rsastore.git
    cd rsastore
  2. Install Node.js dependencies

    npm install
  3. Install Python dependencies

    pip3 install -r requirements.txt
  4. Configure environment

    cp .env.example .env
    nano .env  # Edit with your configuration
  5. Initialize database

    node database.js
  6. Create uploads directory

    mkdir -p uploads/products
    mkdir -p uploads/blog
    mkdir -p logs
  7. Start development server

    # Development mode
    npm start
    
    # Production mode with PM2
    pm2 start ecosystem.config.js
    pm2 save
  8. Access the application


πŸ“‹ Configuration Guide

1. Basic Configuration

Edit .env file with your settings:

PORT=3000
NODE_ENV=production
BASE_URL=http://yourdomain.com
SESSION_SECRET=generate-random-string-here

Generate secure secrets:

# For SESSION_SECRET
openssl rand -base64 32

# For WEBHOOK_API_KEY
openssl rand -hex 32

2. Email Configuration (SMTP)

For Gmail:

SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password  # Not your regular password!

How to get Gmail App Password:

  1. Go to Google Account Settings
  2. Security β†’ 2-Step Verification (enable if not enabled)
  3. App passwords β†’ Generate new
  4. Copy the 16-character password

For SendGrid:

SMTP_HOST=smtp.sendgrid.net
SMTP_PORT=587
SMTP_USER=apikey
SMTP_PASS=your-sendgrid-api-key

3. QRIS Payment Configuration

Get QRIS Base String from your payment provider:

  • Bank Indonesia
  • DANA
  • OVO
  • GoPay
  • LinkAja
  • Or any QRIS-supporting provider
QRIS_BASE_STRING=00020101021126680016COM.NOBU...
QRIS_SERVICE_URL=http://localhost:3001

4. WhatsApp Bot Setup

Install Chromium (required):

# Ubuntu/Debian
sudo apt update && sudo apt install -y chromium-browser

# Or use snap
sudo snap install chromium

Enable in Admin Panel:

  1. Login to admin panel
  2. Go to Bot Settings
  3. Enable WhatsApp Bot
  4. Scan QR code with WhatsApp app
  5. Done! Bot is now active

5. Telegram Bot Setup

Get Bot Token:

  1. Open Telegram, search @BotFather
  2. Send /newbot command
  3. Follow instructions
  4. Copy the token

Configure:

TELEGRAM_BOT_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz

Or configure via Admin Panel β†’ Bot Settings


πŸ—οΈ Architecture

System Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           RSA Store Platform                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                       β”‚
   Main Server           QRIS Service
   (Node.js)             (Python)
   Port 3000             Port 3001
        β”‚                       β”‚
        β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
        β”‚                       β”‚
   Bot Services          Database
        β”‚                 (SQLite)
    β”Œβ”€β”€β”€β”΄β”€β”€β”€β”€β”
    β”‚        β”‚
WhatsApp  Telegram
  Bot       Bot
Port 3002  Built-in

Tech Stack

Backend:

  • Node.js + Express.js
  • SQLite3 (database)
  • Python (QRIS service)
  • PM2 (process manager)

Bots:

  • whatsapp-web.js (WhatsApp)
  • node-telegram-bot-api (Telegram)

Frontend:

  • EJS (templating)
  • Vanilla JavaScript
  • CSS3

Libraries:

  • axios (HTTP client)
  • qrcode (QR generation)
  • nodemailer (email)
  • express-rate-limit (security)
  • winston (logging)

πŸ“ Project Structure

rsastore/
β”œβ”€β”€ server.js                 # Main server entry point
β”œβ”€β”€ database.js               # Database schema & initialization
β”œβ”€β”€ ecosystem.config.js       # PM2 process configuration
β”œβ”€β”€ package.json             # Node.js dependencies
β”œβ”€β”€ requirements.txt         # Python dependencies
β”‚
β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ routes-admin.js      # Admin panel routes
β”‚   β”œβ”€β”€ routes-products.js   # Product & shop routes
β”‚   └── routes-blog.js       # Blog/CMS routes
β”‚
β”œβ”€β”€ bot-whatsapp.js          # WhatsApp bot implementation
β”œβ”€β”€ bot-telegram.js          # Telegram bot implementation
β”œβ”€β”€ bot-controller.js        # Shared bot logic
β”‚
β”œβ”€β”€ qris-service.py          # QRIS QR code generator
β”‚
β”œβ”€β”€ auth.js                  # Authentication middleware
β”œβ”€β”€ email.js                 # Email service
β”œβ”€β”€ logger.js                # Winston logger configuration
β”œβ”€β”€ sanitize.js              # Input sanitization
β”œβ”€β”€ utils.js                 # Utility functions
β”‚
β”œβ”€β”€ views/                   # EJS templates
β”‚   β”œβ”€β”€ partials/           # Reusable components
β”‚   β”œβ”€β”€ admin/              # Admin panel views
β”‚   β”œβ”€β”€ shop/               # Shop pages
β”‚   └── blog/               # Blog pages
β”‚
β”œβ”€β”€ public/                  # Static assets
β”‚   β”œβ”€β”€ css/
β”‚   β”œβ”€β”€ js/
β”‚   └── images/
β”‚
β”œβ”€β”€ uploads/                 # User uploaded files
β”‚   β”œβ”€β”€ products/           # Product images & files
β”‚   └── blog/               # Blog images
β”‚
β”œβ”€β”€ logs/                    # Application logs
β”‚
β”œβ”€β”€ docs/                    # Documentation
β”‚   β”œβ”€β”€ BOT_SETUP.md
β”‚   β”œβ”€β”€ WHATSAPP_NOTIFICATION.md
β”‚   └── PM2_MANAGEMENT.md
β”‚
└── .env                     # Environment configuration (not in repo)

πŸ”§ PM2 Process Management

Start All Services

pm2 start ecosystem.config.js
pm2 save
pm2 startup

View Status

pm2 list
pm2 monit

View Logs

# All logs
pm2 logs

# Specific service
pm2 logs rsastore-main
pm2 logs rsastore-whatsapp-bot
pm2 logs rsastore-telegram-bot

Restart Services

# Restart all
pm2 restart ecosystem.config.js

# Restart specific
pm2 restart rsastore-main

Stop Services

pm2 stop ecosystem.config.js
pm2 delete ecosystem.config.js

πŸ§ͺ Testing

Test Email Configuration

node -e "
const {sendTestEmail} = require('./email');
sendTestEmail('your-email@gmail.com')
  .then(() => console.log('βœ… Email sent!'))
  .catch(err => console.error('❌ Error:', err));
"

Test QRIS Service

curl -X POST http://localhost:3001/generate-qris \
  -H "Content-Type: application/json" \
  -d '{"base_string":"YOUR_BASE_STRING","amount":50000}'

Test WhatsApp Bot

Admin Panel β†’ Bot Settings β†’ Test WhatsApp Notification

Test Payment Webhook

curl -X POST http://localhost:3000/webhook/payment \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-webhook-key" \
  -d '{"amountDetected":50123}'

πŸ“± Bot Usage Guide

WhatsApp Bot Commands

menu          - Show main menu
1             - View catalog
2             - Search products
3             - Check order
4             - Help

Customer Flow:

  1. Customer sends "menu" to WhatsApp
  2. Bot shows product catalog
  3. Customer browses and selects product
  4. Bot sends QRIS QR code in chat
  5. Customer scans and pays
  6. Auto-notification on payment success

Telegram Bot

All interactions via inline keyboard buttons:

  • πŸ›οΈ View Catalog
  • πŸ” Search Products
  • πŸ“¦ Check Order
  • ❓ Help

πŸ” Security Best Practices

Production Checklist

  • [βœ…] Change default admin password
  • [βœ…] Use strong SESSION_SECRET
  • [βœ…] Enable HTTPS/SSL
  • [βœ…] Configure firewall (UFW/iptables)
  • [βœ…] Set up rate limiting
  • [βœ…] Enable CSRF protection
  • [βœ…] Regular database backups
  • [βœ…] Keep dependencies updated
  • [βœ…] Monitor logs regularly
  • [βœ…] Use environment variables (never hardcode secrets)

Backup Strategy

# Database backup
cp rsastore.db rsastore.db.backup-$(date +%Y%m%d)

# Full backup
tar -czf rsastore-backup-$(date +%Y%m%d).tar.gz \
  --exclude='node_modules' \
  --exclude='whatsapp-session' \
  --exclude='logs' \
  .

πŸ› Troubleshooting

Common Issues

1. Port already in use

# Find process using port
lsof -ti:3000
# Kill process
kill -9 $(lsof -ti:3000)

2. WhatsApp bot not connecting

# Check chromium installation
which chromium-browser
# Install if missing
sudo apt install chromium-browser
# Restart bot
pm2 restart rsastore-whatsapp-bot

3. Email not sending

  • Check SMTP credentials
  • Verify app password (not regular password)
  • Check firewall allows SMTP port (587/465)
  • Test with npm run test-email

4. QRIS not generating

# Check Python service
pm2 logs rsastore-qris
# Restart service
pm2 restart rsastore-qris

5. Database locked

# Check for processes using database
lsof rsastore.db
# Restart application
pm2 restart rsastore-main

Logs Location

logs/main-out.log           # Main server output
logs/main-error.log         # Main server errors
logs/qris-out.log          # QRIS service
logs/whatsapp-bot-out.log  # WhatsApp bot
logs/telegram-bot-out.log  # Telegram bot

πŸ“Š Performance Optimization

Production Tips

  1. Enable PM2 Cluster Mode

    // ecosystem.config.js
    instances: 'max',
    exec_mode: 'cluster'
  2. Database Optimization

    node create-indexes.js
  3. Enable Compression

    const compression = require('compression');
    app.use(compression());
  4. CDN for Static Assets

    • Use Cloudflare, AWS CloudFront, or similar
    • Offload images, CSS, JS
  5. Monitor Performance

    pm2 monit
    pm2 install pm2-logrotate

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

Development Guidelines

  • Follow existing code style
  • Write meaningful commit messages
  • Test before submitting PR
  • Update documentation if needed

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.


πŸ‘¨β€πŸ’» Author

RSA Store Team


πŸ™ Acknowledgments

  • whatsapp-web.js - WhatsApp bot library
  • node-telegram-bot-api - Telegram bot library
  • Express.js - Web framework
  • PM2 - Process management

πŸ“ž Support

  • Documentation: Check docs/ folder
  • Issues: Open GitHub issue
  • Email: support@araii.id

πŸ“ˆ Changelog

v2.0.0 (2025-11-08)

  • ✨ Added WhatsApp bot integration
  • ✨ Added Telegram bot integration
  • ✨ Added QRIS direct sending in chat
  • ✨ Added payment notification system
  • ✨ Added bot test feature with HTTP API
  • πŸ› Fixed category delete bug
  • πŸ› Fixed markdown parsing in Telegram
  • πŸ“š Comprehensive documentation

v1.0.0 (2025-11-07)

  • πŸŽ‰ Initial release
  • ✨ E-commerce core features
  • ✨ QRIS payment integration
  • ✨ Admin panel
  • ✨ Email notifications

Made with ❀️ for modern e-commerce

About

Modern e-commerce platform with WhatsApp & Telegram bot integration, dynamic QRIS payment, and automated notifications.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published