Enterprise QR Code Generation & Management API
A robust, scalable API service for creating, customizing, and tracking dynamic and static QR codes, built with FastAPI and PostgreSQL.
Q4 2023 - Q2 2024 (Core Development & PostgreSQL Migration)
Project Overview
In an increasingly connected world, QR codes are pivotal for bridging physical and digital experiences. This project delivers a comprehensive, self-hostable API service empowering developers and businesses with full control over QR code generation, real-time scan analytics, and advanced customization, moving beyond the limitations of off-the-shelf solutions.
The Challenge
Many existing QR code solutions lack flexibility, advanced tracking, robust security, or seamless integration capabilities required for enterprise use cases. Businesses needed a reliable, customizable, and secure way to manage QR campaigns at scale, with detailed analytics to measure engagement and ROI.
The Solution
I architected and developed a high-performance API using FastAPI, Segno, and PostgreSQL, offering fine-grained control over QR code generation (static/dynamic, colors, logos, error correction) and detailed scan analytics. The system is containerized for easy deployment and secured using Traefik for network-level protection, providing a powerful, private alternative to third-party services.
Key Features
Advanced capabilities that make this project stand out
Dynamic & Static QR Codes
Generate permanent QR codes or updatable dynamic codes whose destination URLs can be changed post-creation, perfect for evolving campaigns.
Advanced Scan Analytics
Track every scan in real-time. Collect data on device type, approximate location (privacy-aware), scan time, and referral sources. (Analytics dashboard shown in demo).
Deep Customization Engine
Tailor QR code appearance with custom colors, embedded logos, various module shapes (via Segno), and adjustable error correction levels to balance aesthetics and scannability.
Secure API & Deployment
Built with security in mind: token-based API access (planned), input validation, and network-level protection via Traefik (IP allowlisting, rate limiting, HTTPS).
Batch Operations & Management
Efficiently generate and manage thousands of QR codes programmatically through API endpoints designed for bulk operations.
Technical Deep Dive
The implementation details, architecture decisions, and technology choices
The system employs a containerized microservices-oriented architecture. Traefik serves as the edge gateway, handling HTTPS, routing, and initial security. The FastAPI application (Python) acts as the core API service, interacting with a PostgreSQL database for persistent storage. QR code generation utilizes the Segno library, with Pillow for image post-processing. Asynchronous tasks handle scan statistic updates to ensure low-latency redirects.
Feature Demonstrations
See the QR Code Generator in action with these feature demonstrations
/assets/case-studies/qr-code-generator/code/openapi-schema.json
OpenAPI Schema Definition for QR Code Generator API
Code Sample

QR Code Generator System Architecture (Mermaid)
Image

Embedding Logo in QR Code
Video

Redirect Endpoint and Scan Count Demonstration
Video

Swagger UI Documentation Interface
Image

Sample QR Code with Custom Styling
Image
Outcomes & Impact
Results delivered, lessons learned, and future directions
Robust & Scalable QR Platform
Delivered a feature-rich API capable of handling high-volume QR code generation and tracking, with a flexible architecture ready for future expansion.
Key Metrics:
- Supports millions of scans/month (projected)
- Sub-50ms redirect latency
- 99.9%+ API uptime
Enhanced Customization & Control
Provided users with significantly more control over QR code appearance and behavior compared to off-the-shelf solutions, enabling better brand alignment and campaign effectiveness.
Key Metrics:
- 10+ customization parameters
- Logo embedding with high scannability
- SVG export for vector quality
Actionable Scan Analytics
Implemented a scan tracking system that provides valuable insights into QR code engagement, helping users optimize their campaigns and understand audience interaction.
Key Metrics:
- Real-time scan logging
- Data points: device, location (approx.), time
- Foundation for advanced analytics dashboard
Key Learnings
- FastAPI's performance and Pydantic's data validation are excellent for building robust APIs quickly.
- Segno offers powerful low-level control for QR generation, crucial for advanced features like logo embedding when combined with Pillow.
- Designing for asynchronous operations from the start (e.g., scan tracking) is key for maintaining low latency in high-traffic systems.
- A layered security approach (Traefik at the edge + application-level validation) provides comprehensive protection.
- Migrating from SQLite to PostgreSQL for production required careful planning of data types (esp. timestamps) and schema evolution with Alembic.
- Infrastructure as Code principles (Docker, Traefik configs) significantly improve deployment consistency and reliability.
Future Enhancements
- Full-featured analytics dashboard with visualizations and reporting.
- User authentication and role-based access control for multi-tenant capabilities.
- Integration with URL shortening services for even shorter QR content.
- Support for more advanced QR code types (e.g., Wi-Fi, vCard).
- AI-powered suggestions for optimizing QR code design and placement for campaigns.
Get In Touch
I'm always open to discussing new projects, opportunities or partnerships.
Send a Message
How can I help you? Fill out the form below.
Connect With Me
I'm always open to discussing new projects, opportunities, or collaborations.