Skip to content

Repository files navigation

QR Generator Web App

A modern, professional QR code generator built with Next.js 14, TypeScript, and Tailwind CSS. Generate high-quality QR codes for URLs, text, emails, phone numbers, SMS, and WiFi credentials with custom colors and multiple export formats.

QR Generator Preview

πŸš€ Features

Core Functionality

  • Multiple Data Types: URLs, plain text, email, phone, SMS, WiFi
  • 4 Generation Modes: Basic, Colored, SVG, High Quality
  • Multiple Formats: PNG, SVG, JPG, WebP with high-quality output
  • Custom Colors: Brand color matching with contrast validation
  • Error Correction: Adjustable levels for different use cases
  • Real-time Preview: Instant QR code generation with live updates

User Experience

  • Responsive Design: Works perfectly on desktop, tablet, and mobile
  • Privacy Focused: All processing happens locally - no data sent to servers
  • Fast & Reliable: Optimized for performance with error handling
  • Accessibility: Screen reader support and keyboard navigation
  • Progressive Web App: Installable with offline capabilities

Advanced Features

  • Batch Generation: Create multiple QR codes at once
  • Analytics Tracking: Usage analytics with privacy compliance
  • Error Recovery: Comprehensive error handling with retry mechanisms
  • Performance Monitoring: Built-in performance tracking
  • User Guide: Complete in-app documentation

πŸ› οΈ Tech Stack

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • QR Generation: QRCode.js library
  • Canvas Processing: HTML5 Canvas API
  • File Handling: File-saver for downloads
  • Deployment: Vercel (optimized)

πŸ“¦ Installation

Prerequisites

  • Node.js 18.0 or higher
  • npm or yarn package manager

Quick Start

  1. Clone the repository
git clone https://github.com/Ikrar06/qr-generator-web.git
cd qr-generator-web
  1. Install dependencies
npm install
# or
yarn install
  1. Set up environment variables
cp .env.example .env.local
  1. Run the development server
npm run dev
# or
yarn dev
  1. Open your browser Visit http://localhost:3000

Production Build

npm run build
npm start

πŸ“ Project Structure

qr-generator-web/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                    # Next.js app directory
β”‚   β”‚   β”œβ”€β”€ components/         # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ ui/            # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ ErrorBoundary.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ UserGuide.tsx
β”‚   β”‚   β”‚   └── LoadingSpinner.tsx
β”‚   β”‚   β”œβ”€β”€ api/               # API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ generate-qr/
β”‚   β”‚   β”‚   β”œβ”€β”€ health/
β”‚   β”‚   β”‚   └── analytics/
β”‚   β”‚   β”œβ”€β”€ globals.css        # Global styles
β”‚   β”‚   β”œβ”€β”€ layout.tsx         # Root layout
β”‚   β”‚   └── page.tsx           # Home page
β”‚   β”œβ”€β”€ components/            # Shared components
β”‚   β”œβ”€β”€ lib/                   # Utilities and core logic
β”‚   β”‚   β”œβ”€β”€ qr-generator.ts    # QR generation logic
β”‚   β”‚   β”œβ”€β”€ error-handling.ts  # Error management
β”‚   β”‚   β”œβ”€β”€ analytics.ts       # Analytics tracking
β”‚   β”‚   └── utils.ts           # Helper functions
β”‚   β”œβ”€β”€ hooks/                 # React hooks
β”‚   β”‚   └── useQRGenerator.ts  # QR generation hook
β”‚   └── types/                 # TypeScript definitions
β”‚       └── qr-types.ts        # QR-related types
β”œβ”€β”€ public/                    # Static assets
β”œβ”€β”€ docs/                      # Documentation
β”œβ”€β”€ generated-qr/              # Generated QR codes
└── downloads/                 # Download cache

🎯 Usage

Basic QR Generation

  1. Select Data Type: Choose from URL, Text, Email, Phone, SMS, or WiFi
  2. Enter Content: Input your data in the text field
  3. Choose Mode: Select Basic, Colored, SVG, or High Quality
  4. Customize: Adjust colors, size, and error correction
  5. Generate: Click "Generate QR Code"
  6. Download: Choose your preferred format and download

Advanced Options

Error Correction Levels

  • Low (7%): Maximum data capacity
  • Medium (15%): Balanced option (recommended)
  • Quartile (25%): Good for print materials
  • High (30%): Maximum damage resistance

Generation Modes

  • Basic: Standard black and white QR codes
  • Colored: Custom foreground and background colors
  • SVG: Vector format for infinite scalability
  • High Quality: Professional grade with maximum error correction

