How to Prepare Your Local PC for the Backend Development - bounswe/bounswe2024group11 GitHub Wiki

Please note that all the commands here are for Bash/Zsh terminals. For other shells (e.g., cmd in Windows), you may need to make little changes to all commands


Let's say you want to work on our repo, specifically for the backend part. First of all, you should clone the repository to your local computer.

Clone the repository

Inside the directory you want to clone the repo to, run one of these commands

# Clone with SSH
git clone [email protected]:bounswe/bounswe2024group11.git

# Clone with HTTPS
git clone https://github.com/bounswe/bounswe2024group11.git

# Clone with GitHub CLI
gh repo clone bounswe/bounswe2024group11

I personally suggest using the SSH version or the GitHub CLI version in general, but they involve some additional steps for the first time. You may continue with the HTTPS version for this project as well.

Since everyone learned to use Git at the very beginning of the semester, I don't dive into details here. You may want to check GitHub Docs and Git Reference.

Create a virtual environment

We need to create a virtual environment and do all backend-related jobs inside that virtual environment.

# Change directory to the project's backend directory
cd ./bounswe2024group11/backend


# create a virtual environment

## On bash/zsh shells (i.e., on macOS and the most of the Linux-based distros)
python3 -m venv venv

## On Windows
python -m venv venv



# Activate the virtual environment

## On bash/zsh shells (i.e., on macOS and the most of the Linux-based distros)
source ./venv/bin/activate

## On Windows
venv\Scripts\Activate.ps1 (Powershell)
venv\Scripts\activate.bat (cmd)

While initializing our project, we decided to use Python 3.12. So create your virtual environments accordingly. You may want to take a look at Python Documentation.

Installations

Before starting development, we need to install all the requirements. Inside the ./backend directory:

# Install requirements
pip install -r requirements.txt

Alternatively, you can install them manually. However, the list of required libraries may and probably will change from time to time. So, at the very beginning of the project, you can use these commands, but be careful when you want to use them later.

# Install Django
pip install Django

# Install Django REST Framework
pip install djangorestframework

Run the app

To check if everything is okay, try to run the Django project. Inside the ./backend directory:

# Run the Django project server
python manage.py runserver

If you see a page without an error when you visit the URL in the terminal, which is similar to http://127.0.0.1:8000, your server works properly.

Congratulations! You have cloned the project, created a virtual environment, and installed the dependencies. Now, you are ready to start your development.

Please note that all the commands here are for Bash/Zsh. For other shells (e.g., cmd in Windows), you may need to make little changes to all commands