Photography Website A photography portfolio and management site built with Next.js 16. It includes public travel, photo, and blog pages plus an authenticated dashboard for managing photos, cities, posts, and profile settings. 📸 Screenshots Home Page Dashboard 🚀 Features Next.js 16 with React 19 and React Compiler TanStack Query v5 for advanced data fetching and caching tRPC v11 for end-to-end type-safe APIs Photo…
A photography portfolio and management site built with Next.js 16. It includes public travel, photo, and blog pages plus an authenticated dashboard for managing photos, cities, posts, and profile settings.
📸 Screenshots
Home Page
Dashboard
🚀 Features
Next.js 16 with React 19 and React Compiler
TanStack Query v5 for advanced data fetching and caching
tRPC v11 for end-to-end type-safe APIs
Photo Management with direct S3-compatible uploads, EXIF metadata, location editing, favorites, and visibility controls
Travel Galleries with city collections, framed photo galleries, and cover-photo management
Discover with a Mapbox map and public photos in the current viewport
Blog Publishing with a rich-text post editor, cover images, tags, and public/private visibility
Dashboard Analytics with photo activity, travel statistics, and metadata summaries
Modern UI built with Tailwind CSS and shadcn/ui components
Authentication powered by Better Auth
Database using Drizzle ORM with PostgreSQL
File Storage via S3-compatible storage and presigned uploads
🗺️ Application Routes
Public
Route
Description
/
Photography portfolio home page
/about
Photographer profile and equipment
/travel
Travel destinations
/travel/[city]
City gallery
/discover
Map of public, geotagged photos
/blog
Public posts
/blog/[slug]
Blog post
/p/[id]
Photo detail page
/screensaver
Full-screen photo display
Dashboard
Route
Description
/sign-in
Create the first account or sign in
/dashboard
Dashboard overview and analytics
/dashboard/photos
Photo library and bulk management
/dashboard/photos/[id]
Edit a photo
/dashboard/cities
Manage city collections
/dashboard/cities/[city]
Edit a city and manage its photos
/dashboard/posts
Manage blog posts
/dashboard/posts/new
Create a post
/dashboard/posts/[slug]
Edit a post
/dashboard/profile
Profile and security settings
📋 Prerequisites
Before deploying, ensure you have:
Node.js 20.9+ or Bun
PostgreSQL database (Neon is supported through its serverless driver; other PostgreSQL services can use the local/node-postgres driver)
A deployment target such as Vercel or Docker (optional)
💻 Local Development
bun install
cp .env.example .env
# Fill in DATABASE_URL, Better Auth, S3, and Mapbox values.
bun run db:push
bun run dev
Open http://localhost:3000/sign-in and create the first account. Registration is available in any environment only while the user table is empty, then it is automatically disabled.
🧰 Common Commands
Command
Purpose
bun run dev
Start the development server
bun run build
Create a production build
bun run start
Serve a completed production build
bun run lint
Run ESLint
bun run test:unit
Run unit tests
bun run db:push
Push the Drizzle schema to the configured database
bun run db:studio
Open Drizzle Studio
bun run seed:demo-post
Create or update the demo blog post
🎨 Customization
All personal branding is centralized in one file: src/site.config.ts. Edit it to make the site your own:
Field
Description
name
Your name (logo, profile cards, footer)
tagline
Short tagline next to logo (e.g. “Photo”)
role
Your title (e.g. “Photographer”)
bio
Short bio on the home page
avatar
Avatar image path (place file in /public/avatar.jpg)
initials
Fallback text when avatar fails to load
metadata
SEO title & description
socialLinks
Social links with icons (Instagram, GitHub, X, Xiaohongshu, Contact me)
footer
Footer attribution credits
mapbox
Custom Mapbox style URLs for light/dark themes
imageLoader
Set to "cloudflare" or "default" based on your storage provider
gear
Camera gear shown on the About page
Quick start:
# 1. Edit the config
vim src/site.config.ts
# 2. Replace avatar
cp your-photo.jpg public/avatar.jpg
# 3. Replace about background
cp your-bg.jpg public/bg.jpg
Note: If you are NOT using Cloudflare R2, set imageLoader to "default" in site.config.ts. This replaces the old manual edit of next.config.ts.
🛠️ Deployment Guide
Step 1: Clone and Setup
# Clone the repository
git clone https://github.com/ECarry/photography-website.git
cd photography-website
# Install dependencies
bun install
# or
npm install
Step 2: Environment Configuration
Create a .env file in the root directory:
cp .env.example .env
Configure the following environment variables:
Database Configuration
# PostgreSQL connection string
DATABASE_URL=postgresql://username:password@host:port/database_name?sslmode=require
# Optional: "local" uses node-postgres; omit or use "neon" for Neon serverless
DATABASE_PROVIDER=local
For Neon, use DATABASE_PROVIDER=neon or leave DATABASE_PROVIDER unset. Other PostgreSQL services such as Supabase can use the local (node-postgres) driver.
# Generate a random secret key (32+ characters)
BETTER_AUTH_SECRET=your-super-secret-key-here
# Your app's base URL
BETTER_AUTH_URL=https://your-domain.com
NEXT_PUBLIC_APP_URL=https://your-domain.com
S3-Compatible Storage Configuration
# S3-compatible storage settings
S3_ENDPOINT=https://your-s3-endpoint.com
S3_BUCKET_NAME=your-bucket-name
S3_ACCESS_KEY_ID=your-access-key
S3_SECRET_ACCESS_KEY=your-secret-key
# Public asset base URL used by the website
NEXT_PUBLIC_S3_PUBLIC_URL=https://your-custom-domain.com
The public URL must point to a domain that can serve objects from the bucket. The browser uploads directly to storage using short-lived presigned URLs.
⚠️ Image loader note (when not using Cloudflare R2)
If you are not using Cloudflare R2, set imageLoader to "default" in src/site.config.ts. This is handled automatically — no need to manually edit next.config.ts.
Setup Instructions:
Choose your preferred S3-compatible storage provider
Create an account and set up a bucket
Generate API credentials (Access Key ID and Secret Access Key)
Set both variables to enable Upstash-backed rate limiting for public API requests. Leave both unset to disable it.
UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=
Step 3: Database Setup
# Push database schema
bun run db:push
Step 4: Run the Development Server
bun run dev
Open http://localhost:3000/sign-in and create the first account. The registration form is shown only when the configured database has no users; after the first account is created, only sign-in remains available.
Step 5: Build and Test Locally
# Build the application
bun run build
# Test the production build locally
bun run start
Visit http://localhost:3000 to verify everything works correctly.
Step 6: Deploy to Vercel
Option A: Deploy via Vercel CLI
# Install Vercel CLI
npm i -g vercel
# Login to Vercel
vercel login
# Deploy
vercel --prod
Option B: Deploy via Git Integration
Push your code to GitHub/GitLab/Bitbucket
Connect your repository to Vercel
Configure environment variables in Vercel dashboard
Deploy automatically on push
Vercel Environment Variables Setup
In your Vercel dashboard, add all environment variables from your .env file:
Go to Project Settings > Environment Variables
Add each variable with appropriate values for production
Make sure to update URLs to use your production domain
Step 7: Post-Deployment Setup
Database Migration (if needed)
# If you need to run migrations on production
vercel env pull .env.local
bun run db:push
After deploying the app and configuring its database, open https://your-domain/sign-in and create the initial account. Registration is available in production only while the user table is empty and locks automatically as soon as the first account is created. Complete this setup promptly: until then, anyone who can reach the sign-in page can attempt to claim the initial account.
Upgrade: Photo URL storage change (S3 Key)
Change Summary
The database url field now stores the S3 object key (e.g., photos/IMG_0001.jpg) instead of a full public URL.
Benefit: You can switch domains or CDNs freely by updating environment variables for the public base URL, without mass-updating the database.
Migration Steps (run before production, recommended)
Backup your database (strongly recommended).
Run the cleanup script to convert existing full URLs to S3 keys:
bun run clean:photo-urls
Verify the result: spot-check several records; url should look like a key such as path/to/object.jpg.
If you need to rollback, run:
bun run rollback:photo-urls
Notes
Set NEXT_PUBLIC_S3_PUBLIC_URL to the public asset base URL. At runtime, the app combines this base URL with the stored object key.
If you have custom prefixes or multiple buckets, validate the script behavior in a staging environment first.
🐳 Docker Deployment
This project supports two Docker deployment modes: Standalone (self-hosted) and Cloud (managed services).
1. Standalone Mode (Default)
Run the entire stack (App, PostgreSQL, RustFS) locally. Ideal for testing and self-hosting.
docker compose up -d
# or explicitly:
docker compose -f docker-compose.standalone.yml up -d
The Cloud Compose file sets DATABASE_PROVIDER=neon and passes the public app, storage, and Mapbox values as build arguments. Set a real Mapbox token if you use map pages.
⚠️ Important Note on Building
The Dockerfile uses a multi-stage build with two deployment targets:
Target
Used by
Strategy
dev
docker-compose.yml (Standalone)
Runtime build — app is built inside the container at startup so SSG can access the local database
runner
docker-compose.cloud.yml (Cloud)
Pre-built — app is built during docker build using Next.js standalone output for a smaller, faster image
Standalone mode:
First Start: Will take 1-2 minutes to compile.
Restarts: Will be fast (cached via next_cache volume).
Cloud mode:
Image is pre-built and optimized (~200MB vs ~1GB).
Starts instantly — no build step at runtime.
Environment variables for SSG are passed as build args.
评论