Fitcoin
About This Project
Fitcoin is a service that encourages users to take care of themselves. It grants users a virtual currency in exchange for health and well-being activities, such as burning calories, meditating, and sleeping. This currency can be used in games that implement the Fitcoin API to purchase in-game items.
NOTE: As much as I'd love it to be, Fitcoin currently doesn't have a persistent server running. In order to test this code, you will need to spin up your own copy of the Fitcoin Server and the appropriate URLs in the code.
Background
When I was in middle school, I owned a video game console called the Nintendo 3DS. This game console had a built-in pedometer with which it tracked the user's steps. For every 100 steps the user took, they would earn one "Play Coin", which could in turn be exchanged in various games for small rewards or hints. I really liked this concept, and it stuck with me for quite a while.
Many years later, I bought a Nintendo Switch, and with it, the game Ring Fit Adventure, with which I promptly fell in love. Nintendo did an amazing job of gamifying exercise and taking care of oneself, both with Ring Fit Adventure recently and with the Nintendo 3DS Play Coins many years ago. Since then, working on projects that can help a user's wellbeing has become a priority for me.
Playing Ring Fit Adventure brought me back to memories of the Nintendo 3DS's Play Coins, and it occurred to me that there was a lot of untapped potential with the concept of a virtual currency tied to self-care. The Play Coin system was tied only to the user's step count, but with the capabilities of a modern smartphone, many more statistics can be tracked and recorded. Recreating and expanding on the Play Coin model would also require me to develop a variety of different system components.
Components
The Fitcoin service is made up of three major components: a web server which handles the underlying database and API requests, an iOS app which allows a user to manage their Fitcoin balance, and a game API which allows developers to create games that users can spend their Fitcoin in.
Fitcoin Server
The Fitcoin Server handles API requests from users and game services. This includes:
- Creating user accounts
- Getting the balance of a user account
- Getting the transaction history for a user account
- Getting the game services linked to a user account
- Linking a game service to a user account using a QR code
- Creating a game service
- Making Fitcoin purchases for a game service on behalf of a user account
The server logic is written in Python with the Flask library, and uses MongoDB for its database.
Fitcoin App for iOS
The Fitcoin iOS app provides an interface with which users can manage their Fitcoin account. This includes:
- Viewing current Fitcoin balance
- "Depositing" Fitcoin to account based on Active Energy (calories burned) in the Health app
- Viewing history of Fitcoin transactions (in-game purchases and deposits)
- Viewing list of linked game services
- Linking game services by scanning a QR code
- Unlinking game services
NOTE: The Fitcoin iOS app currently does not have support for logging into or switching accounts; the account credentials are hardcoded. If/when I return to this project in the future, this will be one of my top priorities to fix.
Fitcoin for Unity
Fitcoin for Unity provides an API for Unity game developers to link their games to the Fitcoin service with ease, using asynchronous function calls.
To test and showcase the API, a simple example Unity project was concurrently developed that demonstrates the API's capabilities.
What I Learned From This Project
- Server and REST(ish) API design
- Working with the MongoDB database system
- Interfacing a SwiftUI app with a REST API
- Interfacing a Unity C# game with a REST API