Skip to content

Rwothoromo/WeConnect-App

Repository files navigation

WeConnect-App

Build Status Codacy Badge Coverage Status Maintainability Test Coverage CircleCI

WeConnect brings businesses and users together, and allows users to review businesses

Features

  1. Users can create an account and log in
  2. Authenticated Users can register a business.
  3. Only the user that creates the business can update and delete a business
  4. Users can view businesses.
  5. Users can give reviews about a business.
  6. Users can search for businesses based on business location or business category.

View on Heroku

EndPoint Functionality
POST /api/v2/auth/register Creates a user account
POST /api/v2/auth/login Logs in a user
POST /api/v2/auth/logout Logs out a user
POST /api/v2/auth/reset-password Password reset
POST /api/v2/businesses Register a business
PUT /api/v2/businesses/<businessId> Updates a business profile
DELETE /api/v2/businesses/<businessId> Remove a business
GET /api/v2/businesses Retrieves all businesses
GET /api/v2/businesses/<businessId> Get a business
POST /api/v2/businesses/<businessId>/reviews Add a review for a business by the logged in user
GET /api/v2/businesses/<businessId>/reviews Get all reviews for a business

Tested with

Requirements

  • Install Python.
  • Install PostgreSQL.
  • Run pip install virtualenv on command prompt.
  • Run pip install virtualenvwrapper-win for Windows.
  • Run set WORKON_HOME=%USERPROFILES%\Envs for Windows.

Setup

  • Run git clone this repository and cd into the project root.
  • Run mkvirtualenv venv for Windows or python3 -m venv ../wc-venv for Unix/Mac.
  • Run workon venv for Windows or source ../wc-venv/bin/activate for Unix/Mac.
  • Run pip install -r requirements.txt.
  • Run createdb <weconnect_db> and createdb <test_weconnect_db> on the psql bash terminal.
  • Run touch .env to create a file for storing environment variables. Add the following lines (use set for Windows instead of export, used here for Unix/Mac) to it:
export DATABASE_URL=postgresql://<db_user>:<password>@localhost/<weconnect_db>
export SECRET_KEY=<some_secret_value>
export FLASK_CONFIG=development
  • Run source .env to activate the environment variables on Unix/Mac.
  • Run env to verify the above.
  • Run the migrations:
    • python manage.py db init to create a migration repository.
    • python manage.py db migrate to update the migration script.
    • python manage.py db upgrade to apply the migration to the database.
  • Run python manage.py runserver or python3 run.py to run on the default ip and port.
  • View the app on http://127.0.0.1:5000/.

Use endpoints

  • View the api on http://127.0.0.1:5000/api/v2/
  • Test it's usage with postman

Use api documentation

  • View the api on Heroku
  • View the api on http://127.0.0.1:5000/apidocs

Unittests

  • Change the .env file to:
export DATABASE_URL=postgresql://<db_user>:<password>@localhost/<test_weconnect_db>
export SECRET_KEY=<some_secret_value>
export FLASK_CONFIG=testing
  • Run source .env.
  • Run the migrations like before.
  • Run python manage.py test or pytest.

GitHub pages

Go to WeConnect

Notes

For detailed instructions on heroku deployments, go here or here

Extra

  • Run find . | grep -E "(\__pycache__|\migrations|\.pytest_cache)" | xargs rm -rf to remove unnecessary files.