### Wrapping Up 😢
# Week 9!
*So close to Thanksgiving*
<p>Sit with your teams</p>
----
# Current Grade!
<div>
<ul>
<li>Not final</li>
<li>Extra credit for effort</li>
</ul>
</div>
---
# Starting Afresh!
Project Planning 101
----
# The Rails Development Process
- Plan out your database schema
- Run `rails new` and `rails generate ...`
- Build out routes and controller logic
- Deploy to the web!
----
# Wait but?
- Missing piece of the puzzle?
- UI/UX!!!
- User interface and design is crucial to a good website
- Not covered in this course but other decals go deeper into this!
- Web Design DeCal
- React DeCal
----
# Schema Design
- Big questions:
- What models do we need in our app?
- How do they relate?
----
# Let's do it!
- **Sample App**: Amazon
- What models might we have?
- Our guess: Users, Products, Purchases, Reviews
- Let's draw it out!
----
# Lessons Learned
- Create boxes for each model
- Add properties to each
- Draw out relationships with arrows
- Find your teams and give it a shot!!
----
## Google Is Your Friend
*(Except with your data)*
---
# Review on Gems
Ooooh, shiny...
----
# What are they?
- Code that others write that we can add to our project
<!-- .element: class="fragment" -->
- Often add functionality without us having to write it ourselves
<!-- .element: class="fragment" -->
- Not necessarily reliable since we didn't write it
<!-- .element: class="fragment" -->
----
# How to add one
- Gemfile contains all the gems we want in our project
<!-- .element: class="fragment" -->
- Syntax: `gem 'taco'` says our project needs the "taco" gem
<!-- .element: class="fragment" -->
- Command `bundle install` ensures that we install all the gems into our project
<!-- .element: class="fragment" -->
----
# Common Gems Introduced Last Time
- Devise: Takes care of Authentication!
<!-- .element: class="fragment" -->
- Faker: Provides Fake Seed Data
<!-- .element: class="fragment" -->
- Rails-Admin: Gives a nice admin screen to use instead of `rails console`
<!-- .element: class="fragment" -->
----
# How to know whether a gem is reliable?
- Stars on a github repo
<!-- .element: class="fragment" -->
- Date of last commit
<!-- .element: class="fragment" -->
- Any active, problematic issues posted
<!-- .element: class="fragment" -->
- No red flags on the readme
<!-- .element: class="fragment" -->
---
# ActiveStorage Walkthrough
Back to Instagram!
---
# Integrating With The Rest of the Web!
We Are Not Alone.....👽
----
# What've We Learned So Far
- We can build webservers! What does that mean?
<!-- .element: class="fragment" -->
- We've built a program that sends data to people
<!-- .element: class="fragment" -->
- We're used to sending HTML, but we can send back anything
<!-- .element: class="fragment" -->
- https://your.rails.world/json
<!-- .element: class="fragment" -->
----
# Other people do this too!
- People will build webservers that provide routes to provide data
<!-- .element: class="fragment" -->
- They're called APIs, a lot of common websites will have them
<!-- .element: class="fragment" -->
- Our webservers can send requests to others!
- HW 2's Weather Service
<!-- .element: class="fragment" -->
----
# How does this look?
![](https://i.imgur.com/0yRBF1F.png)
----
# Cool APIs
- TacoFancy API: https://github.com/evz/tacofancy-api
<!-- .element: class="fragment" -->
- Star Wars: https://swapi.co/
<!-- .element: class="fragment" -->
- Wikipedia: https://www.mediawiki.org/wiki/API:Main_page
<!-- .element: class="fragment" -->
----
# How do we do it?
- A gem called Faraday! It lets us make requests from our rails apps to other applications
<!-- .element: class="fragment" -->
- `gem 'faraday'`
<!-- .element: class="fragment" -->
```
conn = Faraday.new(:url => 'http://your.rails.world')
response = conn.get '/json'
```
<!-- .element: class="fragment" -->
----
# Add it to Instagram!
---
# API's
> Experienced Programmers just use other people's code to communicate with other people's servers to display other people's data
>
<small>[https://apilist.fun](https://apilist.fun)</small>
----
# What are important API's to know
- ALL OF THEM
- jk, What are good books to know?
- Cool services make you more resourceful
- Feeling comfortable doing research is more important
- [https://apilist.fun](https://apilist.fun)
----
# *cough* welcome to software dev *cough*
- It's open world and the possibilities are literally endless
- So many gold mines and rabbit holes alike
- *I can show you the world*
----
# Three Important Web Concepts
> "The web is just some computers having a conversation"
- Three Types:
- Read API's
- Write API's
- Webhooks
----
# Data API's
- Websites exposing their data in JSON format
- What type of requests are prominent here?
- GET! You are usually just asking for info
- Spam Protection?
- Track IP Addresses, or Auth Tokens/Keys
- What does this look like?
- [NewsAPI.org](newsapi.org)
---
# Webhooks
> "Hey, do you mind just sending ME a request when something interesting happens?"
----
# What are they?
- Usually we get requests from users
- Can tell other webservers to ping you!
- Messenger Bot, Github, IFTTT
- [Damn I love the internet](https://github.com/realadeel/awesome-webhooks)
----
# Moral of the story:
> You don't need to have read every book to be resourceful. Knowing that the library exists and how to read its catalog is good enough
>
- The web is so much more fun when you're not alone
- "There's an App for that" => "There's an API for that"
---
# [Heroku Deployment](https://devcenter.heroku.com/articles/getting-started-with-rails5)