Skip to content

Capstone project: A staff & student site for Turing School of Software & Design --- visit Mentor Match here! -->

Notifications You must be signed in to change notification settings

BeccaHyland/mentor_match_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

screen shot 2019-01-09 at 5 35 18 pm Build Status Waffle.io - Columns and their card count

Mentor Match (API)

Developers

Back End: Tim Fielder, Rebecca Hyland (Project Lead)
Front End: Casey Hoepner, Alex Rau

Table of Contents

Introduction

Mentor Match is an app for internal staff and student use at Turing School of Software & Design, planned in partnership with real clients. In this repo, you will find the code and documentation for the Back End, which provides the database and API endpoints for user by the Mentor Match front end and is deployed at https://mentor-match-api.herokuapp.com/ Mentor Match is also deployed to a staging environment to insulate the production site from bugs.

Iteration 1: Gives admin tools to manage the matching process in which incoming Turing students have the opportunity to be mentored 1-on-1 by a software development mentor, usually an alumni.

  • Admin can filter current mentors and students by easy-to-use button attributes or a query string
  • Admin can assign and remove matches
  • New mentors can complete a detailed form to add their information to the mentor database
  • Admin can enter new students into the database

Iteration 2: Secures the app with an OAuth login (authentication) and differentiated access based on User role (authorization).

  • JSON web tokens (JWT) are generated, and a User is identified or created in the Back End after the User clicks "Login with GitHub" on the Front End
  • The Front End stores and sends the User's JWT with every API request to the Back End, where the User's identity and permissions are identified
  • A new Mentor that is created is associated with the User, for future editing of the User's own information

Iteration 3 (in development): Gives students search functionality to locate additional mentors for short-term mentoring (coffee meetings, mock interviews) as a part of Turing's Professional Development curriculum.

Screen Capture 1: Admin Logs In and Filters Mentors

mmpart1

Screen Capture 2: Admin Matches and Unmatches Mentor with a Student, Capacity Updates

mmpart2matching

Screen Capture 3: Mentor Completes & Submits Form

mmpart3mentorform

Initial Setup

