Building an Order-Ahead app

Mobile app for pick up orders

Anshil Bhansali, Oct 17, 2020

This was an idea of a friend of mine, Jack Shalom . He had a vision to build a platform which can quickly spin up a new mobile app for a restaurant that can be marketed for their customers to place pick up orders. Our target market was small mom-and-pop shops in NYC that were using some sort of modern POS (Point of Sale) system.

Our MVP goal was to build platform that integrates with the Square API , since that is the most common POS system. My responsibility was to build the entire back end system, which included writing the business logic, provide an API interface for the mobile client, and hosting the infrastructure in a cloud environment.

This was an interesting project for me to work on because it was just 3 of us (designer, backend developer, front end developer), and we mainly communicated over the internet via Slack, Google hangouts and phone calls. Therein, we ensured to communicate our goals, progress and deadlines clearly and honestly so that we were all on the same page. We used Trello for task management, and Google docs for documentation for the API contract.

My goal with the backend was to build it in such a way, so that all restaurant apps can use a common, scalable backend system. This meant all the data stored in a single MySQL database, where the schemas were designed in a scalable way, and a fleet of EC2 machines with a load balancer and autoscaling configured.

We effectively built a successful MVP that included the following features. Users of the app can - create a profile and store credit card information, view the menu (in real time), place an order (which shows in the Square admin interface), re-order from order history, and allow users to earn and redeem loyalty points. The points system was simple - 1 point per dollar spent. Along with this, I custom built the authentication system with JWT tokens, and reset password functionality by sending emails with Sendgrid API.

Of course, the major development of the MVP relied on the Square API. But the loyalty point system was completely custom built by me - The points data is stored in our MySQL database. One of the major challenges in this development was making sure the data is synced with Square.

The merchant's Square system is where the menu data, customer information and credit card information wasd stored. I chose not to store that in our database. I applied an approach deciding to store references to Square objects in our database, so that we could consistenly query the Square API for the freshest data. Eventually, I planned to incorporate a caching mechanism for faster retrieval, and a webhook from Square to bust the cache when the data changes.

The most complicated piece of development was the functionality to allow a customer to place an order. The tricky part was allowing a user to redeem his/her loyalty points, which effectively was a 'discount' on the order. The discount was pure dollar based. This means if a customer redeems 3 points in a $10 order, the effective charge should be $7, and the customer should earn 7 points. Applying a discount with Square and having it show up in the admin interface as a 'Discount' forced us to use the Square discount objects, thus we had to store references to Square 'Discount' objects in our database. This also meant if the customer was redeeming $5 (5 points), and if the merchant's Square system did not already have a $5 discount in it, my backend would need to create it and maintain it.

I hosted it in AWS with an EC2 machine protected by a load balancer. I also configured an autoscaling group to increase the amount of EC2 machines to a max of 3 when the CPU usage is over 70%. This would handle issues such a peak time traffic during lunch or dinner time.

All in all, we successfully made our MVP and it was quite satisfying to use it. Eventually, I chose to leave the team as the pandemic hit and I wanted to work on another idea of mine. It was a great experience working with them and I learned a lot from the experience!