Skip to content

HireUp-Turing/HireUp_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HireUp - Backend API in Flask

Build Status

HireUp gif

Jump To

About

HireUp aims to minimize bias in the hiring process, and reduce efforts required of job applicants to produce application materials and of employers to read through piles of those materials. Job seekers can create anonymous applicant profiles that highlight their skills and values, and employers can browse through those anonymous profiles and message applicants they believe would be a good fit for their open roles.

This repo is the back-end service for HireUp and is consumed by our front-end application. The front-end GitHub repo can be found here and the deployed site here.

Contributors

Setup

  • If you do not yet have pyenv, Python3, or Pip3 installed, follow these instructions.
  • Clone repo: git clone [email protected]:HireUp-Turing/HireUp_backend.git
  • Virtual Environment Setup:
    • Build and activate a virtual environment to install your Python packages with $ python3 -m venv ./venv
      • If you have Python3 set as your global version inside pyenv you probably can run python instead of python3 at the beginning of that command.
    • Activate the virtual environment: $ source venv/bin/activate (Run $ deactivate to deactivate the virtual environment when done working with the app)
  • Install Python packages: $ pip install -r requirements.txt
  • Set up local databases
    $ createdb hireup_dev # creates your dev database
    $ createdb hireup_test # creates your test database
    $ export DATABASE_URL=postgresql://localhost:5432/hireup_dev # connects you to your dev database in order to run the following commands
    $ python manage.py db migrate # generates new migration files from any changes made to models.py
    $ python manage.py db upgrade # runs migrations on your dev database
    $ python manage.py db_seed # seed data in dev database
    $ export DATABASE_URL=postgresql://localhost:5432/hireup_test # connects you to your test database in order to run the following commands
    $ python manage.py db upgrade # runs migrations on your test database
  • Run $ export DATABASE_URL=postgresql://localhost:5432/hireup_dev again to reset DATABASE_URL to the development database for any future work.
  • In order to avoid needing to restart the server manually after each change to your code, run the following commands, which enable all development features, including debug mode:
     $ export FLASK_ENV=development
     $ flask run
    
  • $ python run.py to run server on localhost:5000 (If you get errors concerning the FLASK_APP environment not being set, try $ export FLASK_APP=manage.py)

CLI commands

  • $ python manage.py routes returns available routes
  • $ python manage.py db_seed drops all tables, creates all tables, and seeds whichever database is currently set to DATABASE_URL environment variable.

Testing

  • Run tests without coverage: $ pytest -v
  • Run tests with coverage report: $ pytest --cov
    • See browser-based coverage report
      $ coverage html
      $ open coverage_html_report/index.html
      

Database Schema

image

Endpoint Documentation

Run in Postman

Base URL: Use localhost:5000 to explore endpoints with local server and hireup-be.herokuapp.com to explore the endpoints via the live Heroku app

Applicants

GET /api/v1/applicants

Response: Returns all applicants
{
  	"success": true,
  	"data": [
  		{
  			"id": 1,
  			"username": "Anonymous Giraffe",
  			"email": "[email protected]",
  			"bio": "Noodle's mom!",
  			"skills": [
  				{
  					"attribute": "flask"
  				},
  				{
  					"attribute": "rails"
  				},
  			],
  			"values": [
  				{
  					"attribute": "creativity"
  				},
  				{
  					"attribute": "mentorship"
  				}
  			]
  		},
  		{
  			"id": 2,
  			"username": "Famous Hippo",
  			"email": "[email protected]",
  			"bio": "Noodle's mom's accountabilabuddy!",
  			"skills": [
  				{
  					"attribute": "flask"
  				},
  				{
  					"attribute": "rails"
  				},
  			],
  			"values": [
  				{
  					"attribute": "creativity"
  				},
  				{
  					"attribute": "mentorship"
  				}
  			]
  		}
  	]
}

GET /api/v1/applicants/:applicant_id

Response: Does not include any identifying information about the applicant
{
  	"success": true,
  	"data": {
  		"id": 1,
  		"username": "Fancy Chipmunk",
  		"email": "[email protected]",
  		"bio": "I'm the best one you could possibly hire",
  		"skills": [
  			{
  				"attribute": "flask"
  			},
  			{
  				"attribute": "rails"
  			},
  		],
  		"values": [
  			{
  				"attribute": "creativity"
  			},
  			{
  				"attribute": "mentorship"
  			}
  		]
  	}
}

POST /api/v1/applicants/

Request: Email, skills, and values are required fields
{
  	"first_name": "Greyson",
  	"last_name": "Johns",
  	"bio": "I'm the best one you could possibly hire",
  	"username": "Chipmunk",
  	"skills": [2, 3],
  	"values": [2]
}
Response: Creates new applicant and returns attributes including the new user's id
{
  	"success": true,
  	"data": {
  		"id": 6,
  		"username": "Chipmunk",
  		"email": "[email protected]",
  		"bio": "I'm the best one you could possibly hire",
  		"skills": [
  			{
  				"attribute": "flask"
  			},
  			{
  				"attribute": "rails"
  			},
  		],
  		"values": [
  			{
  				"attribute": "creativity"
  			},
  			{
  				"attribute": "mentorship"
  			}
  		],
  	}
}
Error handling: Request body with empty arrays for either skills or values when being created will produce a 400 error message

