Skip to content

Commit

Permalink
feat: gRPC lib and tutorials (ZupIT#524)
Browse files Browse the repository at this point in the history
* move overview to beagle helpers root page

* delete overview from beagle helpers android page

* delete overview from beagle helpers ios page

* Create overview.md

* Create overview.md

* Create _index.md

* Create _index.md

* create a beagle gRPC tutorial

* Update content/en/get-started/using-beagle-helpers/backend/_index.md

Co-authored-by: carlossteinzup <60155378+carlossteinzup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: carlossteinzup <60155378+carlossteinzup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: Mariana Moreira  <66182661+mdcpmoreira@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: Mariana Moreira  <66182661+mdcpmoreira@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: Mariana Moreira  <66182661+mdcpmoreira@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: Mariana Moreira  <66182661+mdcpmoreira@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: Mariana Moreira  <66182661+mdcpmoreira@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: Mariana Moreira  <66182661+mdcpmoreira@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: carlossteinzup <60155378+carlossteinzup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: carlossteinzup <60155378+carlossteinzup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: carlossteinzup <60155378+carlossteinzup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: carlossteinzup <60155378+carlossteinzup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: carlossteinzup <60155378+carlossteinzup@users.noreply.github.com>

* fix grammaly

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/overview.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* add linux and mac run guide

* add portuguese page

* fix How Beagle gRPC works

* fix portuguese gramally

* fix Portuguese grammar

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: Luiz Gustavo Gomes Borges <luiz.borges@zup.com.br>

* fix How Beagle gRPC works - grammar

* chore: Add android doc

Signed-off-by: paulomeurerzup <paulo.meurer@zup.com.br>

* Update content/pt/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/pt/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/pt/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/pt/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/pt/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/pt/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/pt/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/pt/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/pt/get-started/using-beagle-helpers/backend/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* feat: Beagle gRPC iOS

* fixes in grpc ios pages

* beagle grpc ios pt

* Update content/en/get-started/using-beagle-helpers/android/beagle-grpc.md

Co-authored-by: Uzias Ferreira <63263091+uziasferreirazup@users.noreply.github.com>

* fix beagle grpc backend versions

* fix static version on beagle grpc for android

* Update content/en/faq.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/faq.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/faq.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/faq.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/faq.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/faq.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/faq.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/en/faq.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* grpc for beagle web

* add @zup-it/ to the package name

* Update content/en/get-started/using-beagle-helpers/android/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* Update content/pt/get-started/using-beagle-helpers/Android/beagle-grpc.md

Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>

* english fixes

Co-authored-by: carlossteinzup <60155378+carlossteinzup@users.noreply.github.com>
Co-authored-by: Mariana Moreira  <66182661+mdcpmoreira@users.noreply.github.com>
Co-authored-by: igorgiumellizup <73198010+igorgiumellizup@users.noreply.github.com>
Co-authored-by: Luiz Gustavo Gomes Borges <luiz.borges@zup.com.br>
Co-authored-by: paulomeurerzup <paulo.meurer@zup.com.br>
Co-authored-by: Lucas Araújo <lucas.araujo@zup.com.br>
Co-authored-by: Uzias Ferreira <63263091+uziasferreirazup@users.noreply.github.com>
Co-authored-by: Arthur Bleil <arthur.bleil@zup.com.br>
  • Loading branch information
9 people committed Jun 4, 2021
1 parent 57bb1fe commit 448a117
Show file tree
Hide file tree
Showing 20 changed files with 1,390 additions and 96 deletions.
63 changes: 31 additions & 32 deletions content/en/faq.md
Expand Up @@ -13,43 +13,43 @@ Beagle is an open source framework of cross-platform development, it is based on

## How does Beagle work?

The developer declares the backend screens and the expose the endpoints that represent them. These endpoints are called using Beagle to render the screen components on the web or mobile.
The developer declares the backend screens and the exposed endpoints that represent them. These endpoints are called using Beagle, to render the screen components on the web or mobile.

Beagle works as a 'bridge' between front and backend, it is possible that the design components of your application have a parameter in backend which makes a native application possible.
Beagle works as a 'bridge' between front and backend, and it is possible for the design components of your application to have a parameter in the backend, making a native application possible.

## My application's architecture will change if I use Beagle?

No, Beagle does not interfere with your project's architecture.

## Why should I use Beagle and not React Native or Flutter?
## Why should I use Beagle and not React Native or Flutter?

Beagle's solution is different from other tecnologies. It is a tool to make the development easier, it has UI oriented concept of continuous delivery. Beagle allows you to handle through backend, native components of your application, change layouts and the display of these components.
Beagle's solution is different from other technologies. Beagle is a tool that makes mobile and web app development easier, and it has a UI oriented concept of continuous delivery. Through a backend project, Beagle also allows you to implement native components and change its layout.

## Is it possible to make tests in server driven screens?
## Is it possible to make tests in server driven screens?

Yes! Unit tests like instrumented test work the same way on Beagle.
Yes! Unit tests, like instrumented tests, work the same way on Beagle.

## Can I use Beagle in an application that already has developed resources?
## Can I use Beagle in an application that already has developed resources?

Yes! If your application already have the developed components in a design system, you are able to use them on Beagle. You only have to see if these components are defined and then it will be easy to register them on Beagle.
Yes! If your application already has the developed components in a design system, you are able to use them on Beagle. You only have to see if these components are defined and then it will be easy to register them on Beagle.

## Does a Beagle application need to be 100% Server Driven?
## Does a Beagle application need to be 100% Server Driven?

No, the application can use only one Server Driven screen in some app's flows. You can continue in one server driven flow or return to the native screen normally.
No, the application can use only one Server Driven screen in some app's flows. You can continue in one server driven flow or return to the native screen normally.

## Do I have to use Beagle in the whole application?
## Do I have to use Beagle in the whole application?

No, your application will continue the same and it can be native even with Beagle on it. You may use Beagle whenever you want.

## Will my application work offline?
## Will my application work offline?

Depends. All server driven application when requests the server a flow, it needs to be connected in order to receive a response from backend. The server driven flows cannot be solved without a connection. But, your if your application is not 100% server driven, there is a part of it that doesn't need to get online information, then it will work. The application also can be configured to call other screens in case they are offline.
It depends. All server driven applications, when requesting the server in a flow, will need to be connected in order to receive a response from backend. The server driven flows cannot be solved without a connection. But, if your application is not 100% server driven, then there is a part of it that doesn't need to get online information, and then it will work. The application also can be configured to call other screens in case they are offline.

### If my my internet connection is interrupted in the middle of the application flow?
### What If my internet connection is interrupted in the middle of the application flow?

The way to deal with disconnection cases is to create local declaratives screens to `fallback`.
The way to deal with disconnection cases is to create local declaratives screens to `fallback`.

## Will I have problems to upload an application with Beagle on App Store or Play Store?
## Will I have problems to upload an application with Beagle on App Store or Play Store?

No! All the components used will be defined in your application when the store's upload happens. Beagle is dynamic when dealing with updates, this happens because the work is in the backend and there isn't any frontend configuration that is big enough to cause a block on Apple or Google. Beagles wants to minimize the `deploys` on the stores.

Expand All @@ -59,8 +59,7 @@ Not, it's the quite opposite. We made a renderization `benchmark` and Beagle - u

## How about backend's answer time? Will my application be slower?

No, because Beagle uses a **cache mechanism** to store adjacent screens and, then, optimize backend's calls. This means that you don't need to request again to backend in the user's click moment.

No, because Beagle uses a **cache mechanism** to store adjacent screens and, then, optimize backend's calls. This means that you don't need to request again to backend in the user's click moment.

Beagle's latest version is:undefined

Expand All @@ -70,42 +69,42 @@ Yeas! Beagle is an **open source development framework**, which means that its t

## **Can I create a BFF with a different language than JVM?**

It's possible to create a BFF in a different language. However, we don't have ready `libs` to help you on this process, so it would be necessary that the developer create a mechanism to respect Beagle's contracts.
It's possible to create a BFF in a different language. However, we don't have ready `libs` to help you on this process, so it would be necessary that the developer create a mechanism that respects Beagle's contracts.

## What are the advantages of using Beagle?

One of the main advantages is that Beagles facilitates the development because of backend's configuration based on [**BFF paradigm.**]({{< ref path="/key-concepts#backend-for-frontend" lang="en" >}})

This means that Beagle helps you on changing screen's `layouts`, screen's flows and app's navigation. All of this is made from pages declaratively created in your BFF with a components' library defined on your application's frontend, which helps on interface's change.
This means that Beagle helps you on changing screen's `layouts`, screen's flows and app's navigation. All of this is made from pages declaratively created in your BFF with a components' library defined on your application's frontend, which helps on interface's change.

It allows you to:
It allows you to:

* Decide which visual component must be presented: which texts, subtitles and any other visual information that must be shown, centralized and abstracted on the server.
- Decide which visual component must be presented: which texts, subtitles and any other visual information that must be shown, centralized and abstracted on the server.

This avoids a replication on each frontend's platform that consumes this API. The server applies this business logic and use its results to assemble the API response representing it.
This avoids a replication on each frontend's platform that consumes this API. The server applies this business logic and use its results to assemble the API response representing it.

* Make A/B tests to change the order how components are presented.
- Make A/B tests to change the order how components are presented.

## Can I use Beagle for Android, iOs or Web development?
## Can I use Beagle for Android, iOs or Web development?

Yes! As a cross-platform framework, Beagle helps you on developing application on these three platforms by using the [**Server-Driven UI concept**]({{< ref path="/key-concepts#server-driven-ui" lang="en" >}}), which enables that even a BFF may be used on all of these applications.
Yes! As a cross-platform framework, Beagle helps you on developing application on these three platforms by using the [**Server-Driven UI concept**]({{< ref path="/key-concepts#server-driven-ui" lang="en" >}}), which enables that even a BFF may be used on all of these applications.

You can see more how to create Beagle's projects with each of these platforms on:
You can see more how to create Beagle's projects with each of these platforms on:

* [**Beagle for Android**]({{< ref path="/get-started/creating-a-project-from-scratch/case-android/" lang="en" >}})
* [**Beagle for iOS**]({{< ref path="/get-started/creating-a-project-from-scratch/case-ios/" lang="en" >}})
* [**Beagle for Web**]({{< ref path="/get-started/creating-a-project-from-scratch/case-web" lang="en" >}})
- [**Beagle for Android**]({{< ref path="/get-started/creating-a-project-from-scratch/case-android/" lang="en" >}})
- [**Beagle for iOS**]({{< ref path="/get-started/creating-a-project-from-scratch/case-ios/" lang="en" >}})
- [**Beagle for Web**]({{< ref path="/get-started/creating-a-project-from-scratch/case-web" lang="en" >}})

## How to make unitary and instrumented tests on server-driven screens?

Beagle doesn't interfere in unitary or instrumented tests, so they can be normally done.

## How to make unitary tests using Beagle?

Unitary tests has the goal to gauge the code's functionality in a minor fraction. The applications' tests that use Beagle are done in the same way as in applications that don't use our tool. That means Beagle doesn't interfere in these tests.
Unitary tests has the goal to gauge the code's functionality in a minor fraction. The applications' tests that use Beagle are done in the same way as in applications that don't use our tool. That means Beagle doesn't interfere in these tests.

### How to make instrumented tests using Beagle?

Instrumented tests are done in applications using Beagle in the same way as in applications that don't use our tool.
Instrumented tests are done in applications using Beagle in the same way as in applications that don't use our tool.

However, it's important to reinforce that, usually, a server-driven component may not contain an ID that mostly identifies an instrumented test. Thinking of it, we add a `WIDGET` element \(that refers a component\) and an `ID attribute` so it can be possible to programatically identify it.
107 changes: 107 additions & 0 deletions content/en/get-started/using-beagle-helpers/android/beagle-grpc.md
@@ -0,0 +1,107 @@
---
title: Beagle gRPC
weight: 16
description: 'Here you will find the **Beagle-gRPC** library to help you use gRPC in a project using Beagle in Android.
This lib will hold almost all necessary configuration to add gRPC into a Beagle Android project.'
---

---

![Maven Central](https://img.shields.io/maven-central/v/br.com.zup.beagle/beagle-grpc?color=green&label=Beagle-gRPC)
![**Maven Central**](https://img.shields.io/maven-central/v/br.com.zup.beagle/android?label=Beagle)

### Requirements

<hr>

Before you start to configure Beagle for your Android system, it’s important to check out if you have installed all the current versions of the following programs: ‌

- JDK 8+ language
- Android API level: at least 19 or higher
- Kotlin 1.3+

### Getting started

<hr>

This tutorial will configure Beagle from the Start.

#### Step 1: Add a configuration on the Gradle file in your project:

- `Add mavenCentral()` into the `All projects` block on your Project Gradle file(build.gradle)<br>

```kotlin
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
```

#### Step 2: Add Kotlin Kapt plugin and 3 dependencies on your application dependency manager (gradle.gradle)<br>

![Maven Central](https://img.shields.io/maven-central/v/br.com.zup.beagle/beagle-grpc?color=green&label=Beagle-gRPC)
![Maven Central](https://img.shields.io/maven-central/v/br.com.zup.beagle/android?label=Beagle)

- Add the packagingOptions code block to the build.gradle file, as in the example below.

- _The version numbers listed below may have been updated. Please check the actual versions on the tags above:_

```kotlin
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}

android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}

packagingOptions {
pickFirst 'META-INF/LICENSE.md'
pickFirst 'META-INF/LICENSE-notice.md'
}
}

dependencies {
kapt "br.com.zup.beagle:android-processor:${beagleVersion}"
implementation "br.com.zup.beagle:beagle-grpc:${beagleVersion}"
}
```

#### Step 3: Create an AppHttpClientFactory

- This class will be responsible to provide the `HttpClient` that will be used by Beagle to perform requests.<br>

```
const val BASE_URL = "http://10.0.2.2:8080" // your gRPC host
@BeagleComponent
class AppHttpClientFactory: HttpClientFactory {
override fun create(): HttpClient {
return GrpcClient(BASE_URL, HttpClientDefault())
}
}
```

Here, we are telling Beagle to use `GrpcClient` to perform network requests.<br><br>
Let's look to the constructor params of `GrpcClient`: <br>

- `grpcAddress`: Host of your gRPC server. Every request pointing to this host will be performed by `GrpcClient`.
- `customHttpClient`: All requests made to another host will be performed by this `HttpClient`.

Therefore, a request to `http://10.0.2.2:8080/foo` will be performed by `GrpcClient` and a request to another host, let's say, `http://127.0.1.1:5555/bar` will be performed by `HttpClientDefault`.
<br>

The `HttpClientDefault` implementation can be found at Beagle-Default lib.

<hr>

##### For more on Beagle: Please check our [Beagle](https://github.com/ZupIT/beagle) repository.

##### For more on Beagle-Defaults: Please check our [Beagle-Default]({{< ref path="/get-started/using-beagle-helpers/android/beagle-defaults" lang="en" >}}) documentation.
35 changes: 0 additions & 35 deletions content/en/get-started/using-beagle-helpers/android/overview.md

This file was deleted.

6 changes: 6 additions & 0 deletions content/en/get-started/using-beagle-helpers/backend/_index.md
@@ -0,0 +1,6 @@
---
title: Backend
weight: 2
description: >-
This section lists all backend libs that will help you to use Beagle.
---

0 comments on commit 448a117

Please sign in to comment.