Building a 10-min Grocery App - Building Product Inventory
Time to build - 10 minutes
Last updated
Time to build - 10 minutes
Last updated
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.
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.
Our tutorial assumes that you have already , picking the cloud of your choice.
.
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.
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.
The name of the model should match the collection name (table name) in your database. Keeping it Products
would create a collection named Products
in your MongoDB database.
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.
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.
We will not be mentioned _id
as it is going to be auto-generated by our database (MongoDB) for us.
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 -
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.
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 -
You 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.
You can now also check if the Product is successfully created in our system by calling the List Products API that we had created -
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.
Cosmocloud let's you test your APIs on development mode before deploying or releasing a version. This means, anything on your DRAFT state can be tested instantly on the already in your Cosmocloud project.
To customise your APIs and add more custom logic into them, checkout our .