Giter VIP home page Giter VIP logo

qr-code-reader-generator's Introduction

QR Code Generator & Reader


This is a project I have created for Cloud Computing (CENG495) class at METU. The purpose of this project was to build an app accessing to an external API to generate or read QR codes, which is then to be deployed to Azure Cloud. The project is not accessible now, due to the expiration of Free Plan, however you can host the project on a PHP server after building it.

Created by: Ozan Incesulu

The project is written in Elm as front-end language, there is a PHP script to redirect requests from app to the endpoint since the real APIs do not support cross-origin requests. The project is bundled using Parcel bundler.

User's Manual

The app has two parts that can be navigated from the menu above:

  1. Reader

    In reader part you can provide a URL to be read, or you can select and upload a file to be processed. If operation is successful you will see the result in a green box, a red box will indicate error otherwise.

  2. Generator

    In generator part you can adjust settings on the right to generate a given QR code on the left. If the settings you provide has errors or exceeds the limits provided by the API, a red error box will be displayed instead of the QR.

Problems Faced & Solutions
  • CORS block:
    1. The API that I used was good, however the developers hadn't allowed Cross-Origin requests, thus I had to find a way in the server-side that would redirect any request that I have sent to the original server.
    2. I have first thought about writing a simple server config in Apache, however to my frustration the machines that we are provided turned out to have Windows in them, which made everything more complicated (no bash scripts, no GNU tools, no anything).
    3. Then I thought about checking if PHP was installed on the machine, and I got lucky. Thus considering that request redirection has not been a part of core functionalities that we are required to implement (and not being very proficient in PHP), I have found a script that would redirect the request here
  • File transfer & deployment:
    1. I wanted to build a simple CI/CD process to allow auto-update of my app from source code, but I couldn't find an easy way to do it directly in Azure
    2. I considered using FTP to send files to serve to the machine, however reuploading files each time I update something would be too repetitive and cumbersome.
    3. Then I have realized that in the deployment center with the given utilities I can directly update the file system from Git, thus however dirty it is, I have produced my own builds in Git, then pushed those (details are provided in Deployment section)
Setup

You need elm and node and npm to build this project. Elm is the language used to write the main project, npm is necessary for building and developing the app.

Steps
  • Run npm i in root directory
  • Run npm run build to generate the build that is in the /build directory
Run

You need php, it is necessary to run the redirect script and serve the files.

Run cd dist && php -S localhost:8000 to start serving the app in port 8000

Deployment
  1. I have created an App Service in Microsoft Azure.
  2. I have used Git as the version control tool for my app and pushed it into a repo in GitHub.
  3. I have worked on two branches, master and deployment, in the master branch I have developed my code, then in development branch I have built and pushed the artifact to Git repo.
  4. In the app service from Deployment Center I have selected GitHub and the deployment branch as the deployment source.
  5. I have added the build path as the virtual root path to make the machine serve the build directory.

With the above steps my app becomes available here (This app is not available now, due to limits of Azure)

File Structure
  • dist/* -> compiled and minified app assets that are ready to be served.

  • favicon.ico -> A QR code icon to represent the app

  • forward.php -> PHP code to forward given request from app to the real endpoint

  • index.html -> HTML entrypoint of the app, generated by create-elm-app

  • loading.gif -> A GIF file to show when image is loading

  • manifest.webmanifest -> A JSON file for Android and Chrome to specify theme colors and icons

  • src/

    • main.scss -> Some SCSS overrides for the app
    • index.js -> Autogenerated main JS entrypoint for the app which includes CSS files and boots Elm app.
    • Main.elm -> Entrypoint for the app, creates the menu and renders the active tab
    • ReadQR.elm -> All the models, update logic and views that are needed for reading QR tab is here
    • GenerateQR.elm -> All the models, update logic and views that are needed for generating QR tab is here
    • QRFormat.elm -> Stores some shared functions and types between reading and generating.
  • .gitignore -> Contains entries to exclude some generated code while resolving dependencies

  • elm.json -> Package configuration settings for Elm part of the app

  • package.json -> Automatically generated by create-elm-app. Package configuration for node and npm which are used by the components that compile and minify the code

  • package-lock.json -> Automatically generated by npm to freeze the package state of the app.

External libraries/utilities used

Utilities:

Libraries:

  • bootstrap: UI library for HTML
  • elm/browser: Elm core library for interacting with browser
  • elm/core: Elm language core
  • elm/file: Elm core library for file interactions
  • elm/html: Elm core library for Html generation
  • elm/http: Elm core library for creating Http requests
  • elm/json: Elm core library for parsing and building JSON
  • elm/url: Elm core library for generating and parsing URLs
  • elm-json-decode-pipeline: An easier way to decode JSON for Elm
  • elm-color: A unified way for representing colors in Elm
  • elm-color-extra: A library providing contrast ratio calculation function for colors
  • elm-bootstrap: A library in Elm providing representations of Bootstrap entities for UI
  • elm-colorpicker: A library in Elm that generates color picker for UI

qr-code-reader-generator's People

Contributors

dependabot[bot] avatar ozyinc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.