DudleyFamilySite

The Dudley Family Site

A full-stack family website built with React, Cloudflare Workers, and Cloudflare Pages. Features include digital photo sharing, family calendar, and message board.

Features

Tech Stack

Frontend

Backend

Project Structure

dudley-family-site/
├── frontend/                 # React frontend
│   ├── src/
│   │   ├── components/      # Reusable components
│   │   ├── pages/          # Page components
│   │   ├── contexts/       # React contexts
│   │   └── ...
│   ├── package.json
│   └── vite.config.js
├── worker/                  # Cloudflare Worker backend
│   ├── src/
│   │   └── index.js        # Main worker file
│   ├── schema.sql          # Database schema
│   ├── package.json
│   └── wrangler.toml
├── package.json            # Root package.json
└── README.md

Setup Instructions

Prerequisites

  1. Node.js 18+ installed
  2. Cloudflare account
  3. Wrangler CLI installed: npm install -g wrangler

1. Install Dependencies

# Install root dependencies
npm install

# Install frontend dependencies
cd frontend && npm install

# Install worker dependencies
cd ../worker && npm install

2. Cloudflare Setup

Create D1 Database

# Login to Cloudflare
wrangler login

# Create D1 database
wrangler d1 create dudley-family-db

# Note the database ID from the output and update wrangler.toml

Create R2 Bucket

# Create R2 bucket for photos
wrangler r2 bucket create dudley-family-photos

Update Configuration

  1. Update worker/wrangler.toml with your database ID
  2. Set your JWT secret and family password in environment variables
  3. Update R2 domain in the worker code if using custom domain

3. Database Setup

# Apply database schema
wrangler d1 execute dudley-family-db --file=./worker/schema.sql

4. Development

# Start both frontend and worker in development
npm run dev

# Or start individually:
npm run dev:frontend  # Frontend on http://localhost:3000
npm run dev:worker    # Worker on http://localhost:8787

5. Deployment

Deploy Worker

cd worker
wrangler deploy

Deploy Frontend to Cloudflare Pages

  1. Connect your GitHub repository to Cloudflare Pages
  2. Set build command: cd frontend && npm run build
  3. Set build output directory: frontend/dist
  4. Set environment variables:
    • VITE_API_URL: Your worker URL (e.g., https://dudley-family-api.your-subdomain.workers.dev)

Environment Variables

Worker Environment Variables

Frontend Environment Variables

API Endpoints

Authentication

Photos

Events

Messages

Security Features

Customization

Styling

Features

Troubleshooting

Common Issues

  1. CORS errors: Ensure CORS_ORIGIN is set correctly in wrangler.toml
  2. Database errors: Verify D1 database is created and schema applied
  3. R2 upload errors: Check R2 bucket permissions and configuration
  4. Authentication errors: Verify JWT_SECRET is set correctly

Development Tips

Contributing

This is a private family project. For questions or issues, contact the family administrator.

License

Private family use only.