DEV Community

victoriaehrbar
victoriaehrbar

Posted on

JavaScript Project

I finished my phase 4 project for Flatiron School! I created a single-page web application for my JavaScript project.

I created 2 separate repos for the front end and back end. The back end was fairly similar to the phase 3 Rails project, with controllers, models, and has_many relationships.

My project was a book review/tracker, where a user can input a title, author, description, and category/genre. A category has_many books and a book belongs_to a category.

While it was interesting to create a mini Rails project and review some old material, I was most interested in the front end JavaScript portion and refining what I learned in phase 4. I utilized the fetch method to get the book data to display on the page, display new posts, and to delete posts.

The back end part of the project required creating a Rails API, which was interesting as the phase 3 Rails project did not incorporate this. The front end JavaScript portion of this project communicates with the API for the front end and back end to work together.

In JavaScript, event listeners are used to create actions. For example, my project has an attachDeleteButtonListener, which lets the server know that when the delete button is clicked, that book entry should be removed from the page. There is also another event listener that lets the page know to create a new book when "submit" is clicked on the new book form.

Overall, the JavaScript project was a great fusion of Rails and JavaScript that allowed me to synthesize my JavaScript knowledge and create a fun single-page web application.

Top comments (4)

Collapse
 
jzombie profile image
jzombie

Nice, I might be learning some Ruby myself soon.

In your repo, could you have made separate folders for frontend and backend in a single repo? Seems like that would make it easier to manage the thing as a whole, plus your versions would automatically be locked together.

Collapse
 
curiousdev profile image
CuriousDev

I think both scenarios are possible and valid: Having a single or two repositories. With two you are able have separate applications (versions of both are not neccessarily depending on each other). But you are still right, that it would be easier to manage.
Any other thoughts on this?

Collapse
 
jzombie profile image
jzombie • Edited

Yes, I just wanted to say that, despite the question, I did something similar in reverse, starting off with a single repo and diverging into multiple repos.

For a one-off project, I'd stick with the single repo, personally (though that doesn't seem to be your use case, if you don't need the frontend / backend to be dependent upon one another).

I went with the multiple repos in hopes that the other pieces might find some usage in other projects, but it has definitely required extra work to manage that aspect.

Collapse
 
nftcryptomix profile image
nftcryptomix

Cool