Output Formats

  • PNG: Best for web use with transparency support
  • SVG: Perfect for print and scalable graphics
  • JPG: Smallest file size for quick sharing
  • WebP: Modern format with superior compression

πŸ”§ Configuration

Environment Variables

# Application
NEXT_PUBLIC_BASE_URL=http://localhost:3000
NODE_ENV=development

# Analytics (optional)
NEXT_PUBLIC_GA_ID=G-XXXXXXXXXX
NEXT_PUBLIC_ANALYTICS_CONSENT=false

# Error Reporting (optional)
NEXT_PUBLIC_SENTRY_DSN=your_sentry_dsn

# Performance Monitoring
NEXT_PUBLIC_PERFORMANCE_MONITORING=true

Customization

Colors and Theming

Edit tailwind.config.js to customize the color palette:

module.exports = {
  theme: {
    extend: {
      colors: {
        primary: {
          50: '#eff6ff',
          500: '#3b82f6',
          600: '#2563eb',
          // ... more colors
        }
      }
    }
  }
}

QR Generator Settings

Modify src/lib/constants.ts for default settings:

export const QR_DEFAULTS = {
  width: 256,
  height: 256,
  margin: 2,
  errorCorrectionLevel: 'M',
  quality: 0.92
};

πŸ“Š Analytics & Monitoring

Built-in Analytics

  • QR generation tracking
  • Error monitoring
  • Performance metrics
  • User interaction analytics
  • GDPR-compliant data collection

Performance Monitoring

  • Page load times
  • Generation performance
  • Download success rates
  • Error rates and categorization

Privacy Features

  • Local processing only
  • No data collection without consent
  • GDPR compliance
  • Do Not Track respect

πŸ”’ Security

Data Privacy

  • Local Processing: All QR generation happens in the browser
  • No Server Storage: No user data stored on servers
  • HTTPS Only: Secure connections in production
  • Content Validation: Input sanitization and validation

Security Best Practices

  • Input validation and sanitization
  • XSS protection
  • CSRF protection
  • Secure headers configuration
  • Regular dependency updates

πŸš€ Deployment

Vercel (Recommended)

  1. Connect Repository
vercel
  1. Configure Environment Set environment variables in Vercel dashboard

  2. Deploy

vercel --prod

Docker

  1. Build Image
docker build -t qr-generator-web .
  1. Run Container
docker run -p 3000:3000 qr-generator-web

Static Export

npm run build
npm run export

πŸ§ͺ Testing

Running Tests

# Unit tests
npm run test

# Integration tests
npm run test:integration

# E2E tests
npm run test:e2e

# Coverage report
npm run test:coverage

Browser Testing

Test on multiple browsers and devices:

  • Chrome/Edge (Chromium-based)
  • Firefox
  • Safari (WebKit)
  • Mobile browsers (iOS Safari, Android Chrome)

πŸ› Troubleshooting

Common Issues

QR Code Won't Scan

  • Check color contrast (minimum 4.5:1 ratio)
  • Increase QR code size
  • Use higher error correction level
  • Ensure adequate quiet space

Download Fails

  • Check browser permissions
  • Try different format (PNG vs SVG)
  • Clear browser cache
  • Disable ad blockers temporarily

Performance Issues

  • Reduce QR code size
  • Use Basic mode instead of High Quality
  • Close other browser tabs
  • Update browser to latest version

Debug Mode

Enable debug logging:

localStorage.setItem('qr_debug', 'true');

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Run the test suite
  6. Submit a pull request

Code Standards

  • TypeScript strict mode
  • ESLint configuration
  • Prettier formatting
  • Conventional commits
  • Component testing

πŸ“ License

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

πŸ™ Acknowledgments

  • QRCode.js for QR generation
  • Next.js for the amazing framework
  • Tailwind CSS for styling
  • Vercel for hosting and deployment
  • The open-source community for inspiration and tools

πŸ“ž Support

Getting Help

Reporting Issues

When reporting issues, please include:

  • Browser and version
  • Operating system
  • Steps to reproduce
  • Expected vs actual behavior
  • Screenshots if applicable
  • Console error messages

Feature Requests

We love hearing about new feature ideas! Please check existing issues first and provide:

  • Clear use case description
  • Expected behavior
  • Any relevant examples or mockups

πŸ”„ Changelog

Version 1.0.0 (Current)

  • Initial release with core QR generation
  • Multiple data type support
  • Custom color options
  • Real-time preview
  • Multiple output formats
  • Error handling and recovery
  • Analytics and performance monitoring
  • Comprehensive user guide
  • PWA capabilities

Upcoming Features

  • QR code templates and presets
  • Batch processing improvements
  • Advanced customization options
  • Integration APIs
  • Enhanced accessibility features

