### BlueRing was probably one of my first ventures into the world of web API’s and frontend dev, back in 2011-2012ish timeframe. This page is preserved so I can cringe at what I didn’t know and how bad it really was.

# Project BlueRing on Github

Project BlueRing started out as a way of keeping track of my house pantry inventory. This would then in turn be used to make a shopping list as things got low, however it quickly grew into a much larger scope, and has now grown into a full API design project.

BlueRing is now becoming an inventory control API which provides:

- Product Information retrieval
- Updating, deleting and adding new products
- (Product Pictures and thumbnails are also generated if supplied in the update or addition calls.)
- Placing and viewing orders
- Generating graphs/charts of the percent of units per day and the stock usage chart

In addition to this, BlueRing has a learning algorithm which runs every time a product is restocked, which tries to guess when the restock quantity will reach 0 units. This algorithm is part of the biggest challenge for this API.

Future versions will hopefully (or possibly) include:

- A better learning algorithm, or one more fit for the purpose
- Advanced Order handling system
- More graphs and charts
- Product pricing and a small amount of accounting software
- Shopping list generation of product running low
- Improved ranking and flagging systems
- Improved PDF and HTML outputs to go in stride with the JSON output of the API

I have never worked with an API system like this, so this whole project has been a major learning curve, however it has helped me tremendously with advancing my programming skills and knowledge, along with given me a sort of a head start with API systems which I may program in the future.

# License

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

# Predictions

Currently a linear regression algorithm is used to make the predictions. This will eventually be adapted to meet the shape of the product use data, and paired with a classification algorithm to help predict which products need to be restocked soon.

\begin{equation}\label{eq:linear}

\hat{y_{n}}=mx_{n}+b

\end{equation}

\begin{equation}\label{eq:dm}

\frac{d}{dm}\sum_{}^{}{(y_{n}-\hat{y})^2}=0

\end{equation}

\begin{equation}\label{eq:db}

\frac{d}{db}\sum_{}^{}{(y_{n}-\hat{y})^2}=0

\end{equation}

Solving these with some “Fuzzy Math” one can get m and b to equal:

\begin{equation}\label{eq:m}

m=\frac{\bar{x}*\bar{y}-\bar{xy}}{(\bar{x})^2-\bar{x^2}}

\end{equation}

\begin{equation}\label{eq:bm}

b=\bar{y}-m\bar{x}

\end{equation}

\begin{equation}\label{eq:b}

b=\bar{y}-\frac{\bar{x}*\bar{y}-\bar{xy}}{(\bar{x})^2-\bar{x^2}}*\bar{x}

\end{equation}

In Python this was fairly easy to achieve, and functions fantastically. The data must be normalized however, meaning that quantity change must become a percentage, and the time between the restock and the change of quantity in days must be used. Again, with the datetime module of Python, this was fairly easy to achieve.