Skip to content

LabConnect-RCOS/LabConnect-Backend

Contributors Forks Issues Pull Requst Activity Stargazers

About

LabConnect Logo

A centralized website to connect RPI undergraduate students with research or lab positions
posted by professors, graduate students, or lab staff.

Built With

Python Flask PostgreSQL SQLAlchemy

Prerequisites

  • Clone
    • Clone repo through CLI
      $ git clone https://github.com/LabConnect-RCOS/LabConnect-Backend.git
    • or through Github Desktop
  • Install Python 3.12.4
    • Mac
      brew install python@3.14
      
    • Windows: here
    • Linux:
      $ sudo apt install python3
      
  • Install PostgreSQL
    • The application is built and tested with postgresql 17
    • Mac: UI here or
    brew install postgresql@17
    
    • Windows: here
    • Linux:
      $ sudo apt install postgresql
      
  • Install Libraries
    $ python3 -m pip install -r requirements.txt
    
  • Setup user and initialize database
    • Windows:

      $ psql -U postgres -d postgres
      CREATE DATABASE labconnect;
      ALTER USER postgres WITH PASSWORD 'root';
      \q
    • macOS (Homebrew):

      # start postgres if not running
      $ brew services start postgresql
      $ psql -U postgres -d postgres
      CREATE DATABASE labconnect;
      ALTER USER postgres WITH PASSWORD 'root';
      \q
    • macOS (Postgres.app):

      # open Postgres.app, then in a terminal (Postgres.app adds psql to PATH)
      $ psql -d postgres
      CREATE DATABASE labconnect;
      ALTER USER postgres WITH PASSWORD 'root';
      \q
    • Linux:

      $ sudo -i -u postgres
      $ psql
      ALTER USER postgres WITH PASSWORD 'root';
      \q
      $ exit
      $ sudo -u postgres createdb labconnect
    • Final step

      • Run the db initialization with test/dummy data make create

Testing

  • Run pytest
    • Run all the test files and generate a coverage report. Coverage reports are set up to output to the terminal and provide an HTML file that can be viewed to show what branches or statements are not covered. It is in the project's best interest to have high coverage to ensure all statements and branches work as expected.
    $ make test
    or manually
    $ python3 -m pytest
    or manually with a coverage report generated
    $ python3 -m pytest --cov
    or individual tests
    $ python3 -m pytest -q tests/(file_name).py

Development

  • Run flask with python directly
    • Run all the test files
    $ make develop
    or
    $ python run.py

Deployment

Create PRs to the main branch. Upon merging, a new Docker container will be created and pushed to the packages for this repo.

Production

Use the Docker container in the packages tab. You can set these environment variables:

Environment Variables

Variable Name Default Value Description
SECRET_KEY main-secret Secret Key for Flask
JWT_SECRET_KEY jwt-secret Secret Key for JWT
FRONTEND_URL None URL to the frontend server
DB None URI for postgres database eg. postgresql+psycopg2://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres/labconnect
CONFIG config.TestingConfig URL to the backend server
  • Run gunicorn to test how the service runs in production
    $ make run
    or with Makefile
    $ gunicorn run:app -w 6 --preload --max-requests-jitter 300 --bind 0.0.0.0:8000

Contact Us

Discord Jira

License

Distributed under the Apache License. See LICENSE for more information.

About

Centralized website for people to post and find lab and research opportunities on campus

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors 17

Languages