Inspiration

  • The average food waste per household in the U.S. is estimated to be around 1,300 to 1,400 pounds each year, translating to a financial loss of approximately $1,500 to $2,000. Commonly wasted items include fruits, vegetables, dairy products, and meats.
  • This waste contributes to about 8-10% of global greenhouse gas emissions when considering the entire supply chain, from production to disposal.
    • Inspired by these staggering figures, we aim to reduce food waste through a home grocery management API that acts as a guardian, raising awareness of current grocery items and helping households make smarter, more sustainable choices.

What it does

  • The GroceryGuardian: Home Grocery Management API provides an efficient solution for households to track and manage their grocery items, helping to minimize waste and optimize usage.
  • Feature #1 - Add, Update, and Delete Grocery Items: Users can add new grocery items to their inventory, update item details (such as quantity or expiration date), and delete items they no longer need. This ensures a comprehensive, up-to-date list of groceries at any time.
  • Feature #2 - Expiration Date Tracking: The API tracks the expiration dates of grocery items and identifies those that are near expiry. Users can easily access a list of expired or soon-to-expire items, helping to prioritize them in meal planning and reducing the chances of spoilage.
  • Feature #3 - Categorization and Search: Items can be categorized (e.g., dairy, produce, meat), making it easy to organize and find specific items. The API also allows for keyword-based search functionality, enabling users to quickly locate any item in their inventory.

How we built it

To create the Home Grocery Management API, we followed a structured approach, leveraging Blackbird’s powerful API development and testing tools:

  1. Problem Identification and API Design: We started by identifying the problem of household food waste and designed an API focused on essential features to help users manage grocery items effectively. Our first challenge was to build an API with core functionality around tracking, categorizing, and retrieving grocery items by status.

  2. Generating API Specifications: Using the Blackbird UI, we prompted Blackbird AI Bot to generate an initial API specification based on our requirements. We iteratively refined this OpenAPI specification through further prompts to solidify the API design, ensuring it captured all essential aspects and conformed to best practices.

  3. Setting up Blackbird CLI: With the OpenAPI specification in hand, we set up Blackbird’s CLI in our devices to streamline our development and deployment workflow.

  4. Mock API Testing: We created a mock instance of our API using Blackbird’s Mock API feature, which allowed us to simulate the API endpoints and perform early testing. This step gave us a concrete understanding of how our API would function in a real environment and provided valuable insights into areas needing refinement.

  5. Code Generation with Blackbird CLI: Leveraging Blackbird CLI’s code generate command, we generated the API code in Go, using our OpenAPI specification as input. This helped us quickly scaffold a functional API with minimal setup time.

  6. DB Setup and connectivity : We replaced the Mock data store with actual Database. DB was hosted in an AWS RDS instance and the REST APIs connected with Postgres DB Instance for a robust and more generic implementation of our functionality.

  7. Local Testing and Debugging: After generating the code, we tested it locally using Blackbird CLI’s code run and code debug commands. These tools allowed us to catch and resolve issues early in the development process, ensuring that the API met our initial specifications before moving to deployment.

  8. Deployment and Iterative Improvements: Once confident in our API’s functionality, we deployed it to our Blackbird API Project. Each deployment iteration was tracked for improvements, allowing us to make adjustments and enhance the API incrementally.

  9. Security Setup: To secure our API, we used Blackbird CLI’s apikey command, establishing API key protection. This ensured only authorized users could access our API endpoints, adding an essential security layer for deployment.

  10. CICD setup using Github Workflow Actions :BLackbird code generate command includes the flag to enable GitHub Actions - Test module. This enables us to build upon the yml file to integrate with a continuous integration flow for our code.

Challenges we ran into

  • Setting up Blackbird CLI on Windows: Configuring Blackbird CLI on Windows presented some initial setup challenges, as it required adjusting our environment to ensure compatibility. However, with some troubleshooting, we successfully got it running smoothly.

  • API Specification Refinement: Generating the API specification through Blackbird’s prompt-based UI was powerful but took a few iterations. We experimented with different prompts to fully capture the functionality we envisioned, allowing us to arrive at a well-rounded API specification.

  • CICD Login Setup: For the CI/CD setup, Blackbird CLI required an API token for authentication, which wasn’t straightforward to obtain directly from the platform. We had to explore a few workarounds, but in the end, we successfully integrated secure authentication for automated deployments.

  • Code Generation in Go: Blackbird’s code generation feature provided efficient scaffolding for our API, but it currently only supports Go. This prompted us to learn some Go fundamentals to adapt and enhance the generated code. Despite being new to the language, we quickly became comfortable, which added to our skill set and allowed us to complete the project effectively

Accomplishments that we're proud of

We’re proud to have built a functional, straightforward solution that addresses food waste in a practical way. Learning new tools and navigating setup challenges allowed us to create an API that could make a small but meaningful impact.

What we learned

  • Through this project, we gained experience in designing APIs with Blackbird, from specification generation to deployment. We also learned how to set up CI/CD workflows, manage API keys for secure access, and adapt to a new programming language, Go, for backend development. Along the way, we improved our problem-solving skills and became more comfortable troubleshooting setup issues across different environments.
  • Another important realization is tools such as Blackbird have made API development and management very easy and it will only become easier in the future with the increasing role of AI and automation, so as developers it is imperative to quickly learn using these tools which make life easy for developers.

What's next for

  • Alerts and Reminders: We plan to integrate automated reminders for upcoming expiration dates and low stock items. This feature would help users proactively manage their groceries, reducing food waste and prompting timely usage.

  • Barcode Scanning: Adding barcode scanning functionality would allow users to quickly add items by scanning product barcodes, simplifying inventory management and ensuring accurate item details.

  • Receipt Parsing for Inventory Updates: We aim to implement receipt parsing so that users can upload a shopping receipt, and the app will automatically update grocery inventory based on purchased items.

Built With

Share this project:

Updates