# rizwansaifi571/qr-authnet-authenticity-detection-with-cnn architecture

> Architecture diagram of the GitHub repository rizwansaifi571/qr-authnet-authenticity-detection-with-cnn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn
- Repository: https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn

## Overview

##### Project type and purpose
- This is a full-stack web application built with Flask that exposes a machine-learning pipeline for authenticating QR code prints (distinguishing original vs. counterfeit).
- The purpose is to allow users to upload QR code images via a web interface, run them through both traditional CV+SVM and a CNN model, and display prediction results and history.

##### File structure
- Top level:
- app.py: main Flask application entry point
- Procfile & requirements.txt: deployment configuration for Gunicorn/Render
- data/: raw/original & augmented training data (used off-line in notebooks)
- notebooks/: Jupyter notebooks and the serialized CNN model (best_model.h5)
- static/ & templates/: the front-end assets (CSS, HTML pages)
- uploads/ (in README but not in file tree): runtime storage for user-uploaded images
- Architectural patterns: MVC-like separation – templates/ static/ ≈ View, app.py ≈ Controller, notebooks/models ≈ Model
- No traditional database—persistent state is kept in the file system (uploads folder and potentially a log file).

##### README for additional insights
- Describes two pipelines: a handcrafted-feature + SVM (traditional) and a CNN (deep learning).
- Mentions deployment on Render with Gunicorn, environment variables, and a multi-image upload interface.
- Technologies: Flask, TensorFlow/Keras, scikit-learn, OpenCV, scikit-image, Gunicorn, HTML/CSS/Bootstrap.

##### Details
- Endpoints and their responsibilities (/landing, /predict, /history, /about).
- Model loading lifecycle (startup vs. per-request).
- Both pipelines (traditional vs. CNN) as parallel subcomponents.
- Don’t omit the static/templates layer that forms the user interface.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        Browser["Client Browser"]:::frontend
    end

    %% Server Side
    subgraph "Server Side"
        subgraph "Web Layer"
            Gunicorn["Gunicorn/Werkzeug"]:::server
            FlaskApp["Flask App"]:::server
            Requirements["Python Dependencies"]:::server
            Templates["Templates (templates/)"]:::frontend
            Static["Static Assets (static/)"]:::frontend
        end

        subgraph "Inference Layer"
            ModelLoader["Model Loader"]:::ml
            TradPipeline["Traditional CV+SVM Pipeline"]:::ml
            CNNInference["CNN Inference Module"]:::ml
        end

        subgraph "Storage Layer"
            Uploads["Uploads Folder"]:::storage
            Logs["Logs/History Store"]:::storage
            DataOrig["Original Data"]:::storage
            DataAug["Augmented Data"]:::storage
        end

        subgraph "Batch Training Pipeline"
            Notebook["Offline Training Notebook"]:::ml
        end
    end

    %% Deployment
    Render["Render.com Deployment"]:::external

    %% Connections
    Browser -->|"HTTP GET/POST"| Gunicorn
    Gunicorn --> FlaskApp
    FlaskApp --> Templates
    FlaskApp --> Static
    FlaskApp --> Requirements
    FlaskApp -->|"invokes at startup"| ModelLoader
    FlaskApp -->|"on /predict"| Uploads
    FlaskApp -->|"on /predict"| TradPipeline
    FlaskApp -->|"on /predict"| CNNInference
    TradPipeline -->|"reads data"| DataOrig
    TradPipeline -->|"reads data"| DataAug
    ModelLoader --> CNNInference
    Notebook -->|"produces model"| ModelLoader
    Uploads --> Logs
    FlaskApp --> Logs
    Gunicorn --> Render

    %% Click Events
    click FlaskApp "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/blob/main/app.py"
    click Gunicorn "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/tree/main/Procfile"
    click Requirements "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/blob/main/requirements.txt"
    click Templates "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/tree/main/templates/"
    click Static "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/blob/main/static/css/style.css"
    click ModelLoader "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/blob/main/notebooks/best_model.h5"
    click Notebook "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/blob/main/notebooks/cnn_model.ipynb"
    click DataOrig "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/tree/main/data/original_data"
    click DataAug "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/tree/main/data/augmented_data"
    click Docs "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/blob/main/docs/QR Code Authentication Assignment.pdf"
    click Readme "https://github.com/rizwansaifi571/qr-authnet-authenticity-detection-with-cnn/blob/main/README.md"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#000,color:#000;
    classDef server fill:#c8e6c9,stroke:#000,color:#000;
    classDef ml fill:#ffe0b2,stroke:#000,color:#000;
    classDef storage fill:#eeeeee,stroke:#000,color:#000;
    classDef external fill:#e1bee7,stroke:#000,color:#000;
```
