How nathanmendis/secure-qr-code-generator-web-application-using-flask works
Main Components
• Frontend Components:
• Templates: The HTML files (index.html and decrypt.html) act as the user interface for the encryption and decryption workflows.
• Static Assets: Files such as encrypted_qr.png (and any other static resources) that are used to display or store the generated QR code images.
• Backend Components:
• Flask Application: The main web server logic is encapsulated in app.py, handling routes, encryption, decryption, and QR code generation.
• Encryption/Decryption Logic: Implemented using the cryptography.fernet library to encrypt and decrypt URL data.
• QR Code Generation and Scanning: Uses libraries like qrcode for generating QR codes and OpenCV for scanning/decrypting QR codes from user uploads.
• Data Storage:
• File storage for static QR code images and uploads for image files.
• Temporary data storage in memory when handling requests and responses.
Relationships and Interactions
• The client visits the homepage (index.html) provided via Flask routes and submits a URL for encryption.
• The app processes the request by:
• Encrypting the URL.
• Generating a QR code based on the encrypted data.
• Displaying and providing an option to download the generated QR code along with the unique encryption key.
• For decryption:
• The user navigates to the decryption page (decrypt.html) and uploads an image of the QR code.
• The app uses OpenCV to decode the QR code and then applies the decryption function (using the provided key) to reveal the original URL.
Architectural Patterns and Design Principles
• Views are the HTML templates.
• The Controller is represented by Flask routing and app.py's logic.
• The Model, in this case, is minimal (mainly handling the encryption/decryption and QR code binary data manipulation).
• Separation of Concerns: Isolate the encryption/decryption logic, QR code generation, and scanning into distinct functional blocks within the app.
• Security: Emphasize secure key management and safe file upload practices.
Relevant Technologies, Frameworks, or Libraries
• Flask for backend routing and HTTP request handling.
• Cryptography (Fernet) for secure encryption/decryption.
• qrcode for QR code generation.
• OpenCV for scanning and decoding QR codes from images.
• HTML/CSS (within templates) for the frontend UI.
• Python (app.py) for orchestrating the entire process.
Detailed Component Breakdown
• Client Layer:
• Web Browser: Direct interaction with the index and decrypt pages.
• Application Layer (Flask - app.py):
• Routing: Handle routes for home (encryption) and decryption endpoints.
• Business Logic: Process input data, invoke encryption/decryption functions, interact with QR code generation/scanner.
• Service Layer:
• Encryption Service: Provided by the cryptography library, which securely handles URL encryption.
• QR Code Service: Uses the qrcode library for generating QR codes from encrypted data, and OpenCV for decoding them.
• Data/Storage Layer:
• Static File Storage: Holds generated QR images referenced by the frontend.
• Upload Directory: (Not shown in file_tree but mentioned in README) Where user-uploaded QR code images are stored.
• Integration Points:
• Key generation and handling between encryption and decryption functionalities.
Happy diagramming!