A guide on how to contribute to this project.
Clone the project
git clone [email protected]:algorandfoundation/hack-tui.git
Change to the directory
cd hack-tui
Build the project
make build
Running a Participation Node
docker compose up
Create a configuration file for the participation node in the root directory of the project (.algorun.yaml)
server: http://localhost:8080
token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Launch the TUI
./bin/algorun
├── api # Generated API Client
├── cmd # Command Controller
├── internal # Data Models/Fetch Wrappers
└── ui # BubbleTea Interfaces
There are three top level modules (cmd, internal, ui) which align with the GoLang/Charm ecosystem. There is an additional code-generated module called api which should not be edited by hand. See generating rpc package for more information
All submodules and endpoints SHOULD align with the command/ui namespaces.
Example Command:
hacktui status
Example Structure
├── cmd/status.go
├── internal/status.go
└── ui/status/table.go
All submodules SHOULD abstract when appropriate to a submodule.
Example Refactor
├── cmd/status/root.go
├── internal/status/model.go
└── ui/status/table.go
Additional top level modules SHOULD NOT be relied on unless there is a clear reason.
A common abstraction found in other projects is a server
module which handles any local daemons.
Folder for commands that can be run from the cli. Effectively this package is the "controller" in MVC
- SHOULD be used to manage cli commands
- SHOULD mirror the name of the command.
cli-tool command-name
should be represented as./cmd/command-name.go
or./cmd/command-name/root.go
- SHOULD bind the
internal
andui
models - SHOULD NOT contain any model or UI code (only bindings).
Common library code which includes the models and business logic of the application. Its main responsibility is constructing the state used in the TUI. This package is considered the "Model" in MVC
- SHOULD be used to hold models.
- SHOULD mirror the namespace the models relate to.
- SHOULD NOT contain any UI or CLI specific code (example, IsVisible or any tea|cobra interfaces).
Elements to be presented to the user.
This is built on the bubbletea
abstraction.
This package is the ViewModel and View in MVC.
- SHOULD be used to build bubbletea interfaces.
- SHOULD be named by the component it represents.
For example,
./ui/table.go
for a reusable component or./ui/command-name/table.go
for context specific elements - SHOULD contain ViewModel state like "IsVisible"
- SHOULD NOT contain any model or CLI specific code (ViewModels/tea.Models should be composed of internal Models for testability).
The api
package is generated via oapi-codegen.
Its configuration is found under generate.yaml
and can be run with the following make command:
make generate
The full command for reference
oapi-codegen -config generate.yaml https://raw.githubusercontent.com/algorand/go-algorand/v3.26.0-stable/daemon/algod/api/algod.oas3.yml