# Richland Class of 1976 — Reunion Website
## Setup & Deployment Guide

---

### Project structure

```
reunion_site/
├── index.html            Main landing page
├── alumni_info.html      Schedule / alumni info page
├── sponsor_page.html     Sponsor page (reads/writes MongoDB)
├── styles.css            Shared stylesheet
├── meijer_logo_1976.png  Original 1976 Meijer logo
├── server.js             Express API + static file server
├── package.json          Node.js dependencies
├── .env.example          Environment variable template
├── .gitignore
└── README.md             This file
```

---

### Prerequisites on your server

1. **Node.js 18+**
   ```bash
   node -v   # should show v18 or higher
   ```

2. **MongoDB 6+ (local install)**
   ```bash
   # Ubuntu / Debian
   sudo apt-get install -y mongodb
   sudo systemctl enable mongod
   sudo systemctl start mongod
   mongod --version   # confirm running
   ```

3. **A process manager (recommended)**
   ```bash
   npm install -g pm2
   ```

---

### First-time setup

```bash
# 1. Upload the project folder to your server, then:
cd reunion_site

# 2. Install Node dependencies
npm install

# 3. Create your .env file from the template
cp .env.example .env
nano .env          # set MONGO_URI and PORT if needed

# 4. Start the server
node server.js
# or with pm2 (keeps it running after logout):
pm2 start server.js --name reunion76
pm2 save
pm2 startup        # follow the printed command to auto-start on reboot
```

The site is now running at `http://your-server-ip:3000`.

---

### Reverse proxy (nginx) — recommended

Serve the site on port 80/443 and proxy to Node:

```nginx
# /etc/nginx/sites-available/reunion76
server {
    listen 80;
    server_name your-domain.com www.your-domain.com;

    # Increase body size limit for base64 image uploads
    client_max_body_size 15M;

    location / {
        proxy_pass         http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection 'upgrade';
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
```

```bash
sudo ln -s /etc/nginx/sites-available/reunion76 /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
```

Add HTTPS free with Certbot:
```bash
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com
```

---

### MongoDB data

MongoDB stores data in its default directory (`/var/lib/mongodb/` on Linux).
The database is named `richland76` and contains two collections:

| Collection   | What it stores                                         |
|-------------|--------------------------------------------------------|
| `sponsors`  | 2026 sponsor slots — name, logo (base64), slotId       |
| `memorys`   | 1976 memory wall tiles — tile index (0–11), image      |

To back up the database:
```bash
mongodump --db richland76 --out ./backup/
```

To restore from backup:
```bash
mongorestore --db richland76 ./backup/richland76/
```

---

### API reference

All endpoints return JSON. Bodies use `Content-Type: application/json`.

| Method | Path                  | Body                        | Description              |
|--------|-----------------------|-----------------------------|--------------------------|
| GET    | /api/sponsors         | —                           | All 2026 sponsor slots   |
| PUT    | /api/sponsors/:id     | `{ name, img }`             | Upsert one slot          |
| DELETE | /api/sponsors/:id     | —                           | Clear one slot           |
| GET    | /api/memory           | —                           | All memory wall tiles    |
| PUT    | /api/memory/:idx      | `{ img }`                   | Upsert one tile (0–11)   |
| DELETE | /api/memory/:idx      | —                           | Clear one tile           |
| GET    | /api/health           | —                           | Server + DB status       |

Slot IDs: `a0`–`a3` (anchor), `b0`–`b9` (small business).
Tile indices: `0`–`11` matching the founding76 array in sponsor_page.html.

---

### If your host doesn't support Node.js (cPanel shared hosting)

You have two options:

**Option A — MongoDB Atlas (free tier) + serverless functions**
Use a platform like Netlify Functions or Vercel Serverless Functions.
Change `API_BASE` in sponsor_page.html to point to those endpoints.

**Option B — Replace MongoDB with a simple JSON file over PHP**
A two-file PHP backend (read.php, write.php) can replace server.js
if your host supports PHP. Ask Claude to generate this if needed.

---

### Environment variables

| Variable   | Default                                    | Description                  |
|------------|--------------------------------------------|------------------------------|
| MONGO_URI  | mongodb://127.0.0.1:27017/richland76      | MongoDB connection string    |
| PORT       | 3000                                       | Express server port          |
| NODE_ENV   | development                                | Set to `production` on live  |
