# Git Repository Setup Guide - Wellsprings Project

## ⚠️ IMPORTANT SECURITY WARNING

**Before committing to Git, you should move sensitive credentials to environment variables!**

Your project currently has hardcoded API keys and database passwords in:
- `school/views.py` (LeadSquared API keys, Sendinblue API key)
- `wellsprings/settings.py` (Database password, Django secret key)

**See `API_KEYS_LOCATION_GUIDE.md` for instructions on securing these.**

---

## 🔍 Current Situation

Your project has:
- **Main Django project** - needs Git setup
- **Landing page** (`landing-page/lets-whisper-first/`) - **already has its own Git repo** connected to:
  - `https://github.com/sourabhz-freelance/lets-whisper-first.git`

You have **2 options** for handling the nested repository:

---

## 📋 Option 1: Keep Landing Page as Separate Repository (Recommended)

**Best if:** You want to maintain the landing page separately or it's managed by a different team.

### Step 1: Exclude Landing Page from Main Repo

The `.gitignore` already excludes the landing page directory. Verify:

```bash
cd /var/www/html/wellsprings
```

The `.gitignore` should have:
```
landing-page/lets-whisper-first/
```

### Step 2: Initialize Main Git Repository

```bash
# Navigate to project root
cd /var/www/html/wellsprings

# Initialize Git
git init

# Configure Git (use your actual details)
git config user.name "Your Name"
git config user.email "your.email@example.com"

# Check what will be added (landing-page should be ignored)
git status
```

### Step 3: Add and Commit Main Project

```bash
# Add all files (landing-page will be ignored)
git add .

# Create initial commit
git commit -m "Initial commit: Wellsprings Academy Django project

- Django backend with school application
- Templates and static files
- API integrations (LeadSquared, Sendinblue)
- Note: Landing page maintained in separate repository"
```

### Step 4: Add Remote and Push

```bash
# Add remote repository (replace with your actual URL)
git remote add origin https://github.com/yourusername/wellsprings-academy-website.git

# Push to remote
git branch -M main
git push -u origin main
```

**Result:** 
- Main Django project → Your new repository
- Landing page → Remains in `https://github.com/sourabhz-freelance/lets-whisper-first.git`

---

## 📋 Option 2: Include Landing Page in Main Repository

**Best if:** You want everything in one repository or the landing page repo is no longer needed separately.

### Step 1: Remove Nested Git Repository

```bash
cd /var/www/html/wellsprings

# Remove the nested .git directory
rm -rf landing-page/lets-whisper-first/.git

# Also remove the remote reference if it exists
# (This just removes the git tracking, not the files)
```

### Step 2: Update .gitignore

Remove or comment out the landing page exclusion:

```bash
# Edit .gitignore and remove or comment:
# landing-page/lets-whisper-first/
```

### Step 3: Initialize Main Git Repository

```bash
# Navigate to project root
cd /var/www/html/wellsprings

# Initialize Git
git init

# Configure Git
git config user.name "Your Name"
git config user.email "your.email@example.com"

# Check what will be added (now includes landing-page)
git status
```

### Step 4: Add and Commit Everything

```bash
# Add all files (including landing-page)
git add .

# Create initial commit
git commit -m "Initial commit: Wellsprings Academy website project

- Django backend with school application
- React/TypeScript landing page
- Templates, static files, and media handling
- API integrations (LeadSquared, Sendinblue)"
```

### Step 5: Add Remote and Push

```bash
# Add remote repository
git remote add origin https://github.com/yourusername/wellsprings-academy-website.git

# Push to remote
git branch -M main
git push -u origin main
```

**Result:** Everything in one repository.

---

## 📋 Option 3: Use Git Submodule (Advanced)

**Best if:** You want to keep them separate but track the landing page version in main repo.

### Step 1: Initialize Main Repository

```bash
cd /var/www/html/wellsprings
git init
git config user.name "Your Name"
git config user.email "your.email@example.com"
```

### Step 2: Remove Current Landing Page Directory

```bash
# Remove the directory (but keep files safe)
mv landing-page/lets-whisper-first landing-page/lets-whisper-first-backup
```

### Step 3: Add as Submodule

