π§ Part 1 β Foundations
Key idea: Before you write a single line of backend code, your machine needs to be set up correctly. This section walks you through every step β from installing your IDE to running your first Python program. Future sections assume you have completed this setup.
The goal is not to memorise commands. The goal is to understand the system. Every tool exists to solve a problem β understand why it exists, not just how to use it.
Navigation
| β Handbook Home | Part 2: Backend β |
1. Full Development Environment Setup
This is the most important section in the handbook. Get everything here working before moving forward. When something goes wrong in a later section, the first question will always be: βDid you complete the setup checklist in Part 1?β
1.1 Choose Your IDE β VS Code or PyCharm?
An IDE (Integrated Development Environment) is the app you use to write, run, and debug code. Think of it as a text editor with superpowers β it highlights errors, lets you run code, shows you your files, and includes a terminal.
You have two great options for Python. Pick one and stick with it β do not install both and switch back and forth while youβre learning.
Side-by-Side Comparison
| Feature | π¦ VS Code | π© PyCharm |
|---|---|---|
| Cost | Free, open source | Free Community edition; paid Professional |
| Weight | Lightweight (~100 MB) | Heavier (~700 MB+) |
| Setup effort | A few extensions needed | Python-ready out of the box |
| Best for | All languages, flexible | Python/Django/FastAPI projects |
| Virtual env detection | Manual (select interpreter) | Automatic (detects venv on open) |
| Beginner friendliness | ββββ | βββββ |
| Professional use | Very common | Common in Python-heavy teams |
Recommendation: Start with VS Code β it is the most widely used editor on real engineering teams and works for every language youβll ever encounter. PyCharm is an excellent alternative if you find VS Code confusing or want automatic Python setup.
1.2 Installing VS Code
Download: code.visualstudio.com
πͺ Windows
- Go to code.visualstudio.com and click Download for Windows.
- Run the downloaded
.exeinstaller. - On the βSelect Additional Tasksβ screen, tick both of these:
- β
Add "Open with Code" action to Windows Explorer file context menu - β
Add to PATH (requires shell restart)
- β
- Finish the installer and reopen any terminal windows.
- Verify: open a terminal and run
code --version. You should see a version number.
Common issue: If
codeis not recognised after install, restart your computer to apply the PATH change.
π Mac
- Go to code.visualstudio.com and click Download for Mac.
- Open the downloaded
.zipβ it extractsVisual Studio Code.app. - Drag
Visual Studio Code.appinto your Applications folder. - Open VS Code, then press
Cmd+Shift+P, typeshell command, and select βShell Command: Install βcodeβ command in PATHβ. - Verify: open Terminal and run
code --version.
Common issue: βVS Code cannot be opened because it is from an unidentified developer.β Go to System Settings β Privacy & Security and click Open Anyway.
π§ Linux (Ubuntu/Debian)
# Download and install the Microsoft GPG key and repository
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
# Install VS Code
sudo apt update
sudo apt install code
Verify: run code --version.
Install Essential VS Code Extensions
After installing VS Code, add these extensions (they make Python development much easier):
- Press
Ctrl+Shift+X(Windows/Linux) orCmd+Shift+X(Mac) to open the Extensions panel. - Search for and install each of these:
| Extension | Publisher | Why you need it |
|---|---|---|
| Python | Microsoft | Syntax highlighting, linting, debugger, interpreter selection |
| Pylance | Microsoft | Smarter code completion and type checking |
| GitLens | GitKraken | See who changed what and when, right in the editor |
| Docker | Microsoft | View and manage containers from the sidebar |
1.3 Installing PyCharm (Alternative)
Download: jetbrains.com/pycharm/download
Download the Community edition β it is free and covers everything in this handbook.
πͺ Windows
- Download the Community installer (
.exe). - Run it and follow the wizard.
- On the Installation Options screen, tick βAdd launchers to PATHβ so you can open PyCharm from a terminal.
- Launch PyCharm from the Start menu after install.
π Mac
- Download the Community
.dmg. - Open the
.dmgand drag PyCharm CE into Applications. - Open PyCharm from Applications β macOS may ask you to confirm opening an app from the internet; click Open.
π§ Linux
# Install using the JetBrains Toolbox (recommended) or snap
sudo snap install pycharm-community --classic
Or download the .tar.gz from the website, extract it, and run bin/pycharm.sh.
PyCharm First-Run Setup
- On first launch, PyCharm asks about plugins β skip and use defaults.
- Choose New Project to create your first project (covered in section 1.7).
- PyCharm automatically detects Python installed on your machine β youβll see it pre-selected in the interpreter dropdown.
PyCharm tip: Unlike VS Code, PyCharm creates a virtual environment automatically when you create a new project. It also shows you which interpreter is active in the bottom-right status bar at all times.
1.4 Installing Python
Python is the programming language this handbook is built around.
Download: python.org/downloads
Always install Python 3.11 or newer. Python 2 is obsolete β do not install it.
πͺ Windows
- Go to python.org/downloads and click the latest Python 3.x.x button.
- Run the downloaded
.exeinstaller. -
β οΈ Critical step: On the first screen, tick βAdd Python to PATHβ before clicking Install Now.
β Add Python 3.x to PATH β TICK THIS or python won't work in any terminal - Click Install Now.
-
Once done, open a new terminal window (important β old windows donβt see the new PATH) and verify:
python --versionExpected output:
Python 3.11.x(or newer)
Common Windows issues:
| Problem | What you see | Fix |
|---|---|---|
| Forgot to add to PATH | 'python' is not recognized as an internal or external command |
Reinstall Python and tick βAdd to PATHβ, or add it manually via System Properties β Environment Variables |
| Python opens Microsoft Store | Microsoft Store opens instead of Python | Go to Settings β Apps β Advanced app settings β App execution aliases and turn off python.exe and python3.exe |
| Wrong version | Python 2.7.x |
You have Python 2 installed β use python3 command instead, or uninstall Python 2 |
π Mac
macOS comes with Python 2 pre-installed (old and unusable for our purposes). Install Python 3 separately.
Option A β Official installer (recommended for beginners):
- Download from python.org/downloads β the macOS installer
.pkg. - Run the package installer and follow the steps.
-
After install, run the SSL certificate fixer that comes with it:
/Applications/Python\ 3.11/Install\ Certificates.command(Replace
3.11with your installed version number.) -
Verify in Terminal:
python3 --version
Option B β Homebrew (for developers who already have Homebrew):
brew install python@3.11
Common Mac issues:
| Problem | Fix |
|---|---|
python: command not found |
Use python3 β macOS ships Python 2 as python |
SSL: CERTIFICATE_VERIFY_FAILED |
Run the Install Certificates script from the Python Applications folder |
zsh: command not found: python3 |
Python not on PATH β add to ~/.zshrc: export PATH="/usr/local/bin:$PATH" |
π§ Linux (Ubuntu/Debian)
# Update package list
sudo apt update
# Install Python 3.11
sudo apt install python3.11 python3.11-venv python3-pip -y
# Verify
python3.11 --version
python3 --version
pip3 --version
Tip: On Ubuntu 22.04+,
python3is Python 3.10+. Usepython3.11explicitly if you need that specific version.
1.5 Installing Git
Git is the tool that tracks every change you make to your code. It lets you go back in time, work in teams, and share code on GitHub.
Download: git-scm.com
1.5a Sign Up for a GitHub Account
GitHub is the platform where your code lives online. Think of it as a combination of a cloud backup for your code and a social network for developers. You will push your projects here so the team can see your work, review it, and collaborate with you.
Create Your Account
- Go to github.com and click Sign up.
- Enter your email address and click Continue.
- Create a password (use something strong β at least 12 characters).
- Choose a username. This will appear on all your commits and repos β keep it professional (e.g.,
jane-smithorjsmith-dev). - Complete the verification puzzle, then check your email for the verification code.
- On the βWelcome to GitHubβ screen, you can skip or answer the questions about your use β click Continue until you reach the dashboard.
Youβre in! Your GitHub dashboard is at
github.com/<your-username>.
Connect Git on Your Machine to GitHub
After installing Git (section 1.5), you need to authenticate so GitHub accepts your pushes. The most secure method is Personal Access Tokens (PAT).
Step 1 β Set your identity in Git
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Use the same email address you signed up to GitHub with β this links your commits to your account.
Step 2 β Generate a Personal Access Token (PAT)
A PAT is like a password for the terminal. GitHub no longer accepts your account password for Git operations.
- Log in to github.com.
- Click your profile photo (top-right) β Settings.
- In the left sidebar, scroll down and click Developer settings.
- Click Personal access tokens β Tokens (classic).
- Click Generate new token β Generate new token (classic).
- Give it a name (e.g.,
My Laptop Token). - Set Expiration to 90 days (or
No expirationfor personal learning machines). - Under Scopes, tick β repo (this covers all repo operations youβll need).
- Click Generate token.
- Copy the token immediately β GitHub will not show it again.
Save your token in a password manager or a secure note. You will need it the first time you push from this machine.
Step 3 β First Push (entering your token)
The first time you run git push, Git will prompt you for credentials:
πͺ Windows
A dialog box called Windows Credential Manager will pop up. Enter:
- Username: your GitHub username
- Password: paste your PAT (not your account password)
Git stores this securely β you wonβt be asked again on this machine.
π Mac
The macOS Keychain dialog will appear. Enter:
- Username: your GitHub username
- Password: paste your PAT
macOS stores it in Keychain β you wonβt be prompted again.
π§ Linux
# Enable credential caching so Git remembers for 1 hour
git config --global credential.helper cache
The first push will prompt for username and password β enter your GitHub username and paste the PAT as the password.
Tip: If you push and see
remote: Support for password authentication was removed, it means you used your GitHub password instead of a PAT. Create a new PAT and use that.
πͺ Windows
- Download the Git for Windows installer from git-scm.com.
- Run the installer β you can accept defaults on most screens.
- On the screen βChoosing the default editor used by Gitβ, select VS Code from the dropdown if you installed it.
- On βAdjusting your PATH environmentβ, keep the default:
Git from the command line and also from 3rd-party software. - Finish the install.
After install, you now have Git Bash β a Unix-style terminal on Windows. You can use this instead of Command Prompt for all terminal commands in this handbook.
Verify (open Git Bash or PowerShell):
git --version
Expected: git version 2.x.x
π Mac
Option A β Xcode Command Line Tools (simplest):
xcode-select --install
A dialog will appear β click Install. This installs Git (and other dev tools) automatically.
Option B β Homebrew:
brew install git
Verify:
git --version
π§ Linux (Ubuntu/Debian)
sudo apt update
sudo apt install git -y
git --version
First-Time Git Configuration
After installing Git on any OS, tell it your name and email. Git uses this to label your commits.
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
You only do this once per machine. It applies to all your Git projects.
1.6 Installing Docker Desktop
Docker lets you run software in isolated containers β same code, same environment, on any machine. Youβll use it later for running databases and packaging your API.
Download: docker.com/products/docker-desktop
πͺ Windows
- Download Docker Desktop for Windows.
- Run the installer. It may prompt you to enable WSL 2 (Windows Subsystem for Linux) β click Enable/Install if asked. This is required.
- Restart your computer if asked.
- Launch Docker Desktop from the Start menu β it starts in the background (look for the whale icon in the system tray).
Verify (in any terminal):
docker --version
docker compose version
Common Windows issues:
| Problem | Fix |
|---|---|
| βWSL 2 installation is incompleteβ | Open PowerShell as Admin and run: wsl --update |
| Docker Desktop wonβt start | Make sure virtualisation is enabled in BIOS (usually is on modern PCs) |
docker: command not found |
Docker Desktop is not running β start it from the Start menu |
π Mac
- Download Docker Desktop for Mac β choose Apple Silicon (M1/M2/M3) or Intel based on your Mac.
- Open the
.dmgand drag Docker to Applications. - Open Docker from Applications β it starts in the background (whale icon in the menu bar).
- Wait for the whale icon to become steady (not animated) β Docker is ready.
Verify:
docker --version
docker compose version
π§ Linux (Ubuntu)
# Install Docker Engine
sudo apt update
sudo apt install ca-certificates curl -y
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
# Run Docker without sudo (log out and back in after this)
sudo usermod -aG docker $USER
Verify after logging out and back in:
docker --version
docker compose version
Note: On Linux there is no Docker Desktop GUI β Docker runs as a background service. This is fine for this handbook.
1.7 Verify All Installations
Open a terminal (Git Bash on Windows, Terminal on Mac/Linux) and run each command. Every command should return a version number β not an error.
# Check Python
python --version # Windows
python3 --version # Mac / Linux
# Check pip (Python package manager)
pip --version # Windows
pip3 --version # Mac / Linux
# Check Git
git --version
# Check Docker
docker --version
docker compose version
Expected output (your exact versions may differ β thatβs fine):
Python 3.11.9
pip 23.3.1 from ...
git version 2.44.0
Docker version 26.1.1
Docker Compose version v2.27.0
β οΈ If any command gives an error, stop here and fix it before continuing. Every other part of this handbook depends on these tools working.
1.8 Open a Project in Your IDE
Now that everything is installed, letβs open a project folder and get comfortable in the IDE.
VS Code
- Create a new folder on your computer called
hello-project(anywhere you like β your Desktop or Documents is fine). - Open VS Code.
- Go to File β Open Folder and select
hello-project. - VS Code opens the folder. The left sidebar shows your project files (currently empty).
Open the integrated terminal in VS Code:
- Press
Ctrl+`(Windows/Linux) orCmd+`(Mac) β the backtick key, top-left of most keyboards. - Or go to Terminal β New Terminal from the menu bar.
A terminal panel opens at the bottom, already pointing to your project folder. You can run all commands from here β you do not need a separate terminal window.
Select the Python interpreter in VS Code:
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) to open the Command Palette. - Type
Python: Select Interpreterand press Enter. - Choose the Python version you installed (e.g.,
Python 3.11.x).
Common issue: If no Python shows up, VS Code canβt find it. Make sure Python is on your PATH (check by running
python --versionin the terminal). If it works in the terminal but not in VS Code, restart VS Code.
PyCharm
- Open PyCharm.
- Click New Project.
- Set the Location to a folder called
hello-project. - Under Python Interpreter, select New environment using Virtualenv β PyCharm will create a venv automatically.
- Click Create.
Open the terminal in PyCharm:
- Press
Alt+F12(Windows/Linux) orOption+F12(Mac). - Or go to View β Tool Windows β Terminal.
Check the active interpreter in PyCharm:
Look at the bottom-right corner of the PyCharm window. It shows the active Python interpreter (e.g., Python 3.11 (hello-project)). Click it to change.
1.9 Create and Activate a Virtual Environment
A virtual environment (venv) is an isolated box of Python packages for your project. It prevents version conflicts between projects and keeps your global Python installation clean.
Every project should have its own venv. This is non-negotiable on real teams.
Skip this section if you are using PyCharm β PyCharm already created the venv for you in step 1.8.
Step 1 β Create the virtual environment
Open the terminal in your IDE (or any terminal) and make sure you are in your project folder:
# Make sure you are in your project folder
cd hello-project # skip if you are already there
Now create the venv:
| OS | Command |
|---|---|
| πͺ Windows | python -m venv venv |
| π Mac | python3 -m venv venv |
| π§ Linux | python3 -m venv venv |
This creates a folder called venv/ inside your project. You only do this once per project.
Step 2 β Activate the virtual environment
You must activate the venv every time you open a new terminal window. When active, your terminal prompt shows (venv) at the start.
| OS | Command |
|---|---|
| πͺ Windows (PowerShell) | venv\Scripts\Activate.ps1 |
| πͺ Windows (Command Prompt) | venv\Scripts\activate.bat |
| πͺ Windows (Git Bash) | source venv/Scripts/activate |
| π Mac | source venv/bin/activate |
| π§ Linux | source venv/bin/activate |
After activation, your prompt looks like this:
(venv) user@machine:~/hello-project$ β (venv) means it's active
Step 3 β Verify the venv is active
# Should show a path inside your project's venv folder
which python # Mac / Linux
where python # Windows
Expected output (Mac/Linux):
/home/yourname/hello-project/venv/bin/python
Expected output (Windows):
C:\Users\yourname\hello-project\venv\Scripts\python.exe
If it shows a system path instead (like /usr/bin/python), the venv is not activated.
Deactivate when done
deactivate
Common venv errors
| Error | Cause | Fix |
|---|---|---|
No such file or directory: venv/bin/activate |
venv not created yet | Run the python -m venv venv command first |
Activate.ps1 cannot be loaded because running scripts is disabled |
Windows PowerShell security policy | Run: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser and try again |
python: command not found after activation |
venv was created with a Python that is no longer on PATH | Delete the venv folder and recreate it: rm -rf venv && python3 -m venv venv |
| Packages installed but not found | venv is not activated | Activate it first β check for (venv) in your prompt |
| Wrong Python version in venv | System Python is old | Specify the version: python3.11 -m venv venv |
1.10 Your First Python Hello World Project
Now you will write and run your first Python program. No extra packages needed β just Python and your venv.
Create the file
In your IDE, create a new file called hello.py in your project folder:
VS Code: Click the New File icon in the Explorer sidebar (or File β New File), name it hello.py.
PyCharm: Right-click the project folder in the Project panel β New β Python File β name it hello.
Write the code
# hello.py
# This is your first Python program.
# The print() function outputs text to the terminal.
print("Hello, world!")
Thatβs it. One line of real Python code.
Run from the terminal
Make sure your venv is active ((venv) in the prompt), then:
python hello.py # Windows
python3 hello.py # Mac / Linux
Expected output:
Hello, world!
If you see
Hello, world!β your setup is working. π
Run from VS Code
- Open
hello.pyin VS Code. - Click the βΆ Run button in the top-right corner of the editor, OR press
F5. - A terminal panel opens at the bottom and shows the output.
Common issue: VS Code runs with the wrong Python. Check the bottom-left status bar β it should show your venv Python path (e.g.,
Python 3.11.x ('venv': venv)). If it shows the global Python, click the interpreter name and select your venv.
Run from PyCharm
- Open
hello.pyin PyCharm. - Right-click in the editor β Run βhelloβ, OR press
Shift+F10. - The output panel at the bottom shows
Hello, world!.
PyCharm note: The Run button only appears once you have a Python file open. If you see a grey triangle (not green), make sure the interpreter at the bottom-right is set to your venv.
Common run errors
| Error | What it means | Fix |
|---|---|---|
ModuleNotFoundError: No module named 'hello' |
You ran python hello instead of python hello.py |
Add .py extension: python hello.py |
SyntaxError: invalid syntax |
Typo in your code | Check the line number in the error β look for missing quotes or brackets |
NameError: name 'Print' is not defined |
Python is case-sensitive β Print β print |
Use lowercase: print("Hello, world!") |
IndentationError |
Unexpected spaces or tabs | Python cares about indentation β remove any accidental spaces before print |
No such file or directory: hello.py |
You are not in the right folder | Run cd hello-project first, then run the file |
1.11 Initialize Your Demo Project and Push to GitHub
Now that your IDE is set up, your venv is active, and you have a working hello.py, itβs time to put your project under version control and push it to GitHub. This is what you will do every time you start a new project or mini exercise.
Why push to GitHub? The team reviews your work from GitHub, not from your local machine. If it is not on GitHub, it does not exist from the teamβs perspective. Make it a habit β push early and push often.
Step 1 β Create a .gitignore file
Before initialising Git, tell it which files to ignore. The venv/ folder is large and machine-specific β never commit it.
Create a file called .gitignore in your project root:
venv/
__pycache__/
*.pyc
*.pyo
.env
.DS_Store
Step 2 β Initialise Git in your project folder
In your terminal (with venv active, inside hello-project/):
git init
This creates a hidden .git/ folder β Git now tracks changes in this folder.
Step 3 β Stage and commit your files
# Stage all files (hello.py and .gitignore)
git add .
# Commit with a descriptive message
git commit -m "Initial commit: hello world project"
Run git status to confirm there is nothing left unstaged.
Step 4 β Create a repository on GitHub
- Go to github.com and log in.
- Click the + icon (top-right) β New repository.
- Fill in:
- Repository name:
hello-project(match your local folder name) - Description:
My first Python hello world project(optional but good practice) - Visibility: Public (so the team can see it) or Private
- Do NOT tick βAdd a READMEβ or any other options β you already have files locally
- Repository name:
- Click Create repository.
GitHub shows you a page with setup instructions β you only need the ββ¦or push an existing repository from the command lineβ section.
Step 5 β Connect your local project to GitHub
Copy and run the commands GitHub shows. They look like this (with your actual username and repo name):
git remote add origin https://github.com/your-username/hello-project.git
git branch -M main
git push -u origin main
When prompted:
- Username: your GitHub username
- Password: paste your Personal Access Token (from section 1.5a β not your GitHub password)
Step 6 β Verify on GitHub
Reload your GitHub repository page β you should see hello.py and .gitignore listed.
π Your first project is live on GitHub!
Future pushes (after the first)
Once the remote is set up, pushing new changes is just:
git add .
git commit -m "Describe your change"
git push
You wonβt need to enter credentials again (they were cached in step 3 of section 1.5a).
1.12 Setup Checklist β
Go through each item below. Do not move to Part 2 until every box is ticked.
- VS Code (or PyCharm) is installed and opens without errors
- VS Code Python extension is installed (or PyCharm is detecting Python automatically)
python --version(orpython3 --version) shows3.11.xor newer in a terminalpip --version # Windowsorpip3 --version # Mac / Linuxshows a version numbergit --versionshows2.x.xor newergit config --global user.nameanduser.emailare set- GitHub account created and verified at github.com
- Personal Access Token (PAT) generated and saved securely
docker --versionshows a version numberdocker compose versionshows a version number- Docker Desktop is running (whale icon visible, or
docker psreturns without error) - A project folder (
hello-project) is open in your IDE - A virtual environment (
venv/) has been created inside the project folder - The venv is activated β
(venv)is visible in your terminal prompt .gitignorecontainsvenv/and__pycache__/hello.pycontainsprint("Hello, world!")- Running
python hello.pyin the terminal printsHello, world! - Running
hello.pyfrom the IDE (Run button or F5) also printsHello, world! git initrun inhello-project/, files committed, pushed to GitHub- GitHub repo is visible at
github.com/<your-username>/hello-project
All boxes ticked? You have a fully working development environment. Everything in the rest of this handbook builds on this foundation.
Stuck on something? Check the error tables in each section above. If youβre still stuck, search the exact error message β you are very unlikely to be the first person to see it.
2. How to Approach Learning
The goal is not to memorise commands. The goal is to understand the system.
Every tool exists to solve a problem. Before using a tool, ask:
- What problem does this solve?
- How does it fit into the system?
- What would break without it?
3. Common Setup Failures
These are the most common problems beginners hit. Check here before asking for help.
| Error | Cause | Fix |
|---|---|---|
command not found: python |
Python not installed or not on PATH | Install Python; on Windows, tick βAdd Python to PATHβ during install |
python opens the Microsoft Store (Windows) |
Windows App Execution Aliases intercepting | Disable in Settings β Apps β Advanced app settings β App execution aliases |
command not found: docker |
Docker Desktop not installed | Install Docker Desktop |
| Docker commands fail | Docker Desktop is not running | Launch the Docker Desktop app from your applications folder |
docker compose not found |
Old Docker version uses docker-compose (hyphen) |
Update Docker Desktop, or use docker-compose (with hyphen) |
Permission denied (Mac/Linux) |
Running Docker without sudo or group membership | Add your user to the docker group: sudo usermod -aG docker $USER then log out and back in |
SSL: CERTIFICATE_VERIFY_FAILED (Mac) |
Python SSL certificates not installed | Run /Applications/Python\ 3.x/Install\ Certificates.command |
| VS Code canβt find Python | Python not on PATH or wrong interpreter | Press Ctrl+Shift+P β βPython: Select Interpreterβ and choose the correct one |
4. Git Mental Model
Git tracks your code across four states:
Working Directory β Staging β Commit β Remote
| State | What it means |
|---|---|
| Working Directory | Files on your machine that you are editing right now |
| Staging | Files you have marked to include in the next commit (git add) |
| Commit | A saved snapshot stored in your local Git history |
| Remote | The commit pushed to GitHub where others can see it |
Git Basics
Before you start, tell Git who you are (do this once):
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Initialise a new repository:
git init
Check what has changed (run this often):
git status
Stage all changed files:
git add .
Create a commit with a description:
git commit -m "Describe what you changed and why"
Push to remote (GitHub):
git push
Branching Workflow
Rules (non-negotiable):
- Never work directly on
main - Create a new branch for every task
- Push your branch to GitHub when done
# Start from the latest main branch
git checkout main
git pull
# Create and switch to a new branch for your task
git checkout -b feature/my-task
# Do your work, then stage and commit
git add .
git commit -m "Add my feature"
# Push the branch to GitHub so others can see it
git push -u origin feature/my-task
Common Git Problems
| Problem | Cause | Fix |
|---|---|---|
| Push rejected | Remote has commits you donβt have locally | git pull first, resolve any conflicts, then git push |
| Merge conflict | Two branches changed the same lines | Manually resolve conflicts, remove the conflict markers, then commit |
| Working on wrong branch | Forgot to create a branch before coding | git stash, create the correct branch, then git stash pop |
fatal: not a git repository |
Youβre not in a git repo folder | Run git init or cd into the correct project folder |
5. Internet Flow and HTTP Basics
How the Internet Works
Client β HTTP Request β Server β HTTP Response β Client
- You type a URL or click a button in a browser
- Your browser (the client) sends an HTTP request to a server
- The server processes the request (runs code, queries the database)
- The server sends back an HTTP response with data
- Your browser renders the response
HTTP Methods
| Method | Purpose | Example |
|---|---|---|
GET |
Retrieve data (no side effects) | Get a list of users |
POST |
Create new data | Create a new user |
PUT |
Replace existing data completely | Update all fields of a user |
PATCH |
Update part of existing data | Update just a userβs name |
DELETE |
Delete data | Delete a user |
HTTP Status Codes
| Code | Meaning | When you see it |
|---|---|---|
200 |
OK | Request succeeded (GET, PUT, PATCH) |
201 |
Created | A new resource was created (POST) |
400 |
Bad Request | Client sent invalid or malformed data |
404 |
Not Found | The resource you asked for does not exist |
422 |
Unprocessable Entity | Data format is valid but fails validation rules |
500 |
Internal Server Error | Something broke on the server side |
6. Terminal Basics
If you are new to the terminal, here are the most important commands:
| Command | What it does | Example |
|---|---|---|
pwd |
Print working directory (where am I?) | pwd |
ls (Mac/Linux) / dir (Windows) |
List files in current folder | ls |
cd <folder> |
Change directory | cd my-project |
cd .. |
Go up one directory | cd .. |
mkdir <name> |
Create a new folder | mkdir backend |
touch <file> (Mac/Linux) |
Create a new empty file | touch main.py |
cat <file> |
Print file contents | cat requirements.txt |
Ctrl+C |
Stop a running program | Use when the server is running and you want to stop it |
Windows users: Use Git Bash (installed with Git) or Windows Terminal with PowerShell. Many Unix commands like
lsandtouchwork in Git Bash.
Part 1 Summary
| Concept | Key Takeaway |
|---|---|
| Dev environment | Install VS Code (or PyCharm), Python 3.11+, Git, Docker Desktop β verify all with version commands |
| IDE setup | Open project folder, use IDE terminal, select Python interpreter from venv |
| Virtual environment | Create once per project (python -m venv venv), activate every terminal session |
| Hello World | python hello.py prints Hello, world! β confirms your entire setup works |
| GitHub account | Sign up at github.com, generate a PAT, use it as your password when pushing |
| Push to GitHub | git init β git add . β git commit β create GitHub repo β git push |
| Learning approach | Understand systems, not just commands |
| Git model | Working Directory β Staging β Commit β Remote |
| Branching | Always branch, never commit directly to main |
| HTTP | Every web interaction is a request/response cycle |
| Terminal | Learn the basic navigation commands β youβll use them every day |
Navigation
| β Handbook Home | Part 2: Backend β |