A full-stack, modern web application for generating and scanning QR codes.
- Generate 6 Formats: Easily generate QR codes for Links (URLs), Plain Text, Contacts (vCards), Phone Numbers, WiFi Networks, and Locations (Map).
- Scan & Decode: Upload any QR code image (PNG/JPEG) to instantly decode and copy its contents.
- Dynamic Theme: Flawless Light and Dark mode toggle that remembers your preference.
- Strict Validation: Robust frontend and backend validation ensures your QR codes are always generated correctly.
This project is separated into two distinct services to allow for better maintainability and scalability:
- 🌐
frontend/: The client-side interface built with - ⚙️
backend/: The REST API built withutilizing the
go-chirouter.
qrcode-genapp/
├── backend/ # Go REST API
│ ├── internal/
│ │ ├── api/
│ │ │ ├── handlers/ # Request handlers (generate, scan)
│ │ │ │ ├── generate.go
│ │ │ │ ├── helpers.go
│ │ │ │ └── scan.go
│ │ │ └── routes.go # API route definitions
│ │ └── models/ # Data structures and JSON schemas
│ │ └── models.go
│ ├── .env # Environment variables (e.g., PORT)
│ ├── go.mod # Go module dependencies
│ └── main.go # Entry point for the Go server
│
└── frontend/ # Vue 3 Client Application
├── public/ # Static assets
├── src/
│ ├── assets/ # CSS and styles (Tailwind import)
│ ├── components/ # Reusable Vue components
│ │ ├── forms/ # Dynamic form components (URL, Text, WiFi, etc.)
│ │ ├── ui/ # Reusable UI elements (Modals, etc.)
│ │ ├── GenerateTab.vue # QR generation UI & logic
│ │ └── ScanTab.vue # QR scanner UI & logic
│ ├── App.vue # Main layout and tab controller
│ └── main.js # Vue application entry point
├── .env # Environment variables (e.g., API Base URL)
├── package.json # Node dependencies
└── vite.config.js # Vite bundler configuration
To run this application locally on your machine, you need to start both the Go backend and the Vue frontend development servers.
The backend handles the core logic for encoding text into QR images and decoding uploaded QR images back into text.
Requirements: Go 1.20+
- Navigate to the backend directory:
cd backend - Install dependencies:
go mod download
- Configure environment variables:
- Create a
.envfile in thebackend/directory. - Add the desired port (default is 8080 if not provided):
PORT=8080
- Create a
- Run the server:
The server will start at
go run main.go
http://localhost:8080.
The frontend provides a sleek, dark-mode user interface with tabs for Generating and Scanning.
Requirements: Node.js and pnpm
- Navigate to the frontend directory:
cd frontend - Install dependencies:
pnpm install
- Configure environment variables:
- Create a
.envfile in thefrontend/directory. - Specify the local URL of your Go backend so the frontend knows where to send API requests:
VITE_API_BASE_URL=http://localhost:8080
- Create a
- Run the development server:
The application will be accessible at
pnpm dev
http://localhost:5173(or whichever port Vite assigns).
For production, it is highly recommended to decouple the frontend and backend using standard cloud hosting providers.
The Go backend can be deployed as a standard web service on platforms like Render, Railway, or Heroku.
- Connect your Git repository to your chosen platform.
- Set the root directory of the service to
backend/. - The platform should automatically detect it as a Go application and build it.
- Once deployed, copy the live URL of your backend service (e.g.,
https://qr-api.onrender.com). - Security Tip: Update the
corssettings inbackend/main.goto explicitly allow traffic from your future frontend domain, rather than*.
The Vue frontend is a statically generated site that is perfect for platforms like Vercel, Netlify, or Cloudflare Pages.
- Connect your Git repository to your chosen platform.
- Set the root directory of the site to
frontend/. - Set the Build Command to
pnpm build(ornpm run build) and the Output Directory todist. - Add an Environment Variable on the hosting platform:
- Key:
VITE_API_BASE_URL - Value: The live URL of your deployed Go backend (e.g.,
https://qr-api.onrender.com).
- Key:
- Deploy the site! The frontend will now securely communicate with your live backend.
The Go backend exposes two primary endpoints:
Generates a QR code PNG image from the provided text.
- Request Body:
{"type": "url", "text": "https://example.com"}(Supported types:url,text,contact,phone,wifi,location) - Response:
image/pngbinary data.
Reads a QR code from an uploaded image.
- Request Body:
multipart/form-datacontaining animagefile. - Response:
{"result": "decoded text here"}