Example erroneous request:

{
  	"first_name": "Greyson",
  	"last_name": "Johns",
  	"bio": "I'm the best one you could possibly hire",
  	"email": "[email protected]",
  	"username": "Chipmunk",
  	"skills": [2, 3]
}
# missing "values" array

Error message response:

{
  	"success": false,
  	"error": 400,
  	"errors": [
  		"required 'values' parameter is missing"
  	]
}

Searching

GET /api/v1/applicants/search-options

Response: Returns alphabetically ordered skills and values that are actively associated with applicant records. This endpoint is used on the front-end in in order to populate search filter options for employers to browse applicant profiles.
{
	"success": true,
	"data": [
		{
			"skills": [
				{
					"id": 2,
					"attribute": "flask"
				},
				{
					"id": 1,
					"attribute": "rails"
				},
				{
					"id": 3,
					"attribute": "ruby"
				}
			],
			"values": [
				{
					"id": 1,
					"attribute": "creativity"
				},
				{
					"id": 2,
					"attribute": "mentorship"
				}
			]
		}
	]
}

POST /api/v1/applicants/search

Request Body: Attribute arrays contain ids associated with the selected skills and values attributes on the front-end search page. One of the arrays can be empty, but not both.
{
  "skills": [2, 4],
  "values": [3]
}
Response: Returns all applicants that partially match the attributes specified by the request
{
	"success": true,
	"data": [
		{
			"id": 1,
			"username": "Chipmunk",
			"email": "[email protected]",
			"bio": "Noodle's mom!",
			"skills": [
				{
					"attribute": "rails"
				},
				{
					"attribute": "ruby"
				}
			],
			"values": [
				{
					"attribute": "creativity"
				}
			]
		},
		{
			"id": 2,
			"username": "Anonymous Giraffe",
			"email": "[email protected]",
			"bio": "Noodle's mom's accountabilabuddy!",
			"skills": [
				{
					"attribute": "rails"
				},
				{
					"attribute": "flask"
				}
			],
			"values": [
				{
					"attribute": "creativity"
				},
				{
					"attribute": "mentorship"
				}
			]
		}
	]
}
Error handling: A request body that does not specify any skills or values will produce a 400 error message

Example erroneous request:

{
	"skills": [],
	"values": []
}
# missing skills and values ids

Error message response:

{
	"success": false,
	"error": 400,
	"errors": "At least one skill or value id must be specified in order to filter applicant search results."
}

Messages

GET /api/v1/messages?applicant_id=<applicant_id>

Request: Use query params to specify the id of the applicant whose messages need to be retrieved
Response: Returns messages associated with the specified user id
{
	"success": true,
	"data": [
		{
			"id": 1,
			"applicant_id": 2,
			"employer_name": "Google",
			"employer_email": "[email protected]",
			"body": "We know you'll rock our world as CEO of Google - please interview with us.",
			"read_status": false,
			"created_at": "2020-11-01 14:11:53.212912-07:00"
		},
		{
			"id": 2,
			"applicant_id": 2,
			"employer_name": "Aerion Inc",
			"employer_email": "[email protected]",
			"body": "Come work for us. Pretty please.",
			"read_status": true,
			"created_at": "2020-11-01 14:11:53.212912-07:00"
		}
	]
}

POST /api/v1/messages

Request: Body should specify applicant_id (referencing the message recipient), employer_name, employer_email, and a message body. read_status defaults to false and should not be included in the request body.
{
	"applicant_id": 1,
	"employer_name": "Turing",
	"employer_email" : "[email protected]",
	"body" : "We're interested in interviewing you for our Back-End Instructor role. You'll rock our students' worlds!"
}
Response: Returns the new message attributes and its id
{
	"success": true,
	"data": {
		"id": 3,
		"applicant_id": 1,
		"employer_name": "Blop",
		"employer_email": "[email protected]",
		"body": "We're desperate to hire you at Blop Corp. Will you interview with us this Friday?",
		"read_status": false,
		"created_at": "2020-11-02 02:10:15.909406-07:00",
		"success": true
	}
}

Skills

GET /api/v1/skills

Response: Returns all skills. Used on the front-end to populate the list of skills an applicant may select when creating their profile.
{
	"success": true,
	"data": [
		{
			"id": 1,
			"attribute": "rails"
		},
		{
			"id": 2,
			"attribute": "flask"
		},
		{
			"id": 3,
			"attribute": "ruby"
		},
		{
			"id": 4,
			"attribute": "java"
		},
		...
	]
}

Values

GET /api/v1/values

Response: Returns all values. Used on the front-end to populate the list of values an applicant may select when creating their profile.
{
	"success": true,
	"data": [
		{
			"id": 1,
			"attribute": "creativity"
		},
		{
			"id": 2,
			"attribute": "mentorship"
		},
		{
			"id": 3,
			"attribute": "engages with community"
		},
		...
  ]
}

Technologies

  • Python
  • Flask
  • SQLAlchemy
  • Pytest
  • TravisCI

Roadmap

Feel free to explore our list of open issues and our project board to learn about what our team has in mind for future iterations of HireUp