This repository contains the backend code for the Recipe Sharing Platform, built using Django. The backend provides API endpoints for managing recipes and integrates with a React frontend deployed on AWS S3 and CloudFront.
- RESTful API for recipe management
- User authentication and authorization
- CRUD operations for recipes
- Image handling for recipe images
- PostgreSQL database integration
- Additional endpoints for updating and deleting recipes by name and user ID
- Django
- Django Rest Framework
- PostgreSQL
- AWS EC2
- AWS S3
- AWS CloudFront
-
Clone the repository:
git clone https://github.com/yourusername/recipe-sharing-backend.git cd recipe-sharing-backend
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Setup the PostgreSQL database and update
settings.py
:DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'your_db_name', 'USER': 'your_db_user', 'PASSWORD': 'your_db_password', 'HOST': 'your_db_host', 'PORT': 'your_db_port', } } ALLOWED_HOSTS = ['your_ec2_public_ipv4']
-
Run migrations and start the development server:
python manage.py migrate python manage.py runserver
-
Launch an EC2 instance and SSH into it.
-
Install required software:
sudo apt update sudo apt install python3-pip python3-dev libpq-dev nginx curl sudo apt install postgresql postgresql-contrib
-
Clone the repository and set up the virtual environment:
git clone https://github.com/yourusername/recipe-sharing-backend.git cd recipe-sharing-backend python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
-
Configure PostgreSQL and update
settings.py
as mentioned above. -
Run migrations:
python manage.py migrate
-
Configure Gunicorn:
pip install gunicorn gunicorn --workers 3 --bind unix:/home/ubuntu/recipe-sharing-backend/recipe-sharing-backend.sock wsgi:application
-
Configure Nginx:
sudo nano /etc/nginx/sites-available/recipe-sharing
Add the following configuration:
server { listen 80; server_name your_server_ip; location / { include proxy_params; proxy_pass http://unix:/home/ubuntu/recipe-sharing-backend/recipe-sharing-backend.sock; } }
Enable the configuration:
sudo ln -s /etc/nginx/sites-available/recipe-sharing /etc/nginx/sites-enabled sudo nginx -t sudo systemctl restart nginx sudo systemctl restart gunicorn
- Build the React project:
npm run build
- Upload the build folder to an S3 bucket:
aws s3 sync build/ s3://your-s3-bucket-name
- Set up CloudFront to serve the S3 bucket content.
Use the EC2 instance's public IPv4 address as the backend URL to call the endpoints. For example:
- GET:
http://<ec2_public_ipv4>/api/recipes/
- POST:
http://<ec2_public_ipv4>/api/recipes/
- GET:
http://<ec2_public_ipv4>/api/recipes/user/{uid}
- PUT:
http://<ec2_public_ipv4>/api/recipes/update/<name>/<uid>/
- DELETE:
http://<ec2_public_ipv4>/api/recipes/delete/<name>/<uid>/
This project is licensed under the MIT License.
I am Dipit Vasdev, a highly motivated problem solver with a passion for neural networks and machine learning. I recently completed my Master's degree in Computer Engineering at New York University, and my greatest strength lies in my drive for solving complex problems in computer science. I possess a wealth of technical skills in machine learning, deep learning, Android development, and more, and I have taken part in various projects and internships to continuously improve my skills and knowledge.
If you have any feedback, please reach out to me at [email protected].