stockControl 馃馃カ馃 - A comprehensive system for tracking recipes, ingredients and costs - *Update*

siwhelan

Simon Whelan

Posted on February 15, 2023

stockControl 馃馃カ馃 - A comprehensive system for tracking recipes, ingredients and costs - *Update*

I had planned to get an earlier update out to this, but I was having too much fun building it!

An update to my Stock Control web app being built with Python, Django and Bootstrap!

For those who may be unfamiliar with the technologies I'm using, here are some brief introductions:

What is Django?

Django is a high-level Python web framework that is widely used for building web applications. It provides a lot of built-in features, such as a powerful ORM, a templating engine, and a robust authentication system, that make it easy to build complex web applications. Django is also known for its scalability, security, and ease of use, making it a popular choice among developers.

What is Bootstrap?

Bootstrap is a popular front-end framework for building responsive web applications, and provides a set of pre-designed HTML, CSS, and JavaScript components that can be easily integrated into any web project. With Bootstrap, developers can create professional-looking and user-friendly web interfaces without having to write custom code from scratch. Some of the features of Bootstrap include a grid system for laying out web pages, typography styles, forms, buttons, navigation bars, and modal dialogs. Bootstrap also includes support for CSS preprocessors like Sass and Less, and is regularly updated to keep up with modern web development trends.

What is MongoDB?

MongoDB is a document-oriented NoSQL database that stores data in a JSON-like format called BSON. Unlike traditional SQL databases, MongoDB doesn't use tables and rows. Instead, it stores data as documents that can contain nested structures and arrays. MongoDB is highly scalable, flexible, and can handle large amounts of unstructured data, making it a great choice for building modern web applications.

Why use Django with MongoDB?

While Django is traditionally used with SQL databases, it's also possible to use it with NoSQL databases like MongoDB. There are several benefits to using Django with MongoDB, such as:

Flexibility: MongoDB's flexible data model allows you to store and retrieve data in a way that suits your application's needs. This makes it easier to work with complex data structures and adapt to changing requirements.

Scalability: MongoDB is designed to scale horizontally, which means you can add more servers to handle a growing amount of data. This makes it a great choice for building large-scale web applications.

Performance: MongoDB's native query language, as well as its ability to store data in memory, can result in faster query times compared to traditional SQL databases.

Also....I just enjoy using it!

The Web App馃馃カ馃 -

Really pleased with how this is coming together, it's been a fantastic dive into Bootstrap and HTML and the methods of bringing backend Python code into a fully functional interface.

So far the application has several key features, including:

View all ingredients: This feature allows the user to view all of the ingredients currently stored in the database. Each ingredient is displayed with its name, pack size, and price per pack. The user can also edit or delete ingredients as needed, although these are sat in the backend waiting to be implemented! I will also be adding an 'amount' field to track how much of each ingredient the kitchen should have in stock.

Add new ingredient: This feature allows the user to add a new ingredient to the database. The user can enter the name, pack size, and price per pack of the new ingredient.

An example of how the ingredients are currently stored in the database -


{
  "_id": {
    "$oid": "63de7fb1ddb55617db8abac2"
  },
  "product_code": "0003",
  "ingredient": "flour",
  "price_per_pack": 2.99,
  "pack_size": 1000
}

Enter fullscreen mode Exit fullscreen mode

View recipes: This feature lets the user explore all the recipes that are currently saved in the database, complete with their names, ingredients, and codes (these codes are set automatically upon entry by checking the last entry and incrementing it by 1). I have plans to add more options for adding, editing, and deleting recipes soon, and I've already got the backend code set up - I just need to put it into action!

The add_recipe() function is particularly useful, as it prompts the user to input each ingredient for a recipe and cross-references it with the ingredients database. If an ingredient is not yet listed in the database, the function will call add_new_ingredient() and ask the user for it's details, and then add the new ingredient to both the recipe and ingredients databases at the same time.

Recipe cost calculation: The application automatically calculates the cost of each recipe based on the cost of the ingredients used. This helps the user make informed decisions about pricing and profitability. One function that is waiting in the wings is the updating of ingredients to allow accurate pricing as supplier costs fluctuate, this then automatically updates the total cost in the recipe database as well.

Stocktake: Yet to be implemented in the backend, this feature will enable users to conduct physical stock inventory counts and reflect the changes in the database. To do this, users will need to input the currently held quantity for each ingredient, and the application will automatically update the database with the new values. Additionally, a sales entry feature is planned to be added later on. This feature will factor in the current stock on hand with the sales data to calculate the gross profit margins for the kitchen.

I will also be including a wastage input that will both keep a price tally of any ingredients/portions of recipes that are wasted, and also remove the relevant amount of any wasted product from the amount recorded in the ingredients database. This will allow for a much more accurate GP figure.

Screenshots?....Screenshots.

Apologies for the quality on these - if anyone has any tips for uploading higher def images on dev.to I'm all ears!

View All Ingredients

Stock Entry

Recipe Cards

Add Ingredient

Direct links -

Pic1

Pic2

Pic3

Pic4

Also, forgive the basic recipes - I'll be making these a little more interesting over time!

Still lots to do, but it's flying together so it's all good!

The full code is available here for anyone interested, and I'll have another update in a week or so for anyone who's following along.

Any questions, feel free to reach out.

Thanks for reading! 馃憢

馃挅 馃挭 馃檯 馃毄
siwhelan
Simon Whelan

Posted on February 15, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related