gabekutner / roommatefinder-backend

Welcome to DormParty: a social platform for college kids looking for dorm roommates. Help out with the first version of RoommateFinder by sharing feedback and contributing to the code.
https://gabekutner.github.io/roommatefinder-mobile/
Apache License 2.0
1 stars 2 forks source link
api django django-rest-framework matching matching-algorithm postgresql python redis-cache websockets
Dorm Party Icon

Dorm Party

An app where incoming college freshmen can find dorm roommates.

This is just the backend of the app, if you're looking for the frontend: https://github.com/gabekutner/roommatefinder-mobile

Table of Contents

Technologies Used

Check out the live app! Dorm Party Demo

Getting Started

🍴 Fork and Clone the Repo

  1. Fork the Repo: Click the "Fork" button on the top right of this repository. If you're new to forking, check out this YouTube Guide.

  2. Clone Your Fork: Click the Clone or Download button on the top right of your forked repo and clone it:

    git clone https://github.com/your-username/roommatefinder-backend.git
  3. Navigate to the Directory:

    cd roommatefinder-backend

⬇️ Running the Development Server

  1. Install Docker:

    Make sure Docker is installed and set up on your machine. If you don't have Docker, read this guide for installation instructions.

  2. Configure Environment Variables:

    Edit the .env.dev file in the root directory. You can generate a SECRET_KEY used this website. Set USE_SECRETS to false.

    • The EMAIL_HOST_USER and EMAIL_HOST_PASSWORD are used for sending OTP verification codes via email. In development, you can skip setting these variables unless you want to send emails. To view OTP codes, access the Django admin panel (http://localhost:8000/admin/) and check the Profile model. If you want to work with emails, set EMAIL_HOST_USER with your email and generate an app password. See this tutorial for guidance.

    Example .env.dev file:

    SECRET_KEY=""
    DEBUG=True
    DJANGO_SETTINGS_MODULE=roommatefinder.settings.dev
    DATABASE_URL=postgres://myuser:mypassword@db:5432/mydatabase
    REDIS_URL=redis://redis:6379/0
    DATABASE_NAME="postgres"
    DATABASE_USER="postgres"
    DATABASE_PASSWORD="postgres123"
    DATABASE_HOST="db"
    DATABASE_PORT=5432
    EMAIL_HOST="smtp.gmail.com"
    EMAIL_PORT=587
    EMAIL_HOST_USER=""
    EMAIL_HOST_PASSWORD=""
    USE_SECRETS=False
  3. Create a Sample Secrets File:

    Create an empty json file in src/roommatefinder/roommatefinder/settings named sample_secrets.json with {} as its content.

    touch src/roommatefinder/roommatefinder/settings/sample_secrets.json
  4. Build the Docker Container:

    docker-compose build
  5. Apply Migrations:

    docker-compose run web python3 roommatefinder/manage.py migrate
  6. Create a Superuser:

    This superuser will allow you to access the admin panel. Use the credentials you choose to log in.

      docker-compose run web python3 roommatefinder/manage.py createsuperuser
  7. Run the Docker Container:

    docker-compose up
  8. Access the API:

    Find your IP address in your Wi-Fi settings. If your IP is 10.0.0.49, the API will be available at: http://10.0.0.49:8000/.

    Important: Before publishing your code to GitHub, revert the .env.dev file by removing the values for SECRET_KEY, EMAIL_HOST_USER, and EMAIL_HOST_PASSWORD, and set USE_SECRETS to true.


These instructions should get you set up ready to work on Dorm Party 🎉

Running Tests

To run tests, follow these steps:

  1. Install Coverage:

    Ensure you have coverage installed. You can either install it manually or use pip to install from test.txt in the requirements folder.

  2. Run tests:

    Execute the following script to run tests on the API:

     bash commands/__tests__/run_tests_on_api.sh
  3. Run Test Coverage:

    To see how much of the repository is covered by tests, run:\

     bash commands/__tests__/manual_coverage.sh

Note: This coverage report only includes the api app. Files like manage.py, and wsgi / asgi files are not part of the report.

Project Structure

Most of the code is in the src/roommatefinder/roommatefinder folder.

The api app is where all the endpoints and main functionality of the backend is defined.