DEV Community

Vincenzo Chiovaro
Vincenzo Chiovaro

Posted on

Mealtime: A Beginner-Friendly API for Simplified Meal Data

Hello fellow developers! I'm excited to share my latest project, Mealtime, a beginner-friendly API built on top of the MealDB database. This project is designed to help beginners learn how to interact with APIs and practice their programming skills.

Project Overview

Let me share a funny story about how Mealtime came to be. As a recent graduate with a passion for programming, I tried to teach my wife, who is a self-proclaimed "newbie" in coding, how to interact with APIs. However, I quickly realized that the complex APIs and data structures I was explaining were overwhelming for her, this It made me realize that there was a need for a more beginner-friendly approach to API interactions.

That's when I came up with the idea of Mealtime. I wanted to build an API that would make it easy for beginners to learn the ropes of programming without feeling overwhelmed. With humility and self-criticism in mind, I set out to create a simple and user-friendly API that would strip away the complexities and present only the essential meal information.

Technical Details

Mealtime is built using Node.js, Express, and PostgreSQL. The data is fetched from the MealDB API using Axios. The code snippet below shows an example of the seeding process for inserting chicken meal data into the "chickenMeals" table in the database:

const insertChickenMealsData = async () => {
try {
const chickenMealData = await requestChickenMeals();
for (const meal of chickenMealData) {
const query = {
text:

INSERT INTO chickenMeals (title, category, instructions, image, youtube, ingredients)
VALUES ($1, $2, $3, $4, $5, $6::json)
,
values: [
meal.title,
meal.category,
meal.instructions,
meal.image,
meal.youtube || null,
JSON.stringify(meal.ingredients),
],
};


await db.query(query);
}
console.log("inserted data into chicken table successfully");
} catch (err) {
console.error("Error inserting chicken meal data:", err);
}
};

After successfully seeding the database, my next step is to create the endpoints for the API. These endpoints will allow users to interact with the meal data and perform various CRUD operations.

Once the endpoints are up and running, users will be able to access meal data, add new meals, update existing meals, and delete meals as needed.

I'm open to contributions and assistance from fellow developers! If you're interested in helping out or have any suggestions, please feel free to send me a message.

Feedback and Opinions

As this project is still a work in progress, I would greatly appreciate your feedback and opinions! If you have any suggestions, comments, or questions, please feel free to share them in the comments section below. Your feedback will be valuable in shaping the direction of this project and making it even more beginner-friendly.

Repository:
You can find the code for Mealtime on my GitHub repository: https://github.com/vincenzochiovaro/Mealtime-backend

Top comments (1)

Collapse
 
vincenzochiovaro profile image
Vincenzo Chiovaro

https://www.youtube.com/watch?v=qPgY-fp3cl8&ab_channel=VincenzoChiovaro

A quick video about the API structure with a quick refactor!