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
- 🐍 Django Rest Framework
- 🔴 Redis
- 🐘 Postgres
- 🐋 Docker
- Daphne
- Django Channels
- Django Channels JWT Middleware
Check out the live app! Dorm Party Demo
-
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.
-
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
- Navigate to the Directory:
cd roommatefinder-backend
-
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.
-
Configure Environment Variables:
Edit the
.env.dev
file in the root directory. You can generate aSECRET_KEY
used this website. SetUSE_SECRETS
tofalse
.- The
EMAIL_HOST_USER
andEMAIL_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, setEMAIL_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
- The
-
Create a Sample Secrets File:
Create an empty
json
file insrc/roommatefinder/roommatefinder/settings
namedsample_secrets.json
with{}
as its content.touch src/roommatefinder/roommatefinder/settings/sample_secrets.json
-
Build the Docker Container:
docker-compose build
-
Apply Migrations:
docker-compose run web python3 roommatefinder/manage.py migrate
-
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
-
Run the Docker Container:
docker-compose up
-
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 forSECRET_KEY
,EMAIL_HOST_USER
, andEMAIL_HOST_PASSWORD
, and setUSE_SECRETS
totrue
.
These instructions should get you set up ready to work on Dorm Party 🎉
To run tests, follow these steps:
- 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.
-
Run tests:
Execute the following script to run tests on the API:
bash commands/__tests__/run_tests_on_api.sh
-
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 likemanage.py
, andwsgi
/asgi
files are not part of the report.
Most of the code is in the src/roommatefinder/roommatefinder
folder.
- apps : Where the
api
is defined and othercore
functionality. - settings : App settings.
The api
app is where all the endpoints and main functionality of the backend is defined.
-
internal : Internal admin endpoints. Unaccessible by not admin users.
-
serializers : Django Rest serializers used in the
views
folder. -
tests : Unit tests. One test file for every file in the
api
folder. -
utils : Utility functions for the app.
-
views : API endpoints and backend logic!
-
managers.py : A custom Profile User manager. Where the algorithm is defined.
-
consumers.py : The consumer class for all Websocket connections.
-
models.py : Models for all data.