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.
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.
- 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:
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.
- Use protoc version 3.15.8
- Use protoc-gen-go v1.28.0
- Define the protobuf structure in golang
- Compile the proto:
protoc --proto_path=data --go_out=. --go-grpc_out=. data/messages.proto
- Add the endpoint to the binding package
- Compile the protobuf files in Flutter:
protoc --dart_out=grpc:lib/services/breezlib/data/ -I<path to messages.proto>
- Add the function in breez_bridge.dart
We recommend you setup a simnet environment before testing your code on mainnet.