ki

command module
v0.0.0-...-6dd11c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 1 Imported by: 0

README ΒΆ

ki banner

πŸ‰ KI - Dragon Ball CLI TUI

A beautiful Terminal User Interface (TUI) for exploring the Dragon Ball universe, built with Go and Bubble Tea.

Dragon Ball CLI Go Version License

CI codecov Go Report Card

πŸ“‹ Table of Contents

✨ 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:

  1. Model - Application state
  2. Update - State transitions based on messages
  3. 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 characters
    • GET /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
  1. Add API endpoint in internal/api/client.go
  2. Define message types in internal/tui/commands.go
  3. Update model in internal/tui/model.go
  4. Handle messages in internal/tui/update.go
  5. Render UI in internal/tui/view.go
Code Style

This project follows standard Go conventions:

  • gofmt for formatting
  • golint for linting
  • Meaningful variable names
  • Comprehensive comments

πŸ“¦ Dependencies

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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


Made with ❀️ and β˜• by Dragon Ball fans, for Dragon Ball fans.

Over 9000! πŸ’ͺ

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
internal
api
tui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL