ubclaunchpad / Internado

🌪 Find Internship Opportunities
3 stars 1 forks source link
internship-portal recommendation-system typescript webscraping

Internado Travis

Find personalized internship opportunities based on your skills and interests

:earth_americas: Links to in progress website

https://internado.ubclaunchpad.com/ https://internado.azurewebsites.net/

:computer: Running Locally

Running Job/Auth Servers

Server IP PORT Example
Job Search localhost 5000 http://localhost:5000/api
Authentication localhost 5050 http://localhost:5050/api

Install all necessary node files and places them in a node_modules root directory folder

foo@bar:~$ npm install

Builds, Lints and Runs the corresponding server

foo@bar:~$ npm start

Useful scripts

Running client

Install all necessary node files and places them in a node_modules root directory folder

foo@bar:~$ npm install

Runs the client (currently on http://localhost:3000/)

foo@bar:~$ npm start

Running data_acquisition.py

If you don't have a local instance of the PostgreSQL table yet, navigate to the server directory and run

foo@bar:~$ npm start

to create an empty job table. Make sure con = psycopg2.connect(dbname='postgres', user=getpass.getuser(), host='localhost', password='Pa55word') In a different terminal, navigate to the data_acquisition directory.

Use pipenv, a Python dependency and environment manager, to install any missing requirements. Note that we're using Python 3. Pipenv will install the correct version of Python based on the Pipfile, but make sure you're using a Python 3 pip.

foo@bar:~$ pip install pipenv
foo@bar:~$ pipenv install

The next few steps covers adding the ZipRecruiter API key as an environment variable. Message Sherry for the actual API key. This isn't the most secure way of storing it, but better than putting it directly in the code.

To get access to the shell for the managed environment:

foo@bar:~$ pipenv shell

Then add the API key into .env:

(data_acquisition) foo@bar:~$ echo "export ZIPRECRUITER_API_KEY=blahblah" >> .env

Exit the shell using:

(data_acquisition) foo@bar:~$ exit

To run the script:

foo@bar:~$ pipenv run python data_acquisition.py

Now check your job table again, it should be populated with data.

:whale: Running on Docker

Getting Started

Download & Install Docker

Build & Run Internado

Run the following cmd which builds all docker containers but does not run them
Sidenote: running docker build the first time takes a lot of time , however subsequent calls will run much faster as docker caches alot of the repeated steps

foo@bar:~$ docker-compose build

Runs all of the containers that were built above.

foo@bar:~$ docker-compose up

Now you can perform your request to any of the running containers much like how you would do it locally on your machine Currently there are 4 containers that are setup to run

If you are running Docker ToolBox you will need your docker machine ip for the [HOST] which you can get by running

foo@bar:~$ docker-machine ip

Otherwise , you can just refer to the container's name as the [HOST]

Container Name Description Port Example
server Job API (back-end) 5000 [HOST]:5000/api
auth Auth API (back-end) 5050 [HOST]:5050/api
postgres Database 5432 use adminer/cmd line to access
adminer GUI that helps you manipulate the database 8080 [HOST]:8080
client React (front-end) 3000 [HOST]:3000

Regarding the db you can use the following identification parameters to connect to it through any of the above containers

Parameter Value
Host [HOST]
Db name internado
Username admin
Password admin
Port 5432

How to dump data into postgres's container

Step 1 : First create the dump file

Step 2 : Delete all the current containers

foo@bar:~$ docker-compose down -v

Step 3 : Replace data in script found in database_config/init.sql with your dump data

Step 4 : Build and Run

Useful psql commands

Swagger

The server project is configured to display the Swagger UI front end. This front end serves a kind of interactive documentation where you can test out the endpoints we have used. Swagger uses the OpenAPI format to specify the API, and this file is found at server/swagger.json.

How to access Swagger

  1. Build and run the corresponding server
  2. Using your favourite Web browser
    • Access localhost:5000/swagger for Jobs Server Docs
    • Access localhost:5050/swagger for Auth Server Docs
  3. Explore the request and response templates of endpoints by clicking on them to expand them

Using Swagger to hit API endpoints

  1. Go to the swagger page in your browser
  2. Select which endpoint you want to test by clicking it
  3. Click 'Try it out'
  4. Fill in the fields in the parameters with the values you want to test with
  5. Click 'Execute'
  6. View the response in the 'Responses' section below