Giter VIP home page Giter VIP logo

ftl-examples's Introduction

FTL examples

This repository contains a few different example modules for FTL. The top-level go and kotlin directories contain language-specific examples, while the online-boutique directory contains a full micro-services demo based on GCP's demo of the same name.

Note

If using Hermit, be sure to open your editor from the activated environment in order to get the correct environment variables.

Running

In order to have all the tools you need to build and run the examples, follow one of these steps:

  • Install Hermit and related shell_hooks.
  • (or) Install and activate the Hermit environment manually: . ./bin/activate-hermit
  • (or) Manually install Just, FTL, Flutter, Go, Goreman, Watchexec, etc. (not recommended)

Online-boutique

The online-boutique directory is designed to show how to use FTL to build an online boutique backend with a mobile (Flutter) app and React frontend.

Preparation

To see a list of commands that can be run, run just --list in the root of the project.

Start FTL, code gen, and backend services with hot-reloading

just dev

Start the React web app

just web

Flutter app

Flutter is better run via an IDE like VSCode or Android Studio.

Interact with the boutique

Add a new item to your cart using the command-line:

curl -i --json '{"userId": "Larry", "item": {"productId": "OLJCESPC7Z", "quantity": 1}}' localhost:8891/cart/add

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Vary: Origin
Date: Wed, 14 Feb 2024 03:00:03 GMT
Content-Length: 2

{}

Checkout the cart:

curl --json '{
  "userCurrency": "AUD",
  "address": {
    "streetAddress": "1600 Amphitheatre Parkway",
    "city": "Mountain View",
    "state": "CA",
    "country": "USA",
    "zipCode": 94043
  },
  "email": "[email protected]",
  "creditCard": {
    "number": "423412341234",
    "cvv": 123,
    "expirationYear": 2029,
    "expirationMonth": 6
  }
}
' localhost:8891/checkout/Larry | jq .

Response

{
  "id": "19031e2c-a4b3-49fe-bbb8-464bc8707559",
  "shippingAddress": {
    "city": "Mountain View",
    "country": "USA",
    "state": "CA",
    "streetAddress": "1600 Amphitheatre Parkway",
    "zipCode": 94043
  },
  "shippingCost": {
    "currencyCode": "AUD",
    "nanos": 387449163,
    "units": 11
  },
  "shippingTrackingId": "LS-44971-224078566"
}

Open up the FTL console. This will let you navigate the logs, traces and structure of the FTL modules running locally. In the timeline, if you click on one of the calls that we just issued you should see a call trace.

Open up your editor, alter the data structures, alter the logic, and see how it is all reflected in FTL automatically.

ftl-examples's People

Contributors

wesbillman avatar alecthomas avatar dependabot[bot] avatar lifeizhou-ap avatar matt2e avatar safeer avatar nayakhilesh avatar

Stargazers

Nilo Alvarado avatar Mihai Chiorean avatar Faisal Ramdan avatar

Watchers

 avatar

ftl-examples'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.