Overview for Developers

The Breez app is comprised of two main layers:

  • Breez Mobile: the UI layer written in Flutter
  • Breez Library: the business logic written in golang. This layer also refers to all Lightning Network dependencies.

Breez Library

The Breez library is implemented in golang and is responsible for the application's business logic, Lightning/on-chain flows, and LND tight integration.

  • The library is compiled and packaged using gobind, which creates a binding layer (the "binding" package) and a wrapping API in both java and swift that allow it to be invoked from the Android and iOS apps.
  • To build the library in Android using go1.19.x or above, follow these instructions.
  • All the functions/interfaces (APIs) that need to be exposed to the Breez mobile app are contained in this file.

Breez Mobile

  • A Flutter implementation is responsible for the UI.
  • To manage its state and its internal business logic, the app uses the BLoC pattern, which uses streams.
  • UI logic is handled in objects called BLoCs. Every domain has its own BLoC.
  • Services is a directory that contains the implementation for various stateless services that are injected via injector.dart and are to be used from BLoCs only.

The rest of the code is pure UI, which uses Sinks to push data and Streams to read data:

  • Widgets is a generic widgets directory.
  • Routes contains the pages of the app.

Communication (calling functions) between Flutter to golang occurs via this bridge. These functions are defined on both layers and protobuf structures, and they are are used as parameters.

Adding a function to the Breez Library

Define the endpoint in Breez Library (golang):

  1. Use protoc version 3.15.8
  2. Use protoc-gen-go v1.28.0
  3. Define the protobuf structure in golang
  4. Compile the proto: protoc --proto_path=data --go_out=. --go-grpc_out=. data/messages.proto
  5. Add the endpoint to the binding package

Define the caller in Breez Mobile (flutter):

  1. Compile the protobuf files in Flutter: protoc --dart_out=grpc:lib/services/breezlib/data/ -I<path to messages.proto>
  2. Add the function in breez_bridge.dart

Your Development Environment

We recommend you setup a simnet environment before testing your code on mainnet.