Poké-Fun with Kotlin and Arrow
Welcome! In this guide we (well, actually you) are going to work on an application to build decks for the Pokémon Trading Card Game (TCG). Each chapter roughly corresponds to a different functionality: loading decks, searching cards, and so on. Following the spirit of these times, we also hint at using (local) AI in the application.
The source code is available in this repository. Download or clone it, and you should be ready to go.
This book assumes that you know your way around Kotlin, but previous experience with functional programming or Arrow, or with Compose Multiplatform, is not required.
For ease of development, the provided skeleton is a desktop application. Using Compose Multiplatform you can easily make it run in Android or iOS devices, with minor modifications.
The starting point introduces the domain and the main components of the technology.
- If you have never heard of the Pokémon Trading Card Game or don't know the rules, start with the introduction to the domain;
- If you are new to the Kotlin Toolchain or Compose Multiplatform, start with the technology,
- If you are new to local LLMs for AI, follow the local LLM setup instructions.
Poké-Fun uses the Kotlin Toolchain as build tool, as opposed to the most usual Gradle. In particular, you need to install the corresponding plug-in if you are using IntelliJ or Android Studio.
Afterward, the overview describes the main components of the given code. The rest of the guide is divided into a series of largely independent sections, so you can choose what you want to work on. Each section contains an introduction to one or more topics, and pointers to additional tutorials or documentation about them.
- What is (in) a deck: model data using data classes and sealed hierarchies.
- Law-abiding decks: check that the deck follows the rules, and learn about
Raisealong the way. - Deck building: design a good
ViewModelusing functional principles, and design undo/redo with actions-as-data. - Deal with bad internet: improve the experience with
ScheduleandCircuitBreaker, and cache results using memoization. - Through the magnifying glass: use optics to improve the code, and use local storage for card data.
- Loading and saving: store your work locally, and learn about parallel combinators in Arrow Fx.
- Better architecture: introduce resource management, and overall nicer design.
- Nicer UI: implement more visual feedback using Compose Multiplatform.
- Fancy deck titles: learn the basics of AI agents to generate titles for the deck.
- More ideas for AI: use more AI functionality to spice the application.
Many of these sections complement the book Functional Programming Ideas for the Curious Kotliner.