Giter Club home page Giter Club logo

api-gateway-step-functions's Introduction

Barcode Generation Demo

Full workflow to Generate a Barcode based on some input, and send it back to the client via Websockets.

All Serverless using API Gateway (Websockets, REST), and Step Functions.

Demonstrated with the use of a quickly generated React Application

Websockets:

Uses API Gateways Websocket connections to create a websocket. Uses a client ID to ensure that the websocket connection is retrievable later.

The client ID used in the web application is a simple UUID but this could be substituted for an actual user id, or for caching purposes a hash of the requested barcode.

Step Functions workflow

The idea behind the step functions would be that as more 'companies' are added you can quickly add new generators. While in this example they are all simplistic (They just send some 'text' parameter) in reality these could be more advanced (for instance, they could make multiple rest calls, and if they failed, could have retry logic built in.)

An Image of the step function workflow is shown below.

Step Function

  • GetParametersForPDF: Choice - Routes to Company A, Company B or if neither present, routes to Default.

  • CompanyA/B/Default: Placesholders, but would be responsible for generating parameters around barcode generation. This could include making rest calls etc.

  • GeneratePDF: Generates the Barcode (Using a simple Node Library). Uploads to S3, then sends the URL.

  • SendNotifications: Uses the URL and ClientID to find a websocket connection, and sends the completed URL back to the client.

  • NotifyError: Sends an error back via the websocket connection to the client.

Things to note

  • Images in S3 are persisted for 1 day before being removed with a lifecycle policy

  • DynamoDB uses a TTL to remove websocket connections after 1 hour. We should not need to be connected longer than this

  • This is a proof of concept. Error handling and Retries are non-existent.

api-gateway-step-functions's People

Contributors

podginator avatar

Watchers

 avatar  avatar  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.