Ahh CRUD how is this working?
Browsing a website seems pretty simple right? Well luckily it is! Well at least for the user haha. There is quite a bit going on under the hood, and I found that out the hard (but fun) way while making my first web application.

Behind the scenes there are a quite a few things going on, but what I really want to focus on is what we call MVC or Models, Views, and Controllers. For example lets say you visit My Golf Bag. You as the user have sent a request to see the homepage. This is what is called a GET request. You are requesting to see the views which as the user the actual webpage that you are seeing and interacting with. If you wanted to create a new account you all you as the user have to do is click on the sign up link, or if you have an exiting account the Log in link. From that point the magic happens. The controller receives your request and shows you the views that you requested to see which would be either a Sign Up or Log In form.

Let’s say that in your case you are making a new profile. You would enter a name and password into the box and click sign up. This is whats called a POST request. POST requests are how you add new data to the website’s database. In this case it’s your name and password. The controller takes the data from the POST request and sends the it to the MODEL which stores the new data in the database. You now have a profile saved on My Golf Bag!

From here you can navigate the website and send GET request to see more views, POST requests to to add more data to the database, and you have access to two more requests. PATCH and DELETE.

When you send a PATCH request you are asking to alter the data you have stored in the data base. The controller then will send you views with a new form to change existing data.

When you state the changes you would like to make and press the make changes button you have just made a PATCH request! The controller then takes the request to the models that need changing and shows you the views with a new data.

Now you have changed your name and added a bio! If you were to log out your data will be there when you log back in. If you decide you want to delete your profile (for some crazy reason) by clicking the delete button you will send a DELETE request. The controller will send the model your request to “destroy” your data from the database. If you tried to log back in there would be no information about you in the database, so you would be prompted to Sign Up.

Through making my first web application I found a new appreciation for what is really happening when using websites. It’s amazing how much there is to learn and exciting to gain new knowledge!