Skip to content

About

Open-source QR code screenshot decoder web application built with Next.js, Express, and Docker. Free self-hosted version with rate limiting.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

QRdecode.AI πŸ”

A modern, open-source QR code scanning and management application built with Next.js, Express, and TypeScript. Perfect for developers who want to learn full-stack development or need a starting point for their own QR code projects.

QR Code Scanning Demo

License Docker TypeScript

✨ Features

Core Features

  • πŸ“± Scan QR codes using your device camera
  • πŸ“€ Upload QR code images for scanning
  • πŸ“Š View scan history and statistics
  • πŸ”’ User authentication and authorization
  • ⚑ Rate limiting to prevent abuse
  • πŸ“± Responsive design for all devices

Technical Features

  • πŸ”„ Real-time updates using React
  • 🎨 Modern UI with Tailwind CSS
  • πŸš€ Server-side rendering with Next.js
  • πŸ” TypeScript for better code quality
  • πŸ“ Comprehensive API documentation
  • βœ… Extensive test coverage

πŸš€ Quick Start with Docker

The easiest way to get started is using Docker. Make sure you have Docker and Docker Compose installed.

1. Clone the Repository

git clone https://github.com/msdevsec/qrdecode.ai.git
cd qrdecode.ai

2. Set Up Environment Variables

# Copy environment files
cp .env.example .env
cp frontend/.env.example frontend/.env.local
cp backend/.env.example backend/.env

3. Start the Application

# Build and start all services
docker-compose up -d
# start Prisma and apply migration in docker
docker-compose exec backend npx prisma migrate dev

# The following services will be available:
# - Frontend: http://localhost:3000
# - Backend API: http://localhost:4000
# - API Documentation: http://localhost:4000/api-docs

That's it! The application should now be running. πŸŽ‰

Docker Commands Quick Reference

# Start all services
docker-compose up -d

# Stop all services
docker-compose down

# View logs
docker-compose logs -f

# Rebuild services
docker-compose up -d --build

# Remove all containers and volumes
docker-compose down -v

πŸ› οΈ Manual Setup (Without Docker)

If you prefer to run the services directly on your machine:

Prerequisites

  • Node.js 18+
  • PostgreSQL 15+
  • Redis 7+

Backend Setup

cd backend
npm install
npm run prisma:migrate
npm run dev

Frontend Setup

cd frontend
npm install
npm run dev

πŸ“ Project Structure

.
β”œβ”€β”€ frontend/                 # Next.js frontend application
β”‚   β”œβ”€β”€ app/                 # App router pages
β”‚   β”œβ”€β”€ components/          # React components
β”‚   β”œβ”€β”€ context/            # React context providers
β”‚   └── public/             # Static assets
β”‚
β”œβ”€β”€ backend/                 # Express.js backend application
β”‚   β”œβ”€β”€ src/                # Source code
β”‚   β”‚   β”œβ”€β”€ controllers/    # Route controllers
β”‚   β”‚   β”œβ”€β”€ middleware/     # Express middleware
β”‚   β”‚   β”œβ”€β”€ routes/         # API routes
β”‚   β”‚   └── utils/          # Utility functions
β”‚   └── prisma/             # Database schema and migrations
β”‚
└── docker/                 # Docker configuration files

πŸ”§ Configuration

Environment Variables

Backend (.env)

  • PORT: API server port (default: 4000)
  • DATABASE_URL: PostgreSQL connection string
  • REDIS_URL: Redis connection string
  • JWT_SECRET: Secret for JWT tokens
  • RATE_LIMIT_MAX_REQUESTS: Max requests per window (default: 5)

Frontend (.env.local)

  • NEXT_PUBLIC_API_URL: Backend API URL
  • NEXT_PUBLIC_APP_NAME: Application name
  • NEXT_PUBLIC_FREE_TIER_LIMIT: Free tier scan limit

πŸ§ͺ Testing

We use Jest for testing. All tests are in the __test__ directories.

# Run backend tests
cd backend
npm test

# Run frontend tests
cd frontend
npm test

πŸ“š API Documentation

API documentation is available at http://localhost:4000/api-docs when running the development server. It includes:

  • All available endpoints
  • Request/response schemas
  • Authentication requirements
  • Error codes and messages

πŸ”’ Security Features

  • JWT authentication
  • Rate limiting
  • Input validation
  • CORS protection
  • Error sanitization
  • TypeScript type safety

🀝 Contributing

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

πŸ“ License

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

πŸ™ Acknowledgments

  • QR code scanning powered by jsQR
  • UI components inspired by Tailwind UI
  • Icons from Heroicons

πŸ€” Common Issues & Solutions

Docker Issues

  1. Ports already in use

    # Check what's using the port
    netstat -ano | findstr :3000
    netstat -ano | findstr :4000
  2. Database connection issues

    # Restart the database container
    docker-compose restart postgres
  3. Redis connection issues

    # Check Redis logs
    docker-compose logs redis

Development Issues

  1. TypeScript errors

    # Rebuild TypeScript
    npm run clean
    npm run build
  2. Prisma issues

    # Reset database and migrations
    npx prisma migrate reset
    npx prisma generate

πŸ“« Support

  • Create an issue for bug reports
  • Star the repository if you find it useful
  • Fork it if you want to contribute

πŸ’Ύ Database Persistence

The application uses Docker volumes to ensure data persistence. Here's what you need to know:

Data Storage

  • All database data is stored in the postgres_data Docker volume
  • Data persists across container restarts and rebuilds
  • Data remains intact when using docker-compose down

When Data is Lost

Data is only lost in these specific scenarios:

  1. Using docker-compose down -v (which removes volumes)
  2. Manually deleting the postgres_data volume
  3. Running docker volume rm on the postgres volume

Backup Recommendations

To prevent data loss, regularly:

  1. Use docker exec to create database backups
  2. Store backups outside the Docker environment
  3. Avoid using -v flag with docker-compose down unless necessary

Built with ❀️ by msdevsec

About

Open-source QR code screenshot decoder web application built with Next.js, Express, and Docker. Free self-hosted version with rate limiting.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages