Skip to content

Peer to peer Resource Sharing platform for OSA IIITD

Notifications You must be signed in to change notification settings

itissandeep98/Shareiiit

Repository files navigation

BTP Project

Screenshots

image image image image image image image image

Prerequisite

  • Node - ^14.x
  • NPM - ^8.1.x
  • Python - ^3.6
  • Pipenv - ^11.9.0
  • Virtualenv - ^20.0.17

Docker Commands

docker build -t shareiiit .
docker images
docker image rm e8a702109da7
docker run -d -p 3000:3000 --name react-app react-image
docker-compose up
docker-compose down

Local Development

Frontend :

Change URL in Url.js according to your Backend site and run the following commands

cd frontend
npm install
npm run start

Backend :

cd backend
  • Activate the virtual environment using either pipenv or virtualenv
pipenv shell
pipenv install

OR

virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
  • Create migrations
python manage.py makemigrations
python manage.py migrate
  • If db needs to populated with categories and/or skills, run
python manage.py runscript init-db --script-args add-categories
python manage.py runscript init-db --script-args add-skills
  • Check .env file. For dev mode, set DJANGO_DEV as 'true' and 'false' for prod mode.

  • Start the server

python manage.py runserver

NGINX deployment on server

  • Build the frontend code using npm run build on your local computer and push the build folder to the repo
  • git pull on the entire code on ssh server
  • Copy frontend build folder to /var/www/
sudo cp -r frontend/build/* /var/www/share.osa.iiitd.edu.in/
  • Install packages and update migrations of backend
source backend/venv/bin/activate
pip install -r requirements.txt
python backend/manage.py makemigrations
python backend/manage.py migrate
python backend/manage.py collectstatic --noinput
  • Copy static folders of admin panel to /var/www/
sudo cp -r backend/staticfiles/* /var/www/share.osa.iiitd.edu.in/static/
  • Restart Socket and Nginx
sudo systemctl restart share-iiitd.socket
sudo systemctl restart nginx

All commands are available in server.sh

Reference

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04

Project Structure

Backend

The django project has been dividied into three parts based on the functionality: accounts, posts and messaging. The code corresponding to each part is inside that particular django app.

The code for notification generation is in posts/signals.py file.

The scripts folder contains two scripts: