Building a 10-min Grocery App - Building Product Inventory
Time to build - 10 minutes
10-min grocery apps are all the craze in India right now, everyone trying to build a marketplace of groceries and daily household items to be delivered within 10-30 minutes to you.
Have you ever thought how you can build a similar app yourself, using No-Code in just minutes? Let's see how we can do that with Cosmocloud, a Backend-as-a-Service (BaaS) platform to create complex backend layers for your application.
Our Agenda
Building the inventory system to modify products in our application. (This blog)
Building out the marketplace using Full Text Search on Cosmocloud.
Integrating with Payment Gateway to record successful payments.
Firing events to Queues for shipping out Orders.
Prerequisites
Our tutorial assumes that you have already created a project on Cosmocloud, picking the cloud of your choice.
Building Product Inventory
The basic requirement of a 10-min grocery app, is to build an inventory of products in the system, having APIs for the following operations -
Create a new Product in the system
Fetch a list of Products in the system (this is different from search)
Fetch a single Product
Update (or Patch) a Product
Delete a Product.
Building the Product DB-Model
The first step in Cosmocloud is to build your database models of entities defined in your system. We will be creating our Products
model first.
Navigate to Application Layer -> DB Models to create new database models in Cosmocloud.
Click on New Model button.
Enter the name
Products
as the model name, add a description and click on Create.Switch to the Schema Tab on the top to define the schema of our Products model.
Defining the schema of our Products model
As Cosmocloud is connected to your MongoDB database, we can define a Document Model based schema for our Products
model.
Click on JSON to Schema button to quickly generate schema from a sample
Product
record.Copy the snippet below as the sample record in our
Products
model.
{
"title": "Whole-wheat Bread",
"description": "A 100% wheat based bread, made by company X.",
"category": "Breads",
"price": 19.5,
"availableQuantity": 100,
"categoryProperties": {
"brand": "X",
"size": "onesize",
"weight": 500,
"weightUnit": "grams"
}
}
Click on Save button to instantly generate the schema of your
Products
model as well as save it in the system.

You can mark your preferred fields as required such as title, description, price, etc and then click on Save button.
Once saved you can see the Products
model in DRAFT state in DB Models listing page -

Creating our Inventory APIs
As mentioned above, we need to create these APIs for our Inventory feature on Cosmocloud -
Create a Product
List the Products in our system.
Get a single Product
Update a Product
Delete a Product
To do this, you can quickly create these APIs using Cosmocloud's API Templates -
Head over to Application Layer -> APIs.
Click on Create API button, and select Browse Templates.
Chose Entity CRUD APIs to start creating our required APIs
On step 2, select the DB Model we created (Products) to create the APIs for.
Step 3 will ask you to review the APIs you need to create for your feature. Keep all selected, as well as all the models selected, and click on Finish.

As you can see, Cosmocloud immediately created all the APIs required for our Products inventory feature, ready-to-use.
Testing our Product Inventory
Creating a Product
Now to test the APIs, let's start by creating a Product in the system. You can open the Create Products API and copy the Development Endpoint from the API Details page -

To test it out from Postman, you would need to copy your Project ID (you can click on your organisation name on top left) as well as Environment ID (you can get this in Environments section inside your Project), and pass these both IDs in headers on Postman -

projectId
and environmentId
in Heaaders on PostmanYou can now pass in the Request Body to create a new Product -

As you can see, we created a new Product in the system, and it returned the ID of the new Product we just created as the response.
Listing Products
You can now also check if the Product is successfully created in our system by calling the List Products API that we had created -

Conclusion
This was super easy and fast to build, right? That's how Cosmocloud helps in Developer Productivity, eliminating all repetitive steps of setup, and boilerplate as well as deployments and cloud, all in a single No-Code platform.
We saw how to create Products Inventory for our 10-min grocery app's backend layer in this article. Next we will see how we can create a marketplace using Full Text Search, add a strong searching experience as well as filters experience, using Cosmocloud's platform.
Last updated