Skip to content

Sprint 2: MVP and additional features#7

Open
f3liz wants to merge 56 commits intokellerflint:mainfrom
f3liz:main
Open

Sprint 2: MVP and additional features#7
f3liz wants to merge 56 commits intokellerflint:mainfrom
f3liz:main

Conversation

@f3liz
Copy link
Copy Markdown

@f3liz f3liz commented Oct 16, 2025

Tech Stack:

  • Frontend: Next.js (React)
  • Backend: Node.js + Express
  • Database: MySQL with Sequelize ORM
  • Deployment: PM2 on Ubuntu VM

Implemented Features:

  • Completed CRUD functionality for the /books (Create, Read, Update, Delete) API endpoint
  • Integrated a backend API with a frontend interface
  • Configured Sequelize ORM and connected to a MySQL database
  • Implemented environment variables like .env and .env.local for secure application configuration
  • Deployed the working application to a VM using PM2
  • Updated the README with setup, deployment, and API documentation

All CRUD API endpoints are documented in the project README.

AlexanderORuban and others added 30 commits September 25, 2025 11:25
…onents, created new components, and added a favicon.
AlexanderORuban and others added 26 commits October 13, 2025 23:50
…getting a single book by id but frontend needs a new utility to get a single book.
…n the front end trying to reach the update page.
Feature: CRUD operation update merge into development branch
…le/db but doesn't refresh the page after deletion.
Merging the delete feature from feature-delete into development
Development branch merge into main
Comment thread server/index.js
const HOST = "0.0.0.0";

const book = await BookSchema.findAll();
console.log(book);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console log not needed here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to take this out, used to confirm there was a book

Comment thread server/index.js

app.use("/", router);

BookSchema.create({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interacting with database in index file doesn't make a lot of sense. If database needs to be seeded it should be in separate file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this in there to see the database be built out and show information in there, can take out as it is not needed

const { books, loading, error, refetch } = FetchBooks();
const router = useRouter();

const handleDelete = async (id) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are fetch calls in separate utilities folder but update and delete are directly in components/pages.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete and update are in the page.jsx for the table to re-render it after either deleting or updating a book.

return (
<section className="center-wrap">
<div className="card">
{(title || subtitle || actions) && (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not exactly clear on what is happening here. Are you checking that they all three exist before rendering?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are placeholder sections for the Centercard template used by each page where the card header can have a title, subtitle, and actions.

}, [fetchBooks]);

// Return refetch function so that other components can trigger updates
return { books, loading, error, refetch: fetchBooks };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a refetch function? Does this allow you to "refetch" outside in other components?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it does. It's used in the delete function for the books table to re-fetch the page after deleting a book.

const data = await dataLayer.getAllBooks();
res.status(200).json({
message: "success",
data
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent with line 19 where you assign book to data, but that same practice is not followed here on line 7.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the data here is all our books while in line 19 is a singular book

Comment thread server/db/booksRepo.js
export const deleteBook = async (id) => {
return await BookSchema.destroy({
where: {
id
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent again with not assigning any id specifically to your where clause.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is how it is supposed to be returned in order for sequelize to delete an item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants