README
ΒΆ
π KI - Dragon Ball CLI TUI
A beautiful Terminal User Interface (TUI) for exploring the Dragon Ball universe, built with Go and Bubble Tea.
π Table of Contents
- Features
- Installation
- Usage
- Project Structure
- Architecture
- API Integration
- Screenshots
- Development
- Contributing
- License
β¨ Features
- π¨ Beautiful TUI - Styled with Lipgloss for a modern, colorful interface
- π Two-Tab Layout - Browse Characters and Planets separately
- π Async Data Fetching - Non-blocking API calls with loading indicators
- π Pagination Support - Navigate through large datasets with ease
- β¨οΈ Keyboard Navigation - Intuitive controls for quick browsing
- π― Real-time API Integration - Fetches data from the Dragon Ball API
- π Fast & Responsive - Built with Go for optimal performance
- β Error Handling - Graceful error messages when API is unavailable
π Installation
Prerequisites
- Go 1.25 or higher
- Terminal with 256 color support (recommended)
Install from Source
# Clone the repository
git clone https://github.com/bilalbaraz/ki.git
cd ki
# Download dependencies
go mod download
# Build the application
go build -o ki
# Run the TUI
./ki tui
Quick Install
go install github.com/bilalbaraz/ki@latest
π Usage
Launch the TUI
ki tui
Keyboard Controls
| Key | Action |
|---|---|
Tab / Shift+Tab |
Switch between tabs |
1 |
Jump to Characters tab |
2 |
Jump to Planets tab |
β / k |
Move selection up |
β / j |
Move selection down |
β / p |
Previous page |
β / n |
Next page |
r |
Refresh current tab |
q / Ctrl+C |
Quit application |
Command Line
# Show help
ki --help
# Launch TUI
ki tui
# Show version
ki version
π Project Structure
ki/
βββ cmd/
β βββ root.go # Root Cobra command
β βββ tui.go # TUI launch command
βββ internal/
β βββ api/
β β βββ client.go # API client for Dragon Ball API
β β βββ types.go # Data models (Character, Planet, etc.)
β βββ tui/
β βββ commands.go # Tea commands for async operations
β βββ model.go # Application state model
β βββ styles.go # Lipgloss styles
β βββ update.go # Update function (message handling)
β βββ view.go # View function (rendering)
βββ go.mod
βββ go.sum
βββ main.go
βββ README.md
ποΈ Architecture
The Elm Architecture (TEA)
This application follows the Elm Architecture pattern used by Bubble Tea:
- Model - Application state
- Update - State transitions based on messages
- View - Rendering the UI from current state
State Management
type Model struct {
// API client
client *api.Client
// UI state
activeTab Tab
ready bool
// Data
characters []api.Character
planets []api.Planet
// Loading states
charactersState LoadingState
planetsState LoadingState
// Pagination
currentPage int
itemsPerPage int
}
Message Flow
User Input β KeyMsg β Update() β Model State Change β View() β Render
β
API Command β goroutine β Response Msg β Update() β Model
Concurrency
All API requests are wrapped in tea.Cmd functions that run asynchronously:
func LoadCharactersCmd(client *api.Client, page, limit int) tea.Cmd {
return func() tea.Msg {
resp, err := client.GetCharacters(page, limit)
if err != nil {
return CharactersErrorMsg{Err: err}
}
return CharactersLoadedMsg{Response: resp}
}
}
This ensures the UI remains responsive during API calls.
π API Integration
Dragon Ball API
This application uses the Dragon Ball API:
- Base URL:
https://dragonball-api.com/api - Endpoints Used:
GET /characters?page={page}&limit={limit}- List charactersGET /planets?page={page}&limit={limit}- List planets
Data Models
Character
type Character struct {
ID int
Name string
Ki string
MaxKi string
Race string
Gender string
Description string
Image string
Affiliation string
}
Planet
type Planet struct {
ID int
Name string
IsDestroyed bool
Description string
Image string
}
Error Handling
The application gracefully handles:
- Network timeouts
- API errors (4xx, 5xx)
- JSON decoding errors
- Connection failures
All errors are displayed to the user with helpful messages.
π¨ Styling
Color Palette
The UI uses a Dragon Ball-inspired color scheme:
- Primary (Orange):
#FF6B35- Energy/Power - Secondary (Golden):
#F7931E- Super Saiyan - Accent (Cyan):
#4ECDC4- Ki/Aura - Background:
#1A1A2E- Dark space - Error (Red):
#FF4757 - Success (Green):
#2ED573
Components
All UI components are styled using Lipgloss:
- Tab bars with active/inactive states
- Bordered content areas
- Styled list items
- Color-coded status indicators
- Loading spinners
π οΈ Development
Running in Development
# Run without building
go run main.go tui
# Run with race detector
go run -race main.go tui
Testing
# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run specific package tests
go test ./internal/api/...
Adding New Features
- Add API endpoint in
internal/api/client.go - Define message types in
internal/tui/commands.go - Update model in
internal/tui/model.go - Handle messages in
internal/tui/update.go - Render UI in
internal/tui/view.go
Code Style
This project follows standard Go conventions:
gofmtfor formattinggolintfor linting- Meaningful variable names
- Comprehensive comments
π¦ Dependencies
- Bubble Tea - TUI framework
- Lipgloss - Style definitions
- Bubbles - TUI components (list, spinner)
- Cobra - CLI framework
π€ Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Ideas for Contributions
- Add character details view
- Add search/filter functionality
- Add transformations tab
- Add export to JSON/CSV
- Add favorites/bookmarks
- Add keyboard shortcuts customization
- Add config file support
- Add caching for offline viewing
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Dragon Ball API - For providing the awesome API
- Charm - For the incredible TUI libraries
- Akira Toriyama - For creating Dragon Ball
π Contact
- Author: Bilal Baraz
- GitHub: @bilalbaraz
- Project: ki
Made with β€οΈ and β by Dragon Ball fans, for Dragon Ball fans.
Over 9000! πͺ
Documentation
ΒΆ
There is no documentation for this package.