Run locally:

  1. Clone the repo found here: (https://github.com/BeccaHyland/mentor_match_api)
  2. Run bundle from the CLI.
  3. Run rails s
  4. Using localhost:3000 as the base of your url in browser, add the endpoint of your choice. See below:

API Endpoints

This is documentation for the API endpoints.

All successful database requests return JSON in an easy-to-consume format generated by Netflix's fast_jsonapi gem.

For authorization, all requests must include a token.

The value must be the token received by the FE (in the parameters as token) in the first request from the user for that login session.

This ensures that the user already "Logged In" - was authenticated by a Github OAuth login and role-verified by the Back End to set the user's permissions (allowed endpoints)

To supply the Front End app with data, this project provides the following endpoints:

Mentor Public Endpoints

1. All mentors in the database:

GET /api/v1/mentors

  • returns JSON in the following format (all arrays are shown closed except the first, for easier viewing):

screen shot 2019-01-01 at 7 14 23 pm

  • Note: This is the only endpoint that does not require login or sending a token through the Authorization header.

2. One mentor by its id

GET /api/v1/mentors/(INSERT ID HERE)

  • returns JSON in the following format (all arrays are shown closed except the first, for easier viewing):

screen shot 2019-01-01 at 7 22 03 pm

3. Create a new mentor in the database

POST /api/v1/mentors

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

BODY:

  • JSON

  • A successful post returns status: 201 and returns the new mentor.

  • The minimum required fields to create a mentor are: name, city, and email. { "name": "name of mentor", "email": "email of mentor", "city": "city of mentor" }

  • the database already stores defaults for the attributes active and matched, so these are NOT included with a POST.

  • full example:


{
"name": "Sara Mentor",
"email": "sara@sara.com",
"city": "Sarahville",
"state": "CO",
"country": "(will default to US if not provided)",
"slack_username": "sara_slack",
"matched": "false",
"active": "true",
"pronouns": "she/her",
"current_title": "Software Developer",
"current_employer": "Sara's employer",
"background": "I was a student in the FE program, and I love my cat and learning Vue",
"stack_preference": "FE",
"industries": ["food service", "sales"],
"ways_to_mentor": ["1-on-1", "coffee meetings"],
"expertise_tech": ["JavaScript", "Mocha/Chai", "Node.js", "React", "Redux"],
"expertise_non_tech": ["rock-climbing", "parenting", "cooking"],
"avatar_url": "url of the avatar",
"meeting_location": ["remote"]
}

4. Update a mentor in the database

PATCH/PUT /api/v1/mentors/(INSERT ID HERE)

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

BODY:

See above POST request, PATCH does not require all attributes, only those being updated.

Admin Endpoints

Note: All of the following endpoints are name-spaced under admin. In order to access any of these endpoints, a user must be logged in and authenticted through the OAuth process and be registered as an administrative user.

Admin Mentor Endpoints

1. All mentors in the database:

GET /api/v1/admin/mentors

  • returns JSON in the following format (all arrays are shown closed except the first, for easier viewing):

screen shot 2019-01-01 at 7 14 23 pm

  • Note: This endpoint does not require a token, nor authentication.

2. One mentor by its id

GET /api/v1/admin/mentors/(INSERT ID HERE)

  • returns JSON in the following format (all arrays are shown closed except the first, for easier viewing):

screen shot 2019-01-01 at 7 22 03 pm

3. Create a new mentor in the database

POST /api/v1/admin/mentors

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

BODY:

  • JSON

  • A successful post returns status: 201 and returns the new mentor.

  • The minimum required fields to create a mentor are: name, city, and email. { "name": "name of mentor", "email": "email of mentor", "city": "city of mentor" }

  • the database already stores defaults for the attributes active and matched, so these are NOT included with a POST.

4. Update a mentor in the database

PATCH/PUT /api/v1/admin/mentors/(INSERT ID HERE)

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

BODY:

See the following request updating a mentor, PATCH does not require all attributes, only those being updated.

  • full example:

{
"name": "Sara Mentor",
"email": "sara@sara.com",
"city": "Sarahville",
"state": "CO",
"country": "(will default to US if not provided)",
"slack_username": "sara_slack",
"matched": "false",
"active": "true",
"pronouns": "she/her",
"current_title": "Software Developer",
"current_employer": "Sara's employer",
"background": "I was a student in the FE program, and I love my cat and learning Vue",
"mentee_capacity": 1, *(this is an integer)*
"stack_preference": "FE",
"industries": ["food service", "sales"],
"ways_to_mentor": ["1-on-1", "coffee meetings"],
"expertise_tech": ["JavaScript", "Mocha/Chai", "Node.js", "React", "Redux"],
"expertise_non_tech": ["rock-climbing", "parenting", "cooking"],
"identity_preference": ["parent", "female-identifying", "FE"],
"avatar_url": "url of the avatar",
"meeting_location": ["remote"]
}

4. Delete a mentor from the database

DELETE /api/v1/admin/mentors/(INSERT ID HERE)

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

Admin Student Endpoints

1. All students in the database:

GET /api/v1/admin/students

  • returns JSON in the following format:
    screen shot 2019-01-03 at 1 22 05 pm

2. One student by its id

GET /api/v1/admin/students/(INSERT ID HERE)

  • returns JSON in the following format:
    screen shot 2019-01-03 at 1 22 35 pm

3. Create a new student in the database

POST /api/v1/admin/students

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

BODY:

  • JSON

  • A successful post returns status: 201 and returns the new student.

  • The minimum required fields to create a student are: name and email where the email must be unique. { "name": "name of student", "pronouns": "pronouns of student", "email": "email of student", "slack_username": "slack_username of student", "background": "background of student", "industries": ["industries of student"], "stack": "stack of student", "identity_marker": ["identity_marker of student"] }

  • the database stores defaults for the attributes "matched": "false" , "active": "true" , "industries": [] , "identity_marker": [].

  • full example:
    screen shot 2019-01-03 at 1 23 47 pm

4. Update a student in the database

PATCH/PUT /api/v1/admin/students/(INSERT ID HERE)

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

BODY:

See above POST request, PATCH does not require all attributes, only those being updated.

5. Delete a student from the database

DELETE /api/v1/admin/students/(INSERT ID HERE)

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

Admin StudentMentor Endpoints

1. All student mentor relationships in the database:

GET /api/v1/admin/student_mentors

  • returns JSON in the following format:
    screen shot 2019-01-03 at 1 40 17 pm

2. One student mentor relationship in the database by its id:

GET /api/v1/admin/student_mentors/(INSERT ID HERE)

  • returns JSON in the following format:
    screen shot 2019-01-03 at 1 41 08 pm

3. Create a new student mentor in the database:

POST /api/v1/admin/student_mentors

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

BODY:

  • JSON

  • A successful post returns status: 201 and returns the new student mentor relationship.

  • The minimum required fields to create a student are: student_id and mentor_id where the a student and mentor must exist. { "student_id": "student_id as an integer", "mentor_id": "mentor_id as an integer", "active": "true" }

  • the database stores defaults for the attributes "active": "true".

  • full example:
    screen shot 2019-01-03 at 1 43 11 pm

4. Update a student mentor in the database

PATCH/PUT /api/v1/admin/student_mentors/(INSERT ID HERE)

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

BODY:

See above POST request, PATCH does not require all attributes, only those being updated.

5. Delete a student mentor from the database

DELETE /api/v1/admin/student_mentors/(INSERT ID HERE)

  • request must include:

HEADERS:

{ "Content-Type": "application/json", "Accept": "application/json", "Authorization": "(token)" }

Build Details: (draft collection of all details, to be formatted)

initial build command: rails new mentor_match_api -T -d postgresql --skip-spring --skip-turbolinks

Gems added:

general:

gem 'fast_jsonapi' gem 'rack-cors', require 'rack/cors' gem 'active-designer'

development & test gem 'rspec-rails' gem 'capybara' gem 'factory_bot_rails' gem 'pry' gem 'shoulda-matchers' gem 'launchy' gem 'database_cleaner' gem 'faker'

test only gem 'simplecov'

Run rails g rspec:install

To rails_helper, added

Shoulda::Matchers.configure do |config| config.integrate do |with| with.test_framework :rspec with.library :rails end end and require 'faker'

To spec_helper, added: require 'database_cleaner' require 'simplecov' SimpleCov.start "rails"

within the spec_helper RSpec configure: config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) end config.around(:each) do |example| DatabaseCleaner.cleaning do example.run end end

in config/application.rb, added: config.middleware.insert_before 0, Rack::Cors do allow do origins '*' resource '*', headers: :any, methods: [:get, :post, :options] end end for the rack-cors gem

Known Issues

Admin cannot currently POST a new mentor. To POST, a prospective mentor logs in with GitHub, their Mentor Match User account is created through OAuth, and their mentor intake form data is then associated with that User. A future iteration could include a feature allowing an Admin to POST a new mentor independent of a User.

Running Tests

Run rspec from the CLI to run all tests. Run rspec then the filepath of the test you wish to run.

How to Contribute

Drop a line to the creators, or add a Pull Request on GitHub.

Schema Design

screen shot 2019-01-02 at 6 30 11 pm

BE Tech Stack List

  • Ruby 2.4.1
  • Ruby on Rails 5.1
  • PostgreSQL
  • OAuth
  • JSON Web Tokens

About

Capstone project: A staff & student site for Turing School of Software & Design --- visit Mentor Match here! -->

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages