Giter Site home page Giter Site logo

devessier / temporal-electronic-signature Goto Github PK

View Code? Open in Web Editor NEW
90.0 4.0 12.0 16.21 MB

Electronic signature demonstration built with Temporal and XState

License: GNU General Public License v3.0

TypeScript 7.50% JavaScript 82.73% CSS 6.31% HTML 2.28% Svelte 1.15% Shell 0.03%
temporal nodejs xstate

temporal-electronic-signature's Introduction

Temporal Electronic Signature

Temporal Electronic Signature is a demonstration of Temporal Node.js SDK used with XState to write workflows. By implementing an electronic signature system, we have to use all most important features of Temporal: activities, signals, queries, timers. Thanks to XState, the code we have to write is more predictable and prevents race conditions to happen.

validated-signature.mp4

Temporal Meetup

Watch the presentation of this project at the November 2021 Temporal Meetup.

What can be done with the application?

  • User selects a PDF document and validates her choice. It creates a signature procedure.
  • Uploaded document is shown and the user has to validate her choice, or cancel the procedure.
  • An email address is asked. A confirmation code will be sent to this address that will unblock the procedure.
  • The user has to fill the code she received by email.
  • If the code was correct, the document is signed and shown to the user.
  • If the procedure is not validated after one minute, it expires automatically.

How it works

The Stack

The application is built around three packages: app, api and temporal. The front-end is built on SvelteKit and TailwindCSS. The back-end uses AdonisJS.

The Workflow

The workflow is impleted using XState. XState is a library to create state machines in JavaScript. A state machine is a way to represent code with explicit states, that can be in one state at a time, and that goes from one state to another one via transitions. Statecharts are an improvement of state machines that bring some interesting features, such as hierarchical states, delayed transitions or service invokation. These features are used in the workflow.

Let's see how the workflow is organized with states. Open the visualizer

Setup

Those are the instructions to launch the signature system locally.

Except docker-compose package, all commands will have to be executed in separate shells and kept alive.

Dependencies

First, let's install dependencies at the root of the repository.

yarn install

Temporal

We have to launch Temporal server and Temporal worker.

Environment variables

Go to packages/temporal directory, create a .env from .env.example.

You will need credentials to authenticate to a SMTP server. If you do not have one, you can use your Gmail account credentials. If you have enabled 2FA on your Google account, you might need an additional step.

Temporal server

Execute the following command:

cd packages/docker-compose

docker-compose up -d

Temporal worker

Launch a Temporal worker:

cd packages/temporal

yarn start.watch

If you encounter issues, such as dyld: lazy symbol binding failed: Symbol not found, try the following actions:

  • Install Node.js version 14
  • Install node-gyp: npm install -g node-gyp

Back-end

Go to packages/api directory, create a .env by copying .env.example.

Then launch the API with the following command.

cd packages/api

yarn dev

Front-end

Launch SvelteKit development server with the following command.

cd packages/app

yarn dev

The front-end will then be accessible at http://localhost:3000.

If not, check the URL printed in the logs.

temporal-electronic-signature's People

Contributors

devessier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

temporal-electronic-signature's Issues

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.