Coder Social home page Coder Social logo

theghinzou / rest-apis-versioning-workshop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexandre-touret/rest-apis-versioning-workshop

0.0 0.0 0.0 274 KB

Rest APIs Versioning

License: GNU General Public License v3.0

Shell 3.04% Java 96.96%

rest-apis-versioning-workshop's Introduction

REST APIs Versioning: Hands-on !

This workshop aims to introduce different ways to handle and propose several versions of a same API to your customers.

๐ŸŽฏ Big picture

During this workshop we will strive with API versioning on a (small) microservice application. Here is a short description of it.

This platform aims to store and get books of a bookstore.

System View

C4Context
      title System Context diagram for Bookstore System
      Person(customerA, "Bookstore Customer", "A customer of the bookstore") 
      Person(adminA, "Bookstore Administrator", "An administrator of <br/> the bookstore") 
      Enterprise_Boundary(b0, "Bookstore Boundary") {
        System(bookstoreSystem, "Bookstore System", "Allows Book <br/> creation, search,...")  
        System(iamSystem, "Bookstore IAM", "Allows Identification <br/> & authorization...")  
      }
      Rel(customerA, bookstoreSystem, "Uses")
      Rel(adminA, bookstoreSystem, "Uses & manage users")
      Rel(customerA, iamSystem, "identifies & authorizes")
      Rel(adminA, iamSystem, "identifies & authorizes")

Explanations

Here we have two main kind of users:

  • Customer : He can browse and create books
  • Administrator: He can create books and activate/deactivate the maintenance mode

Within our platform, we have two main systems:

  • Bookstore system which operate all the book related operations
  • Bookstore IAM which is responsible for identifying and authorizing users

Container view

C4Container
      title Container Context diagram for Bookstore System


      Person(customerA, "Bookstore Customer", "A customer of the bookstore") 
      Person(adminA, "Bookstore Administrator", "An administrator <br/> of the bookstore") 

      Enterprise_Boundary(b0, "Bookstore Boundary") {
        Container_Boundary(b2,"Bookstore IAM"){
          Container(iam,"IAM","Provides a JWT token with roles in claims")

               }
        Container_Boundary(b1,"Bookstore System"){
            Container(bookstoreApi,"Bookstore API","Spring Boot, Cloud","Exposes the Bookstore APIs")
            Container(gateway,"API Gateway","Spring Cloud Gateway","Exposes the APIs")
            ContainerDb(database, "Database", "PostgreSQL Database", "Stores bookstore")
            Container(isbnApi,"ISBN","Spring Boot, Cloud","Exposes the ISBN APIs")
            Container(configuration,"Configuration Server","Spring Cloud Config","Exposes the configuration")
            Container(zipkin,"Zipkin","Zipkin","Gathers and <br/> provides distributed tracing")
        }
      }

      Rel(customerA,gateway, "Uses")
      Rel(adminA, gateway, "Uses & manage users")
      Rel(customerA, iam, "identifies & authorizes")
      Rel(adminA, iam, "identifies & authorizes")
      Rel(gateway, iam, "verify token")
      Rel(gateway, bookstoreApi, "exposes")
      Rel(gateway, isbnApi, "exposes")
      Rel(bookstoreApi, isbnApi, "uses")
      Rel(bookstoreApi, database, "stores data")
      UpdateLayoutConfig($c4ShapeInRow="3", $c4BoundaryInRow="1")

Explanations

This diagram digs into the systems exposed above in the system view.

The Bookstore system is composed of:

  • The API Gateway which exposes our APIs
  • The Bookstore API which exposes all the related book APIs and stores data to a PostgreSQL database
  • The ISBN API which provides random ISBN numbers
  • A Configuration server which centralizes all the configuration files

The Bookstore IAM is composed of:

  • A mock server which provides JWT token with appropriate roles and information.

๐Ÿ“ Stack

Here is a summary of the stack used in this workshop for this architecture:

Container Tools Comments
API Gateway Spring Cloud Gateway 2022.0.0-RC2
Bookstore API JAVA 17,Spring Boot 3.0.X
ISBN API JAVA 17,Spring Boot 3.0.X
Configuration Server Spring Cloud Config 2022.0.0-RC2
Database PostgreSQL
Authorization Server JAVA 17,Spring Boot 3.0.X, Spring Authorization Server 1.0.0

Customers

Our API Roadmap

%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'rotateCommitLabel': true}} }%%
gitGraph:
    commit id:"Init"
    commit id: "new features" tag:"Adding excerpt attribute & operation"
    branch V1
    checkout V1
    commit id:"add URI PATH versions"
    commit id: "add HTTP Header versions"
    commit id: "add accept HTTP Header versions"
    checkout main
    branch V2
    commit id: "revamping"
    commit id: "Add author list feature"
    checkout V1
    commit id: "Add fallback behaviour in V1"
    checkout V2
    commit id: "Authorization management"
    merge V1
    commit id: "Deprecating V1"

๐Ÿšฅ Prerequisites

๐ŸŽ“ Skills

Skill Level
REST API proficient
Java novice
Gradle novice
Spring Framework, Boot, Cloud Config, Cloud Gateway Spring Authorization Server novice
OpenID Connect novice
Docker novice

๐Ÿ”ง Tools

If you want to execute this workshop locally

You MUST have set up these tools first:

Here are commands to validate your environment:

Java

java -version
    openjdk version "17.0.5" 2022-10-18
    OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
    OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

Gradle

If you use the wrapper, you won't have troubles. Otherwise...:

gradle --version

    Welcome to Gradle 7.6!

Docker Compose

docker compose version
    Docker Compose version v2.12.2

๐Ÿš€ If you don't want to bother with a local setup

With Gitpod (recommended)

You can use Gitpod. You must create an account first. You then can open this project in either your local VS Code or directly in your browser:

Open in Gitpod

With Github Codespaces

You can also use Github Codespaces. You can create a new one by running "Code > Create codespace on main".

You have then to run the command in the shell:

pip install httpie
    sdk install java 17.0.5-tem
    sdk default java 17.0.5-tem

๐Ÿ’ฅ Ready ?

Warning

I strongly suggest to fork this project into your personal GitHub namespace (aka your GitHub account).

You then can change the URL mentioned above to link GitHub and Gitpod:

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#github.com/%%MY_NAMESPACE%%/rest-apis-versioning-workshop.git)

or you can directly browse this URL (think to change the %%MY_NAMESPACE%% prefix):

https://gitpod.io/#github.com/%%MY_NAMESPACE%%/rest-apis-versioning-workshop.git

Note

Now, you can start the workshop ๐ŸŽ‰.

rest-apis-versioning-workshop's People

Contributors

alexandre-touret avatar wlybe 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.