Kenttrann2302 / StudyHub-Backend

This repo is for StudyHub (a full-stack web app that helps student to find the study group that fits their needs!) server development. This involves of all streaming APIs that help building and maintaining the application's server!
6 stars 1 forks source link
aws-dynamodb aws-lambda aws-ses docker flask postgresql-database python server sqlalchemy-orm

StudyHub-Backend

Table of Contents

Overview

StudyHub is an online tool that facilitates the development of efficient and productive study groups. It strives to bring together students who have similar study preferences, courses, and locations in order to improve collaborative learning experiences.

Built With

Architecture

Features

For development purpose:

Note: If you're using Windows, please clone this repo in WSL and run the docker commands in there.

To clone and run this application you'll need:

Then on your terminal, run the following from the root of this repository:

# Build the images and containers then run the containers
docker compose up -d --build

In order to test the APIs of each endpoint at http://0.0.0.0:8080/, use Postman collections.

To stop the containers and to start the containers after the initial build:

# For stopping and removing the containers created above
# Use the -v flag to remove the associated volumes
docker compose down

# For creating and starting the container
# after the initial build
docker compose up -d

Good-to-Know Commands

Run command in a container

To run shell command in any of the two containers:

docker compose exec <service-name> <command> <list-of-args>

# Example: Running SQL commands in the container
PGPASSWORD=<password> psql -U <username> <database>

# Example: Make backend migrations with Flask Migrations
docker compose exec backend flask db init
docker compose exec backend flask db migrate -m <migration-message>
docker compose exec backend flask db upgrade

We recommend creating alias(es) to shorten the above commands

Common Issues

Database is not up to date after running migration scripts

# By running this command, the database will be up to date with the latest migration
docker compose exec backend flask db stamp head

Import "{framework/library-name}" could not be resolved error from Pylance

If you're using VSCode and see this error. This mean the framework/library was not installed globally or installed in the virtual environment you're using. We highly recommend setting up a new virtual environment. So remove your existing environment in the root of this repository. Then run the following commands

# Ensure you are in the root of this repository
python3 -m venv env # Our gitignore assumes the virtual environment name is env
source env/bin/activate
pip install -r backend/requirements.txt

Then select the interpreter in env/bin/. The issue should disappears.

Note: We assumed you're using MacOS or Linux. For Windows, please find the corresponding command for setting up Python virtual environment.