πŸ“ˆ Performance

Benchmarks

  • Generation Time: < 100ms for standard QR codes
  • File Sizes:
    • PNG: 2-10KB typical
    • SVG: 1-5KB typical
    • WebP: 1-8KB typical
  • Browser Support: 95%+ modern browsers
  • Mobile Performance: Optimized for all devices

Optimization Features

  • Lazy loading for non-critical components
  • Image optimization and compression
  • Code splitting for faster initial loads
  • Service worker for offline functionality
  • Progressive enhancement

🌐 Browser Support

Browser Version Support Level
Chrome 88+ Full
Firefox 85+ Full
Safari 14+ Full
Edge 88+ Full
iOS Safari 14+ Full
Android Chrome 88+ Full
IE Not supported -

Feature Detection

The app includes progressive enhancement:

  • Core functionality works in all supported browsers
  • Advanced features degrade gracefully
  • Polyfills included for older browser support

πŸ”§ API Reference

QR Generation Hook

const {
  generate,
  download,
  state,
  progress,
  clear
} = useQRGenerator();

Methods

generate(request: QRGenerationRequest)

Generate a QR code with specified options.

const result = await generate({
  data: 'https://example.com',
  mode: QRMode.COLORED,
  options: {
    width: 256,
    height: 256,
    color: {
      dark: '#000000',
      light: '#ffffff'
    }
  }
});
download(response: QRGenerationResponse, options?: DownloadOptions)

Download generated QR code in specified format.

await download(response, {
  format: OutputFormat.PNG,
  filename: 'my-qr-code.png'
});

Error Handling

import { handleError } from '@/lib/error-handling';

try {
  // Your code here
} catch (error) {
  const processedError = await handleError(error, {
    component: 'QRGenerator',
    function: 'generate'
  });
}

Analytics Tracking

import { trackQRGeneration } from '@/lib/analytics';

trackQRGeneration({
  mode: 'colored',
  dataType: 'url',
  format: 'png',
  success: true
});

🎨 Customization Guide

Theme Customization

Modify the default theme in tailwind.config.js:

module.exports = {
  theme: {
    extend: {
      colors: {
        brand: {
          primary: '#your-color',
          secondary: '#your-color'
        }
      },
      fontFamily: {
        sans: ['Your Font', 'system-ui']
      }
    }
  }
}

Component Customization

Override default component styles:

/* In your custom CSS file */
.qr-generator-container {
  @apply your-custom-classes;
}

Adding Custom Data Types

Extend the QR generator with custom data types:

// In src/types/qr-types.ts
export enum QRDataType {
  // ... existing types
  CUSTOM = 'custom'
}

// Add validation logic in src/lib/validation.ts
// Add formatting logic in src/lib/qr-generator.ts

πŸ“± Mobile Optimization

Features

  • Touch-optimized interfaces
  • Responsive design for all screen sizes
  • Optimized file sizes for mobile networks
  • Offline functionality with service workers
  • Native app-like experience

PWA Installation

Users can install the app on mobile devices:

  1. Visit the website in a mobile browser
  2. Tap "Add to Home Screen" when prompted
  3. Access the app like a native application

πŸ” Security Considerations

Input Validation

All user inputs are validated and sanitized:

  • URL format validation
  • Email format checking
  • Phone number validation
  • Text length limits
  • Character encoding validation

Content Security Policy

The app implements strict CSP headers:

Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'

Data Privacy

  • No user data stored on servers
  • Local storage only for user preferences
  • Analytics data anonymized
  • GDPR compliance built-in

πŸ§ͺ Testing Strategy

Test Coverage

  • Unit tests for utility functions
  • Integration tests for QR generation
  • Component tests for UI elements
  • E2E tests for user workflows
  • Performance tests for optimization

Continuous Integration

# .github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
      - run: npm ci
      - run: npm run test
      - run: npm run build

πŸ“Š Monitoring and Analytics

Built-in Metrics

  • QR generation success rates
  • Popular data types and formats
  • User interaction patterns
  • Performance bottlenecks
  • Error rates and types

Privacy-First Analytics

  • No personal data collection
  • Opt-in analytics only
  • Anonymized metrics
  • GDPR compliant
  • Local data processing

πŸ€– Automation

GitHub Actions

  • Automated testing on PR
  • Dependency updates
  • Security scanning
  • Performance monitoring
  • Automated releases

Pre-commit Hooks

{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  }
}

Built with ❀️ using Next.js, TypeScript, and modern web technologies.

For more information, visit our website or check out the live demo.

About

A modern, professional QR code generator built with Next.js 14, TypeScript, and Tailwind CSS.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages