Stop shipping punimtag_password / admin defaults in install helpers and docs; generate secrets at install time; require ADMIN_PASSWORD from env (with test-only bootstrap in conftest).
7.9 KiB
PunimTag Photo Viewer - Setup Instructions
✅ What's Been Completed
- ✅ Next.js 14 project created with TypeScript and Tailwind CSS
- ✅ Core dependencies installed:
- Prisma ORM
- TanStack Query
- React Photo Album
- Yet Another React Lightbox
- Lucide React (icons)
- Framer Motion (animations)
- Date-fns (date handling)
- shadcn/ui components (button, input, select, calendar, popover, badge, checkbox, tooltip)
- ✅ Prisma schema created matching PunimTag database structure
- ✅ Database connection utility created (
lib/db.ts) - ✅ Initial home page with photo grid component
- ✅ Next.js image optimization configured
- ✅ shadcn/ui initialized
- ✅ Collapsible search bar on main page
- ✅ Search functionality - Search by people, dates, and tags
- ✅ Search API endpoint (
/api/search) - ✅ Search page at
/search - ✅ Photo tooltips showing people names on hover
- ✅ Filter components - People, Date Range, and Tag filters
🔧 Next Steps to Complete Setup
1. Configure Database Connection
Create a .env file in the project root:
DATABASE_URL="postgresql://viewer_readonly:your_password@localhost:5432/punimtag"
NEXT_PUBLIC_SITE_NAME="PunimTag Photo Viewer"
NEXT_PUBLIC_SITE_DESCRIPTION="Family Photo Gallery"
Important: Replace your_password with the actual password for the read-only database user.
2. Create Read-Only Database User (if not already done)
Connect to your PostgreSQL database and run:
-- Create read-only user
CREATE USER viewer_readonly WITH PASSWORD 'your_secure_password';
-- Grant permissions
GRANT CONNECT ON DATABASE punimtag TO viewer_readonly;
GRANT USAGE ON SCHEMA public TO viewer_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO viewer_readonly;
-- Grant on future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT ON TABLES TO viewer_readonly;
-- Verify no write permissions
REVOKE INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public FROM viewer_readonly;
3. Install System Dependencies (Optional but Recommended)
For Image Watermarking (libvips):
# Ubuntu/Debian
sudo apt update
sudo apt install libvips-dev
# Rebuild sharp package after installing libvips
cd viewer-frontend
npm rebuild sharp
For Video Thumbnails (FFmpeg):
# Ubuntu/Debian
sudo apt install ffmpeg
Note: The application will work without these, but:
- Without libvips: Images will be served without watermarks
- Without FFmpeg: Videos will show placeholder thumbnails
4. Generate Prisma Client
cd /path/to/punimtag/viewer-frontend
npx prisma generate
5. Test Database Connection
# Optional: Open Prisma Studio to browse database
npx prisma studio
6. Run Development Server
npm run dev
Open http://localhost:3000 in your browser.
⚠️ Known Issues
Node.js Version Warning
The project was created with Next.js 16, which requires Node.js >=20.9.0, but the system currently has Node.js 18.19.1.
Solutions:
-
Upgrade Node.js (Recommended):
# Using nvm (Node Version Manager) nvm install 20 nvm use 20 -
Or use Next.js 14 (if you prefer to stay on Node 18):
npm install next@14 react@18 react-dom@18
📁 Project Structure
punimtag-viewer/
├── app/
│ ├── layout.tsx # Root layout with Inter font
│ ├── page.tsx # Home page (server component)
│ ├── HomePageContent.tsx # Home page client component with search
│ ├── search/ # Search page
│ │ ├── page.tsx # Search page (server component)
│ │ └── SearchContent.tsx # Search content (client component)
│ ├── api/ # API routes
│ │ ├── search/ # Search API endpoint
│ │ │ └── route.ts # Search route handler
│ │ └── photos/ # Photo API endpoints
│ └── globals.css # Global styles (updated by shadcn)
├── components/
│ ├── PhotoGrid.tsx # Photo grid with tooltips
│ ├── search/ # Search components
│ │ ├── CollapsibleSearch.tsx # Collapsible search bar
│ │ ├── FilterPanel.tsx # Filter panel container
│ │ ├── PeopleFilter.tsx # People filter component
│ │ ├── DateRangeFilter.tsx # Date range filter
│ │ ├── TagFilter.tsx # Tag filter component
│ │ └── SearchBar.tsx # Search bar (for future text search)
│ └── ui/ # shadcn/ui components
│ ├── button.tsx
│ ├── input.tsx
│ ├── select.tsx
│ ├── calendar.tsx
│ ├── popover.tsx
│ ├── badge.tsx
│ ├── checkbox.tsx
│ └── tooltip.tsx
├── lib/
│ ├── db.ts # Prisma client
│ ├── queries.ts # Database query helpers
│ └── utils.ts # Utility functions (from shadcn)
├── prisma/
│ └── schema.prisma # Database schema
└── .env # Environment variables (create this)
🎨 Adding shadcn/ui Components
To add UI components as needed:
npx shadcn@latest add button
npx shadcn@latest add card
npx shadcn@latest add input
npx shadcn@latest add dialog
# ... etc
🚀 Next Development Steps
After setup is complete, follow the Quick Start Guide to add:
- Photo Detail Page - Individual photo view with lightbox
- People Browser - Browse photos by person
- Tags Browser - Browse photos by tag
- Infinite Scroll - Load more photos as user scrolls
- Favorites System - Allow users to favorite photos
✨ Current Features
Search & Filtering
-
✅ Collapsible Search Bar on main page
- Minimized by default, click to expand
- Shows active filter count badge
- Real-time photo filtering
-
✅ Search Filters
- People filter with searchable dropdown
- Date range filter with presets and custom range
- Tag filter with searchable dropdown
- All filters work together (AND logic)
-
✅ Search Page (
/search)- Full search interface
- URL query parameter sync
- Pagination support
Photo Display
-
✅ Photo Tooltips
- Hover over photos to see people names
- Shows "People: Name1, Name2" format
- Falls back to filename if no people identified
-
✅ Photo Grid
- Responsive grid layout
- Optimized image loading
- Hover effects
📚 Documentation
- Quick Start Guide:
/path/to/punimtag/docs/PHOTO_VIEWER_QUICKSTART.md - Complete Plan:
/path/to/punimtag/docs/PHOTO_VIEWER_PLAN.md - Architecture:
/path/to/punimtag/docs/PHOTO_VIEWER_ARCHITECTURE.md
🆘 Troubleshooting
"Can't connect to database"
- Check
.envfile has correctDATABASE_URL - Verify database is running
- Test connection:
psql -U viewer_readonly -d punimtag -h localhost
"Prisma Client not generated"
- Run:
npx prisma generate
"Module not found: @/..."
- Check
tsconfig.jsonhas"@/*": ["./*"]in paths
"Images not loading"
For File System Paths:
- Verify photo file paths in database are accessible from the Next.js server
- Check that the API route (
/api/photos/[id]/image) is working - Check server logs for file not found errors
For HTTP/HTTPS URLs (SharePoint, CDN):
- Verify the URL format in database (should start with
http://orhttps://) - Check
next.config.tshas the domain configured inremotePatterns - For SharePoint Online:
**.sharepoint.comis already configured - For on-premises SharePoint: Uncomment and update the hostname in
next.config.ts - Verify the URLs are publicly accessible or authentication is configured
Project Location: /path/to/punimtag/viewer-frontend
Ready to continue development! 🚀