 It's my absolute pleasure to Introduce the cupcake guy Kingsley Joseph everyone big round of hands all the cupcakes you've been having outside That's the man He's got a little shop at opposite Sony center in Indra Nagar and it's brilliant should totally brilliant He's has about over 15 years of experience in the software industry He's launched and managed multiple million dollar plus technology products. None of them had anything to do with cupcakes Kingsley played pioneering roles at sales force.com and digital chocolate in Silicon Valley While at sales force he created idea exchange which won the Forester grounds will award a webby nomination and a patent patent The idea exchange created a new genre of community apps as well as sales force comms entry into social CRM He's spoken at O'Reilly's web 2.0 expo communities exchange Facebook's developer garage and droidcon India and now Jess who he has a master's in information systems from Indiana University and MA in sociology from Anomala University as well as a graduate diploma in fashion design from NIFT dude So I have to tell you we acted as part of the program committee his talk was an automatic in he and It sounds kind of complicated, but the deal is that he went out He saw the commercial solutions that were available and he says good. I'm building my own I'm writing my own code and that's how he does it. So without any further ado ladies and gentlemen Kingsley Joseph Thanks a minute Hey guys, so everyone liked the cupcakes Awesome So little preamble to the stock. I used to geek out quite a bit I've done a lot of code in my past but right now I What you would call a very pragmatic developer like I don't write code unless I really need to and I'm gonna talk about the way I approach this problem, which is very different from the way I've approached problems in the past when I've had to develop things and Yeah, don't be scared by the big title is actually really really simple So one thing that you won't be learning here is you won't be learning any new frameworks You won't be finding out about the cool newest thing out there and honestly I didn't care about those things when I started developing this stuff what I'm going to show here is like if a Corner store owner were to write software How would he write it because that's how I felt writing this because I was under time constraints and you know I had a running shop. I had to make sure that it continued working Well all those pressures were there when I started developing this so if you need to treat me any questions You can do the two at Kingsley to calm Kingsley to on Twitter and I'll get to it in the end So a little bit about bite me my wife and I when we returned back to India This was about three years ago We tried a whole bunch of different things from bubble tea to wall decals Very lean startup kind of methodology tried to figure out what will actually work as a business Cupcake kind of cupcakes resonated with the people we made them for so I would take it to work every time my Team heated Milestone or something we would take cupcakes and people would half jokingly say you guys should open a shop So that's kind of how bite me got started and a bunch of lean startup like experiments later Including what is the price somebody would pay for a particular size of cupcake? We've kind of identified the proper sweet spot. We did a lot of very Lightweight things like going to apartments selling cupcakes there in small stalls things like that We opened a store in Indra Nagar in February this year and it's been doing fantastic If you guys are ever in it, I got to go check it out And we're looking to grow it really fast So one of the things that while I was writing this was also this idea that whatever I write should not be a using throw one-time thing So the first thing is I am a big believer in this don't reinvent the wheel, right a lot of times I worked in big enterprise companies not just sales was before that I worked for back in New York and A lot of times we would just do things all over again simply because they were not written They were not made here. So Big fan of not reinventing the wheel reusing whatever is available out there But sometimes you do have to reinvent the wheel because sometimes you are crossing terrain that a wheel cannot cross Right and it would be stupid at that point to try to stick with the wheel and you know add things to it to make it try to work So this is kind of where I was with this so I'm gonna skip some slides and come back to them later So those of you who worked in retail probably know some of this better so But for the rest of you When you're working in detail you have to mug up a menu It is a pain So one of the things we decided was that we would not price each flavor differently because we wanted to have different flavors every month so if we're going to have different flavors every month staff has to mug up the new menu every month and They have to not make mistakes when they're telling this to people So one of the things we did was all small cupcakes at the same price all big cupcakes the same price Although they're not you know price that cost they don't cost that way for us to make but we made it simple and You will learn this also in e-commerce design right like when you remove friction from a user's decision You are going to sell more so the user doesn't have to think like should I get that higher end flavor for the higher price Or should I would this lower end flavor be just as good for a lower price? You don't have to think about it. You just have to decide okay I have the appetite for a small cupcake or a big cupcake and then you decide what flavors you want in that and The other thing we did was we added combos. So this is where complexity starts happening right so Yeah, you these are these are our basics you items small cupcake big cupcake bottle of water and a coffee and Then you have gift boxes which is bulk pricing and then you have cupcake combos So you can get three cupcakes for 100 rupees, which is it you know 20 rupee discount instead of buying them separately And then we have coffee combos now suddenly just from that small inventory of four things you come up with so many possible combinations that could happen and So what happens when? My staff are billing things is that mentally they have to do this whole worksheet So let's say a group came in order eight Small cupcakes two big cupcakes three coffees. How many combos is that? Right So you have to then go and figure out. Okay, it's two so what do you do is you start with the coffee combos and then you Try and allocate big cupcakes to that and then you allocate small cupcakes to that really complex even for a small set of products all right, so Because of these things billing was really really slow and it started affecting sales initially. This was not a problem, but As sales started to pick up it took so long to get something billed that it was slowing customers down and that Inevitably leads to fewer orders for you Instead so I went out to look for a point of sale system. So this is where most Retail guys start so we go Google. There are a bunch of Miner sales systems out there go through girl possessed A lot of Indian startups actually doing point of sale systems Inexplicably on tablets without realizing that all the shopkeepers in India, I mean anyone who can afford a point of sale system already has a point of sale system Which runs on a PC and now they'll have to invest in new hardware if you're doing it in Android So as I evaluated the options I found Basically that it was really ridiculously expensive your basic point of sale system costs anywhere 50k plus per install So that's your basic. There are some online ones a very few ones and I'll talk about them before which Which actually the price is not such a big problem. They do like a monthly subscription sass model, but the this you know Hugh gaping gaping word coming is totally on point like normal is expensive because normal has identified the sweet spot where people will buy a lot of things and As I've turned out to be too much for us The other problem was then this was a bigger one is that everything was either completely online or completely offline This is ridiculous because internet is going off every other day, right? For every day for two three hours. Sometimes we don't have internet But willing has to proceed and if you have a completely online system that is not going to happen The other problem is the completely offline systems Where somebody has to still call me and tell me what the inventory levels are? So the way it works in terms of operations is that the bakery sends two deliveries to the store every day Which means in the morning where our sales are low The bakery kind of estimates how much the store is going to need But for the evening the store has to tell us by around 2 o'clock Exactly how many has sold and how much they expect to sell in the evening. So then the bakery can Backfill that inventory right like how many cupcakes they need So the problem with a completely offline system is that we're still stuck going back to a phone and calling each other and saying Oh, how many do you have? Oh, I thought you had this many. Oh, no But I brought that other thing the other time and then it's a big mess and the reason number three and You know, I don't know if you guys have taken a peek behind the cashier's desk when you get built How many of you have looked at point-of-sale systems actually? What do you guys think? right Okay, so these things are stuck in 1995 internet through upon 1980s development Okay, and you don't have to take my word for it volume volume These things are ugly Let me do these things are ugly. It's true Okay It took me nearly an hour to like narrow that clip down and make it look right With it so I went back to the drawing board and said how much is this What is it going to take for me to do this and you know, I'm not a great developer, okay? I'm a bit of a hack so I tend to get things out relatively quickly and I'm going to be a little ashamed of showing you my code today, but I'll show you anyways. It's not It's not phenomenally clean or anything But these were my basic principles right first is UX has to be drastically straightforward nothing like anything that I've seen any of the point-of-sales rethought from ground up for you know fast efficient counter usage and That means people should not be calculating combos at the point of sale So if I'm able to put in that there were eight small cupcakes three big cupcakes two coffees It should calculate the best combo for the customer for me right away Okay, so that's one thing and the other thing is that those of you who worked in retail might know that in most retail Situations employee turnover is fairly high. So people come people go we employ part-timers. They need to be trained so we don't have a lot of time to sit and train people and You know, I've seen this with friends of mine who have restaurants and they spend so much time training anybody who comes in On how to use the menu system. So eventually what happens is that people tend to? Find one person and somehow coax them to stay whose entire job is just managing the point-of-sale system And the second thing I wanted is to make sure that it was offline first So offline it should work regardless of whether internet is there or not the billing system should work because the customer wants a bill it should be able to print something out and give it to them and The third is I want to be able to go to more outlets soon like we're six months down We're already looking at a second and third outlets and some other distribution channels So I want this to be able to scale really well at least I wanted to scale at least across Bangalore to about six seven outlets and How easy is it to deploy because one of the things with That I originally thought of was we'd run a server at every Outlet which would use Python or PHP to use a UI and like store everything in a MySQL DB locally But then in order to deploy on that I'd have to go there and change files or have something that's And be able to restart servers remotely all of these problems so and Third is that I want some kind of online reporting. So if there's no internet There's no choice. We still have to call each other and find out what's going on but if there is internet, I want everything to be automated and And easy to evolve based on usage. I figured this is another thing where I'm new to retail I've never on a store before I have actually before this. I have not even worked in retail I've done a lot of retail studies, but I've never actually worked in retail. So I Figured requirements are going to change I'm going to change the requirements because I'm the idiot doing the requirements now Like at least when you're a developer you can blame somebody else and say like idiot client Doesn't know what he wants. I'm that idiot client to myself So Yeah, some old pictures. So this is our store display any day we bake between 10 to 12 flavors So this is again one of the reasons why we decided to go for simplified pricing So every day we could change the flavors and not have to worry about changing the menu Okay, so I'll cut to the demo Can we change the resolution? Okay, sorry about that. So like I said, I'm not proud of the code Okay, but I'm proud of the fact that it works and it serves our purposes. So yeah, it's not responsive. It is designed more or less for like a fixed width of a 14-inch monitor and Here are the basic things about the POS you can actually like I said my first specification was the UX has to be right and People should be able to put in exactly what they sold and it should calculate. So I'm going to go in here and put in eight three two Right and it updates life And it gives you a live preview of the bill that will actually get printed and If you notice that it is calculated correctly the combos right, so Are those eight cupcakes? So many went into combos and so many went into coffee cupcake combos and some went into cupcake only combos and things like that and I don't know if it's noticeable to you the Background color is changed to green. This means that it is a unsaved order so One thing that happens a lot in a store is in a restaurant type situations We're not a restaurant with just a small cafe type situation Is that people will come and take things and they'll pay after they have them So you need to keep tabs open for people and one of the fun things about this is that it literally is a tab so you just open a new tab and This is set to the home page in my store so you can just open a new tab and you know start out another table so if you have two tables going on you can just like Keep them going in parallel and make the additions as you make them So now these guys came in and they're taking 12 big cupcakes that becomes three big bite you know four big bite combos and And they're going to take So we sell these little letters that you can put on the cupcakes to customize them and they sell for 10 rupees each So if you took five, it's going to believe 50 rupees, but if you take 12 that becomes a combo again, and you get only it's only 100 rupees So it automatically calculates all these combos You restart the browser Till you hit save it doesn't store When you when you hit save it stores But that could be a good thing to do in the meantime to also store the updated values in local storage So I'll tell you what happens now. So If you guys want to see the code that calculates the combos Yeah Okay, so this really stupid function is called smart bill and I This is not my usual writing style I've kind of written it in the hope that I'll soon find somebody else who can take care of it for me And I've kind of written it in a very very Explicit style that I usually don't use for my own code. So Cupcakes and every, you know element is taken stored in a value and then You can see that the beverage for combos are calculated first. So you see like how many coffees Sold is kind of the starting point and then cupcakes are reduced based on that if there are enough cupcakes So if you sold two coffees and no cupcakes were sold no combos will be calculated But if you sold two coffees and two cupcakes were sold one coffee will get allotted to a Cupcake coffee combo and the other coffee will be built separately. So you will be paying 140 So it's not super complex logic, but I wanted to write it in a very very straightforward Imperative way on purpose so that anyone else who comes after me can also understand this code At least at a very gross level and you know replicate it for any other skews we need to add and Then it updates the book pretty simple. Okay, so I'll show you what happens now. So once you build somebody like this bill is for 900 rupees, I just hit enter and It goes into this bottom part this previous bills area The reason is that earlier I used to have a print key here So that they could either save or print the bill which was really convenient Except it wasn't because most customers don't want a bill. They would just crumple it and toss it on the desk and go keep going So what we realized was that to reduce clutter. We should not print bills Unless somebody asked for them and I know some people actually get upset if you don't print a bill So we need to have a way to print bills for things that we have already built. So So that's where this comes in so you can go in there and print any bill that has previously been made and The printing works very simply by using print CSS. So I could You hit print and it basically pulls up the print dialogue There's a chrome setting which can which will let you suppress print preview. So I've got that done so that So I've got it done so that the print dialogue is suppressed So it goes straight to a thermal printer which will just immediately print the bill So as soon as you hit print the bill comes out of the printer and the customers good to go And this data is all stored in local storage at this point, okay? so and There's also another trick here. You can actually print a bill without saving it. So let's say I bought five cupcakes Forgot to bill and wanted to print all I have to do is press command P or print on the browser And it will do the same thing basically it pulls up the bill and prints it and this bill doesn't need to be saved So that's kind of some of the functionality On top it shows a multi-day activity log so this While the bills show you like how many combos you build and how many Actually building items that you've done what we need to do what we need to know Often at around 2 o'clock in the afternoon is how many cupcakes are there in the store? How many have you sold so we can send you more cupcakes? So that drop down at the top shows you exactly how many cupcakes were sold how many water bottles were sold How many paper bags were sold and all the fun stuff? So this gives you the aggregate of all the sales made that day and it is also a drop down So if my store manager wants to go and check because the store manager leaves by 7 Evening stuff comes in after that and then when they close the store the store manager is not there So when he comes in in the morning the next day, he can check that drop down and see like oh So we made that many sales yesterday, right? And then he writes in the cash book and make sure that the cash in the counter is what it is supposed to be according to this So now I'm going to talk about what we do after this. So At this point it did everything that your regular point of sale does which is you can build It will print out a bill and it stores it in a database and I could just go home after this technically, but I decided I wanted to get it online also and In this store in within So my wife and I manage the bakery together between us we use Google apps a lot So we have Google Docs Google spreadsheets for everything from, you know bill payments for Electricity and water to everything we use Google spreadsheets to keep track of what is going on and it helps us collaborate because you know a lot of times we're not in the same place and We have a point of record for everything. So that seemed like the natural place to put this so where It would be useful to see this data But at that point I didn't know how to do it So I started googling around to see if anything could be done about it and I discovered the existence of Google Apps script How many of you have heard of Google Apps script? Cool. So what it is it is like how many of you have done visual basic for Excel? I just dated myself Okay, so if you get so Excel used to support visual basic as a scripting language So you could anything that you couldn't do with ridiculously complex formulas you could do with ridiculously braindead visual basic code so and Google Apps script. I'm not saying it's braindead code. It's actually JavaScript and it's Pretty sweet because the APIs are there to tap into pretty much all of the Google apps Applications that you might be interested in working with doc spreadsheets calendar everything is in there and the documentation is fantastic So I'm not saying this is perfect for every use case But this worked really well for us and it's might be something that you might want to take a look at So what I've struck done is I've structured our Google this is all automatically generated by the way, so I haven't actually done anything here So the directory structure here is if you notice there's a store data folder and there's a Bangalore Indranaga folder So I'm anticipating that we'll have a lot more folders and the store data in the future So under each folder, I have controlling access rights using very basic Google permissions So I've created a user called Indranagar at bitemecompany.com Who's our store user and who has update rights to this folder and has but Read and update rights to this folder, but nothing else and I am the admin for this folder And I can add more users if I wanted to but the Indranaga user cannot themselves So access control comes cheap with the Google Drive system itself. So that's how it is structured Earlier we used to store each month in a separate spreadsheet But now we're trying to consolidate that and have only years in spreadsheets This is what it looks like right so Very simple Year 2013 month September this date. This is what we've sold so this gets updated on a 30-second interval basis right now Sometimes I've adjusted it lower because if Google servers get hit too often They sometimes respond with your hitting us too hard kind of thing. So That's basically it. So and what and how this happens is There is a very simple file. This is not even very big and you can notice that if you notice, it's all JavaScript There are like three or four functions inside this and what it does is this is a JSONP service So I call it through script insertion My basic point of sale is just a very simple HTML file, which I sync through Dropbox So I just make changes and save it and it gets synced to the store as long as internet is available and That file then calls this service So the server sync method Calls the API endpoint with the store ID the store ID is nothing but the Google Docs folder ID that is the store ID and Send an update which is a stringified JSON of the last summary, which very simply says so many cupcakes So many big cupcakes so many coffees and so this is the amount sold amount and then it just logs the response back and that calls this service this service gets the input data and checks to see if This spreadsheet exists if it doesn't it creates this spreadsheet. So for example This get base sheet method, which is here So you can access all the Google applications like drive app that get folder by ID is the store ID So it gets that folder checks to see if there is a file by name the year And if there is no file called 2013 it will create a new file called 2013 and it will add that file and the create file actually calls this function which uses a spreadsheet application to create a spreadsheet file and gives The current running so I'll talk about publishing models it makes me the admin of that file and attaches it to the store folder and Then you come back and it then checks to see if there is a tab inside that spreadsheet for the current month for September if there isn't it will create a tab and it'll add the header rows to that and Every time an update comes in it will check to see if It'll check the last row basically and see if the date corresponds with the update that has come in and if it has if it corresponds then it overrides that row with the New update and if it doesn't then it happens a new row So very very simple logic That's what it's supposed to do and the way Appscript work is works is that you store versions of it What you do is you create a new version of it every time you make a change Which is slow I guess this is not important so I'll skip this part Okay, and then you publish it and you deploy it as a web application and you can Typically as a web application when it's deployed it gets served up as HTML But in the return for return method with the return call of the do get method You can specify that it is not an HTML file and you can set a mime type and in this I'm sending json back Actually, I'm sending jascript back Because it's a json p thing So here if you look at deploy as web app, it will give you a URL at which this is available So this is actually my API endpoint But if you want to make some changes and test your code This URL is actually your dev endpoint So you can make changes to your code and test it against the dev endpoint And if it is good then you can commit it into a version and publish that as the published endpoint So this really helps with debugging so I use this a lot and Then here's the interesting part you can execute the app as X so When my store manager signs into the app he signs in as the Indira Nagar user So everything he does will execute with the same permissions as I've given the Indira Nagar user Which is fantastic for access control so I can make sure that he can modify any file inside the Indira Nagar folder And the code can modify any file inside the Indira Nagar folder But only if it is coming from the Indira Nagar store So every store will have its own Google ID and as long as they're logged in with that They will be able to modify their own data, but not anyone else's and they have no access to the code so even though the code executes with their permission, they are not able to access the code that I have and You have to log in with the byte me company ID in order to use it so that's another way to lock it down So, yeah, so Are we doing that time? So, yeah, that is the basics of the application I don't think I missed any features and I think we have 10 more minutes approximately. So I guess we'll go for questions Can you show us the part? Can you show us the part where it's pushed into Google apps? It'll take 30 seconds So, yeah, as long as the internet connection works, so We can do another question. Oh, yeah, there we go So it's hit my breakpoint where it calls the JSON PAPI have updated it Shit didn't So that oh it got a response. It's just not I might have to refresh this page Oh, yeah, it's gone and put a lot of dates in there No Okay Something wrong I made a copy of the script to Show you guys and something seems to be off But yeah, it's gone and put some kind of Lot of dates in here crazy Yeah, sure I can't hear you at all I'm curious about the various existing online and offline solutions that you consider in how the fair Oh, sure. Um, so I looked at one called go frugal, which is primarily offline Uh, another one was called posist, which was interesting where it was only off online Uh, so those were the two big ones in India There are a lot of like It's a very fragmented market actually and usually it's sold integrated with the hardware So you basically go and buy the hardware the printer the scanner everything together and uh Unfortunately, it's also very targeted at supermarket type situations in India So that's the reason actually the UI is pretty ugly. It's because they really have a lot of skills to take care of Anyone else I think those did you want Uh on that note then a big round of applause for Kingsley