Skip to content

Architecture ‐ Contribution Guide

Nikolaus Heger edited this page Jun 13, 2024 · 3 revisions

Overview of BloC Architecture in Hypha Wallet

The BloC (Business Logic Component) architecture in Flutter is designed to separate the presentation layer from the business logic, ensuring a clean and maintainable codebase. Here's an overview of the roles of various components within this architecture:

1. Views

Views are the UI components that render the application's visual elements. They are typically stateless and rely on BLoCs to manage their state.

  • Example: HomeView displays the user interface for the home page.

2. Components

Components are reusable UI elements that can be embedded within views. They might include buttons, input fields, or custom widgets.

3. Screens (Pages)

Screens or pages represent a complete screen of content, which is usually composed of multiple views and components.

4. BLoCs

BLoCs handle the business logic of the application. They receive events from the UI, process them, and update the UI by emitting new states.

  • Example: HomeBloc handles events related to the home page, such as QR code scanning.

5. Interactors

Interactors folder contains BLoCs and events

6. Events

Events are inputs to a BLoC that trigger it to perform some logic and emit a new state. They represent user interactions or lifecycle events.

  • Example: _OnQRCodeScanned in HomeBloc is an event triggered when a QR code is scanned.

7. States

States are outputs of a BLoC that represent parts of the UI. States are emitted by BLoCs in response to events and trigger UI updates.

  • Example: HomeState represents the state of the home page UI.

8. Use Cases

Use cases encapsulate specific business rules or processes. They are often called by interactors to perform actions that reflect the application's core functionality.

This architecture helps in maintaining a clean separation of concerns, making the code easier to manage and scale. Each component has a well-defined role, ensuring that the application remains modular and testable.