This backend is created in django rest framework with postgresql.
I also have our own forked version of dj-rest-auth called dj-rest-auth-social that implements extra features (such as saving refresh token and expiry in the db to re-use)
- Python 3.10
- Django 4.0.4
- Pipenv
- Google OAuth credentials which has access to google calendar API. Set the Authorized redirect URIs to
http://localhost:3000/api/auth/callback/google - OAuth consent screen setup with these scopes:
[/auth/calendar.readonly, /auth/calendar.events, openid, /auth/userinfo.email, /auth/userinfo.profile]
- Setup PostgreSQL from the installer, or use docker
- Download Pipenv
- Run
pipenv install - Run
pipenv shell - Copy
./app/env.exampleto./app/.env - Adjust the details of DB, also randomize the secrets
- Once DB connection is verified, run
python manage.py mgirate - Run
python manage.py runserver
Note: to develop locally you might need to change ./app/core/settings.py from this line:
239. DEBUG = True
241. ALLOWED_HOSTS = [".meetsy.xyz", "localhost"]
- Run
python manage.py createsuperuserthen follow instruction to create super user - go to
localhost:8000/adminand login with super user - Click Social applications -> add new at the top right
- Choose google -> enter secrets and api key -> save
- Clear up all the
.envlocally in both root and./app - Create postgres db in fly
- Setup all these envs by running
flyctl secrets setorflyctl secrets import
DJANGO_SECRET_KEY=test
JWT_SECRET_KEY=test
MEETSY_POSTGRES_DB=test
MEETSY_POSTGRES_USER=test
MEETSY_POSTGRES_PASSWORD=asdfasdf
MEETSY_POSTGRES_HOST=localhost
- Run
make deploy-fly
- Clone the repo to your VPS
- Setup
.envfile in root and./app - Run
docker-compose up -d postgres certbot - After certbot has successfully create the cert, you can run
docker-compose up -d nginx core
Note: don't forget to point your A record to the IP address of your VPS
- copy
env.exampleto.env - Fill up this part, note the part with the prefix
MEETSYwill be used by our backend. The former is for postgres default
POSTGRES_VERSION=alpine
POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_PORT=5432
MEETSY_POSTGRES_DB=
MEETSY_POSTGRES_USER=
MEETSY_POSTGRES_PASSWORD=
- Run
docker-compose up -d postgres - Adjust
./app/.envusingMEETSY_*db details