Welcome to Koi https://koirewards.herokuapp.com/
Koi is a webapp that helps its users optimize transfers among their credit card, hotel, and airline reward points.
Note:
- User password is hashed upon login via flask.bcrypt.
- The webapp is by no means a commercial product and does not aim to function as one.
Let's explore all the functionalities the dashboard provides for users.
#####$ Update Balance (not shown)
- Add/update program balances
- Editable-select1 drop-down
#####$ Transfer Points
- Transferred From: List of programs within user portfolio with point conversion
- To: Dynamic list rendered post-AJAX call to database based on Transferred From selection
- Ratio: Ratio between the selected outgoing and receiving programs
Transfer Constraints:
- No balances, beginning or ending, can be negative
- Transfer amounts are full-points
#####$ Point Distribution
- Donut Chart rendered via Chart.js
- Section colors are generated dynamically based on the # of programs and have unique RGB
- Code inspired by stack overflow answer[2] [2]: http://stackoverflow.com/questions/43044/algorithm-to-randomly-generate-an-aesthetically-pleasing-color-palette
def generate_random_color(ntimes, base=(255, 255, 255)):
""" Generate random pastel blue-green and red-orange colors for charts """
colors = set()
i = 1
while len(colors) < ntimes + 1:
if i % 2 == 0:
red = random.randint(0, 50)
green = random.randint(150, 170)
blue = random.randint(155, 219)
if i % 2 != 0:
red = random.randint(240, 250)
green = random.randint(104, 168)
blue = random.randint(0, 114)
if base:
red = (red + base[0]) / 2
green = (green + base[1]) / 2
blue = (blue + base[2]) / 2
color = (red, green, blue)
colors.add(color)
i += 1
return colors
#####$ Program Balances
- All tables are jQuery datatables3
- Searchable, sortable, enables column re-order and pagination, and have fixed headers
- Click x to delete a program balance
#####$ User Actions
- User selects a goal program whose value he/she would like to maximize
- User inputs a goal balance for the goal program
- Press Run Optimization
- Press Yes to commit transfers within Koi profile
#####$ Visualization of how programs map to each other4
- function renderD3 makes AJAX call to server
- Server returns jsonified mapping for the user's portfolio
- Full D3 of all programs on Koi can be found in the Visualize section of the Homepage.
Brief overview of the calculation process. For more information, please see helper.py.
#####$ function optimize (start)
def optimize(user_id, source, goal_amount, commit=False):
""" Optimizes points transfer """
* source = goal_program
#####$ function bellman_ford 5 returns:
def bellman_ford(graph, source):
# example_min_cost: [(16, 0), (212, 0.0), (164, 1.0986122886681098), (6, inf), (170, inf), (187, inf)]
# example predecessor: {164: 212, 6: None, 170: None, 16: None, 212: 16, 187: None}
- Array of node-to-cost tuples
- Hashmap of nodes and predecessors as key, value pairs
#####$ function make_path constructs possibly paths with doubly-linked lists
def make_path(current, source, predecessor):
#####$ function is_route_possible applies balance ceiling and whole-point transfer constraints
def is_route_possible(user, goal_amount, node):
""" Return True or False if path is viable """
return goal_amount <= balance_capacity(user, node)
#####$ function optimize (end) returns optimal path with involved programs, transfer amounts, vendor urls, and ratios.
Upon update, deletion, transfer, and commitment to optimized transfers, users can view their entire transaction history on their Koi profile.
Still here? Walk through the progress of Koi development with us!
Week 1
Week 2