Getting Started - shleen/threadline GitHub Wiki
threadline is an iOS app, with a Django backend. So, we do all of our development on a Macbook and assume the same of you, dear reader.
For all three of the following sections, you'll need a copy of the repo. Clone it using git clone [email protected]:shleen/threadline.git
. The following steps will assume that your current directory is in ./threadline/
- If you do not have Xcode installed yet, install it.
- Clone the repo
git clone [email protected]:shleen/threadline.git
- Open the folder
threadline/app
in Xcode - Run in your chosen simulator or device by clicking the play button or using
Cmd + R
-
cd
into the backend directorycd threadline/backend
- Create a virtual environment, ensure the virtual environment activation file is executable, and activate the virtual environment.
python -m venv venv chmod +x ./venv/bin/activate # for bash and zsh, see https://docs.python.org/3/library/venv.html#how-venvs-work for other shells source venv/bin/activate
- Install requirements
pip install -r requirements.txt
- Run the server
python manage.py runserver
- [Optional] Configure systemd service
[Unit] Description=Threadline Backend Requires=postgresql.service After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=on-failure RestartSec=1 User=<YOUR_USER> Group=<YOUR_GROUP> WorkingDirectory=<BACKEND_DIR> ExecStart=<BACKEND_DIR>/venv/bin/python <BACKEND_DIR>/manage.py runserver [Install] WantedBy=multi-user.target
Tips!
- Once you're running the backend, you can test the endpoints using HTTPie or Postman, or cURL. For example, you can send a POST request to
/clothing/create
using HTTPie withhttp -f POST http://127.0.0.1:8000/clothing/create username=sheline type=shirt fit=loose occasion=casual winter=0 image@~/Desktop/shirt.png
-
Sign up for a Cloudflare account
-
Navigate to the R2 dashboard, and create a bucket called
threadline-clothing
. -
From the 'Overview' page, click on this API button
-
Click 'Manage API tokens' and create an API Token with 'Object Read & Write' permission.
-
Take note of the ACCESS_KEY_ID and the SECRET_ACCESS_KEY
-
Paste these two values into
threadline/backend/blank.env
-
Rename
blank.env
to.env
. Gitignore should already take care of this, but remember to not commit this file to Github. -
Navigate back to your R2 bucket. Navigate to the Settings page, and copy the value in
S3 API
. -
In
threadline/backend/apps/core/images.py
, replace theendpoint_url
parameter with the value you copied below. Remove everything after the/
in the URL.
-
cd
into the backend directorycd threadline/backend
- Install PostgreSQL if you do not have it installed. Recommended to use the interactive installer from this page
- If you've already created a virtual environment, activate it
source venv/bin/activate
.
If not, create and activate a virtual environment by following the steps in step 2 of the above Backend section - Install Psycopg, a PostgreSQL adapter for Python
pip install "psycopg[binary]"
- Create a database called
threadline_db
- You can do this by either opening pgAdmin, logging in, and right clicking on 'Databases' in the left sidebar menu, then 'Create'
- or through the cli using
/Library/PostgreSQL/17/scripts/runpsql.sh create database threadline_db; exit;
- Create a
.pg_service.conf
file to tell Django how to look for the database. ReplaceUSER
andPASSWORD
with your PostgreSQL user and password.cat << EOF >> ~/.pg_service.conf [db_service] host=localhost dbname=threadline_db user=USER password=PASSWORD port=5432 EOF
- Run migrations for the database
python manage.py makemigrations python manage.py migrate
- [Optional] Seed data! If you want to populate the db with dummy data that you can actually use, run
python manage.py seed_data
Libraries:
APIs: