Code Monkey home page Code Monkey logo

java-liberty-backend-for-frontend's Introduction

WARNING: This repository is no longer maintained ⚠️

This repository will not be updated. The repository will be kept available in read-only mode.

Platform

Create and deploy a Java Backend For Frontend (BFF) using Java EE

We have similar patterns available for Node.js, Swift, and Java Spring as well!

In this code pattern, you will create a Backend for Frontend (BFF) web service using Java EE MicroProfile running on WebSphere Liberty, matching a RESTful API documented in Swagger.

A BFF can be used to elegantly expose complex backend systems to multiple client-facing platforms, such as iOS and the web, without building a monolothic API that attempts to serve all clients equally. Different types of clients require different types of user experiences, and having a backend API tightly coupled to each specific user experience actually makes for a much more loosely coupled system overall. This pattern helps frontend teams iterate on features faster by giving them more control over the APIs they interact with, without affecting the user experience or development team driving a sister frontend.

When you have completed this code pattern, you will understand how to:

  • Build out the Backend for Frontend (BFF) architecture pattern
  • Deploy to Kubernetes, Cloud Foundry or a DevOps Pipeline
  • Operate an application with monitoring and distributed trace
  • Connect to provisioned services

Video

Learn more about the Backend for Frontend pattern in this tech talk:

BFFs and GraphQL, terms you should know and why

Steps

As an alternative to the steps below, you can create this project as a starter kit on IBM Cloud, which automatically provisions required services, and injects service credentials into a custom fork of this pattern. Then, you can skip directly to step 4 below.

  1. Install development tools
  2. Configuration
  3. Project contents
  4. Run

1. Install development tools

2. Configuration

The application is configured to provide JAX-RS REST capabilities, JNDI, JSON parsing and Contexts and Dependency Injection (CDI).

These capabilities are provided through dependencies in the pom.xml file and Liberty features enabled in the server config file found in src/main/liberty/config/server.xml.

3. Project contents

The BFF application has a health endpoint which is accessible at <host>:<port>/javalibertybackendforfrontend/health. The context root is set in the src/main/webapp/WEB-INF/ibm-web-ext.xml file. The ports are set in the pom.xml file and exposed to the CLI in the cli-config.yml file.

The project contains IBM Cloud specific files that are used to deploy the application as part of a IBM Cloud DevOps flow. The .bluemix directory contains files used to define the IBM Cloud toolchain and pipeline for your application. The manifest.yml file specifies the name of your application in IBM Cloud, the timeout value during deployment and which services to bind to.

Credentials are either taken from the VCAP_SERVICES environment variable that IBM Cloud provides or from environment variables passed in by JNDI (see the server config file src/main/liberty/config/server.xml).

4. Run

To build and run the application:

  1. mvn install
  2. mvn liberty:run-server

To run the application in Docker use the Docker file called Dockerfile. If you do not want to install Maven locally you can use Dockerfile-tools to build a container with Maven installed.

The application exposes the following endpoints:

  • Health endpoint: <host>:<port>/<contextRoot>/health
  • Swagger API: <host>:<port>/ibm/api/explorer/, you will need to login with the credentials set in your server.xml file. By default these are guest and password.

The context root is set in the src/main/webapp/WEB-INF/ibm-web-ext.xml file. The ports are set in the pom.xml file and exposed to the CLI in the cli-config.yml file.

License

This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.

Apache License FAQ

java-liberty-backend-for-frontend's People

Contributors

dolph avatar ibm-devx-automation avatar imgbotapp avatar stevemar avatar stevemart avatar

Stargazers

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

Watchers

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