```bash
# Add the landing page as a submodule
git submodule add https://github.com/sourabhz-freelance/lets-whisper-first.git landing-page/lets-whisper-first

# If you have local changes, copy them back
# cp -r landing-page/lets-whisper-first-backup/* landing-page/lets-whisper-first/
```

### Step 4: Commit Main Project

```bash
git add .
git commit -m "Initial commit with landing page as submodule"
```

**Note:** Submodules require extra commands (`git submodule update --init`) when cloning.

---

## 🎯 My Recommendation

**Use Option 1** (Keep Separate) because:
- ✅ Landing page already has its own repository
- ✅ Easier to manage separately
- ✅ Different teams can work independently
- ✅ Smaller main repository
- ✅ Landing page can be deployed separately

---

## 📝 Quick Setup Commands (Option 1 - Recommended)

```bash
# 1. Navigate to project root
cd /var/www/html/wellsprings

# 2. Verify .gitignore excludes landing-page
grep "landing-page/lets-whisper-first" .gitignore

# 3. Initialize Git
git init

# 4. Configure Git
git config user.name "Your Name"
git config user.email "your.email@example.com"

# 5. Check status (landing-page should not appear)
git status

# 6. Add all files
git add .

# 7. Create initial commit
git commit -m "Initial commit: Wellsprings Academy Django project"

# 8. Add remote (replace with your URL)
git remote add origin https://github.com/yourusername/wellsprings-academy-website.git

# 9. Push to remote
git branch -M main
git push -u origin main
```

---

## 🔍 Verify What's Included

After `git add .`, check what will be committed:

```bash
# See all files that will be committed
git ls-files

# Count files
git ls-files | wc -l

# Verify landing-page is excluded
git ls-files | grep landing-page
# (Should return nothing if excluded properly)
```

---

## 🛡️ Security Checklist

Before pushing to remote repository:

- [ ] ✅ `.gitignore` is created and excludes sensitive files
- [ ] ✅ `.env` files are in `.gitignore`
- [ ] ✅ `API_KEYS_LOCATION_GUIDE.md` is excluded (contains sensitive info)
- [ ] ✅ Database backups directory is excluded
- [ ] ✅ Media files (user uploads) are excluded
- [ ] ✅ Virtual environment (`env/`) is excluded
- [ ] ✅ Landing page is handled (Option 1, 2, or 3 chosen)
- [ ] ⚠️ **Move hardcoded credentials to environment variables**
- [ ] ⚠️ **Review `settings.py` for any sensitive data**
- [ ] ⚠️ **Review `views.py` for API keys**

---

## 📁 What's Included in Git (Option 1)

### ✅ Tracked (Committed):
- Django application code (`school/`, `wellsprings/`)
- HTML templates (`school/templates/`)
- Static files source (`school/static/`)
- Configuration files (`manage.py`, `requirements/`)
- Documentation files

### ❌ Excluded (Not Committed):
- Landing page (`landing-page/lets-whisper-first/` - separate repo)
- Virtual environment (`env/`)
- Node modules (`node_modules/`)
- Media files (`media/` - user uploads)
- Database backups (`database_backups/`)
- Collected static files (`staticfiles/`)
- Environment files (`.env`, `*.env`)
- Build outputs (`dist/`, `build/`)
- Cache files (`__pycache__/`)
- IDE settings (`.vscode/`, `.idea/`)
- Log files (`*.log`)

---

## 🔄 Handling Landing Page Changes

If you choose **Option 1** (separate repos):

### To work on landing page:
```bash
cd landing-page/lets-whisper-first
git status
git add .
git commit -m "Your changes"
git push origin main
```

### To work on main project:
```bash
cd /var/www/html/wellsprings
git status
git add .
git commit -m "Your changes"
git push origin main
```

---

## 📞 Need Help?

- **Git Documentation:** https://git-scm.com/doc
- **Git Submodules:** https://git-scm.com/book/en/v2/Git-Tools-Submodules
- **GitHub Guides:** https://guides.github.com/

---

## ⚠️ Final Reminder

**Before your first push, ensure sensitive data is secured!**

1. Move API keys to environment variables
2. Move database credentials to environment variables
3. Ensure `.env` is in `.gitignore`
4. Review all files for hardcoded secrets
5. Choose your landing page strategy (Option 1, 2, or 3)

---

**Good luck with your Git setup! 🎉**
