A professional, production-ready QR Code URL redirector with comprehensive admin panel, analytics, and privacy-first tracking.
Secure admin login with optional 2FA authentication
- QR Code Generation: Automatic PNG & SVG generation with custom styling
- Smart URL Redirection: Fast, reliable redirects with fallback handling
- Responsive Admin Panel: Beautiful, mobile-friendly web interface
- Flexible Database Support: Choose between JSON file storage or MariaDB/MySQL
- Privacy-First Tracking: GDPR-compliant analytics with SHA256 hashing
- Smart Duplicate Detection: Intelligent repeat visitor identification
- Comprehensive Statistics: Daily/weekly/monthly analytics dashboard
- Click Heatmaps: Detailed visitor behavior analysis
- Multi-Layer Authentication: Secure admin login with optional 2FA
- Email-Based 2FA: Two-factor authentication via SMTP
- Session Security: Secure session handling with configurable timeouts
- Password Protection: Industry-standard PBKDF2 hashing
- Debug Mode: Comprehensive development logging with colored output
- Auto-Restart: Development server with automatic restart capabilities
- Environment Config: Flexible configuration via environment variables
- Error Handling: Detailed error tracking and reporting
- Node.js 16 or higher
- npm or yarn package manager
- MariaDB/MySQL (optional, falls back to JSON storage)
-
Clone the repository
git clone https://github.com/ghiemer/qr-redirector.git cd qr-redirector
-
Install dependencies
npm install
-
Configure environment
cp .env.example .env # Edit .env with your configuration
-
Set up admin user
# Generate admin password hash npm run hash-admin your-secure-password # Copy the hash to your database or environment
-
Start the application
# Development mode (with debug logging) npm run dev # Production mode npm start
# Build and run with Docker
docker build -t qr-redirector .
docker run -p 3000:3000 --env-file .env qr-redirector
Variable | Description | Default | Required |
---|---|---|---|
PORT |
Server port | 3000 |
No |
HOST_URL |
Public URL of your application | http://localhost:3000 |
Yes |
SESSION_SECRET |
Session encryption key | - | Yes |
ADMIN_EMAIL |
Admin user email | - | Yes |
ADMIN_PASSWORD_HASH |
Hashed admin password | - | Yes |
TWO_FACTOR_ENABLED |
Enable 2FA authentication | true |
No |
SMTP_HOST |
Email server host | - | If 2FA enabled |
SMTP_PORT |
Email server port | 587 |
If 2FA enabled |
SMTP_USER |
Email username | - | If 2FA enabled |
SMTP_PASS |
Email password | - | If 2FA enabled |
DB_TYPE |
Database type (mariadb or simple ) |
simple |
No |
DB_HOST |
Database host | localhost |
If MariaDB |
DB_PORT |
Database port | 3306 |
If MariaDB |
DB_NAME |
Database name | - | If MariaDB |
DB_USER |
Database username | - | If MariaDB |
DB_PASS |
Database password | - | If MariaDB |
No additional setup required. Data is stored in JSON files in the data/
directory.
-
Create database and user:
CREATE DATABASE qr_redirector; CREATE USER 'qr_user'@'localhost' IDENTIFIED BY 'your_secure_password'; GRANT ALL PRIVILEGES ON qr_redirector.* TO 'qr_user'@'localhost';
-
Import schema:
mysql -u qr_user -p qr_redirector < schema-mariadb.sql
- Access the admin panel at
/admin
- Log in with your credentials
- Click "New Route" to create a QR code
- Enter your target URL and optional custom alias
- Download generated QR codes (PNG/SVG formats)
- Dashboard: Overview of all routes and analytics
- Route Management: Create, edit, and delete redirects
- Analytics: Detailed click statistics and visitor data
- Settings: Configure application preferences
- Logs: Monitor application activity
GET /:alias
- Redirect to target URLGET /admin
- Admin dashboard (requires authentication)POST /admin/login
- Admin authenticationGET /debug/login
- Debug endpoint (development only)
- Runtime: Node.js 16+
- Framework: Express.js
- Database: JSON files or MariaDB/MySQL
- Templates: EJS templating engine
- Styling: Modern CSS with responsive design
- Authentication: Session-based with optional 2FA
- Security: PBKDF2 password hashing, SHA256 tracking anonymization
- QR Generation: Built-in QR code generation with PNG/SVG output
qr-redirector/
βββ app.js # Main application file
βββ package.json # Dependencies and scripts
βββ schema-mariadb.sql # Database schema
βββ controllers/ # Route controllers
βββ lib/ # Core libraries
βββ services/ # Business logic
βββ views/ # EJS templates
βββ public/ # Static assets
βββ data/ # JSON storage (if using file DB)
npm start
- Start production servernpm run dev
- Start development server with debug loggingnpm run hash-admin <password>
- Generate admin password hashnpm test
- Run test suite (if available)
Enable detailed logging by setting DEBUG=true
in your environment:
DEBUG=true npm run dev
This provides colored console output with detailed information about:
- HTTP requests and responses
- Database operations
- Authentication attempts
- Session management
- Error details
- Set
NODE_ENV=production
- Configure secure
SESSION_SECRET
- Set up proper database (MariaDB recommended for production)
- Configure HTTPS in reverse proxy
- Set strong admin password
- Configure SMTP for 2FA (recommended)
- Set appropriate file permissions
- Configure log rotation
- Shared Hosting: Compatible with Plesk and cPanel
- VPS/Dedicated: Full control over Node.js environment
- Cloud Platforms: Deploy to Heroku, DigitalOcean, AWS, etc.
- Docker: Containerized deployment ready
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Follow existing code style
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
GDPR/DSGVO Compliance: While this software implements privacy-first tracking with SHA256 hashing and pseudonymization features, no guarantee or warranty is provided regarding GDPR/DSGVO compliance. Users are responsible for ensuring their specific use case and configuration meets all applicable legal requirements.
No Legal Advice: This software and its documentation do not constitute legal advice. For specific legal requirements regarding data protection, privacy laws, or regulatory compliance, please consult with qualified legal professionals.
Use at Your Own Risk: The software is provided "as is" without warranty of any kind. Users assume full responsibility for compliance with all applicable laws and regulations in their jurisdiction.
- QR code generation powered by community libraries
- Icons and styling inspired by modern design principles
- Security best practices following OWASP guidelines
- Issues: GitHub Issues
- Documentation: Check the
docs/
directory for detailed guides - Community: Join discussions in GitHub Discussions
Made with β€οΈ for the open source community