How njxue/photoasis works
1. Overall shape
- This is a Next.js App Router application for a photo gallery product called Photoasis.
- The app is split into public and protected route groups, with separate layouts and route-level access control.
- It mixes server-rendered pages, client components, server actions, and a small number of API routes.
2. Core product domain
- The domain centers on users, albums, photos, and user preferences.
- Photos are not just images; they carry and display EXIF metadata such as ISO, aperture, exposure, and metering mode.
- The main user workflows are: register/login, upload photos, organize them into albums, inspect photo metadata, and manage account settings.
3. Route and UI boundaries
- Public routes handle onboarding and authentication: login, register, forgot/reset password, and email verification.
- Protected routes contain the product shell: dashboard, gallery, album detail pages, album creation, and settings.
- The protected area has its own layout and shared navigation, while the public area uses a simpler layout and forms.
4. Stateful feature contexts
- The app uses several React contexts to isolate feature state:
- UserPreferencesContext for app-level preferences.
- AlbumContext for the selected album and album-level operations.
- ImageUploadContext for upload state and photo metadata entry.
- ModalContext and SelectContext for shared interactive UI state.
- These contexts help keep complex album and upload flows organized without passing props deeply.
5. Album and photo management
- Album detail pages are highly interactive and are built from multiple subcomponents: headers, body, selection controls, settings panels, and forms.
- Album actions include create, update, delete, plus photo-level actions such as update photo metadata, delete photos, and change album thumbnails.
- The UI supports selection workflows for bulk actions, indicating that album/photo manipulation is a first-class interaction pattern.
6. Upload and EXIF entry flow
- The upload experience is a distinct subsystem under ImageUpload.
- It appears to combine:
- file dropping / file selection,
- image previews,
- camera settings input fields,
- and upload-specific controls.
- The presence of EXIF-specific inputs like exposure mode and metering mode shows that uploads likely enrich stored photos with structured metadata, not just binary image files.
7. Storage and backend mutation layer
- The actions/ directory contains the main server-side mutation and integration functions.
- These include auth/account flows (signUp, resetPassword, sendEmailVerification, sendPasswordResetEmail) and domain mutations (createAlbum, updateAlbum, deleteAlbum, updatePhoto, updateUser, updateUserPreferences, etc.).
- actions/b2.js strongly suggests integration with Backblaze B2 for file storage, which is likely the external object store for uploaded images.
8. Data and persistence
- The repository uses Prisma with migrations and a schema file, so the persistent data model is database-backed and centrally defined.
- The schema likely covers users, albums, photos, and preference records, plus any auth-related fields needed for login and verification.
- This database is the source of truth for app state; the object storage layer is used for the actual photo binaries.
9. Authentication and account lifecycle
- Authentication is handled through app/api/auth/[...nextauth]/route.js, which indicates NextAuth-style auth integration.
- The public auth flows include registration, login, email verification, and password reset, so account lifecycle is a major subsystem.
- middleware.js likely enforces the public/protected split and redirects unauthenticated users away from protected pages.
10. Export and media delivery
- app/api/download-zip/route.js provides a server endpoint for bulk photo download as a zip archive.
- This is an important boundary because it packages stored media for client download rather than rendering it in the UI.
- The image rendering layer includes optimized/common image components, implying the app uses a performance-conscious approach to gallery display.
11. Shared app shell and cross-cutting concerns
- app/layout.jsx, app/Provider.jsx, app/PosthogProvider.jsx, and app/ToastContainerWrapper.jsx establish global app-wide concerns.
- These likely wire up theming/state providers, analytics, and toast notifications for both public and protected routes.
- The app also includes reusable UI primitives such as inputs, buttons, modals, tooltips, loading states, and drag-and-drop helpers.
12. External integrations and operational tooling
- The repo includes email templates for verification and password reset, so transactional email is part of the architecture.
- public/worker.js and utils/compress.js suggest client-side or edge-assisted image processing/compression support.
- There is GitHub Actions linting, indicating basic CI quality checks, and the app is structured for deployment on a Next.js-friendly platform such as Vercel.
13. How the main data flow works
- A user authenticates through the public auth flow.
- Once protected, they navigate to dashboard/gallery/album views that read from the database via server-rendered pages and client contexts.
- Uploading photos sends files and EXIF metadata through the upload UI, then into storage and Prisma-backed records.
- Album and photo edits are performed through server actions, with the UI updating through shared contexts and form components.
14. What to emphasize in an architecture diagram
- Show three major boundaries: public auth/onboarding, protected gallery management, and backend services.
- Place Next.js UI/components on the front end, server actions + API routes in the middle, and Prisma DB + B2/email storage services on the back end.
- Highlight the photo pipeline separately from the account pipeline, because media upload/storage and authentication/verification are both major but distinct subsystems.
Main entry points: layout.jsx Protected shell · actions Actions · page.jsx Album detail · ImageUpload Photo upload
Components 23
Public routes
Onboarding, login, and password/email recovery.
- Public shell · Shared layout for onboarding and auth pages.
app/(public)/layout.jsx - Auth pages · Login, register, forgot/reset password, and email verification screens.
app/(public)
Protected app
Authenticated gallery, album, upload, and settings experience.
- Protected shell · Authenticated application layout and navigation frame.
app/(protected)/layout.jsx - Dashboard · Primary authenticated landing page and summary surface.
app/(protected)/dashboard/page.jsx - Gallery · Main gallery view for browsing and inspecting photos.
app/(protected)/gallery/page.jsx - Album detail · Interactive album page with selection, settings, and bulk photo actions.
app/(protected)/album/[id]/page.jsx - New album · Form flow for creating a new album.
app/(protected)/album/new/page.jsx - Settings · User preference and image fit settings surface.
app/(protected)/settings/page.jsx - Photo upload · Drop/select files, preview them, and capture EXIF/photo settings during upload.
app/(protected)/components/ImageUpload - Album state · Selected album state and album-level operations.
app/(protected)/album/[id]/AlbumContext.jsx - Preferences state · App-level user preferences shared in the protected area.
app/(protected)/UserPreferencesContext.jsx - Modal & select · Reusable contexts for modal dialogs and selection workflows.
app/(protected)/components/Modal/ModalContext.jsx
Server/backend
Server actions, API routes, auth, persistence, and external services.
- Middleware · Enforces public vs protected access boundaries.
middleware.js - Auth API · Authentication endpoint for session and provider flow.
app/api/auth/[...nextauth]/route.js - Zip download · Server endpoint for bulk photo export as a zip.
app/api/download-zip/route.js - Actions · Main mutation and integration layer for auth, albums, photos, and preferences.
actions - B2 storage · Backblaze B2 integration for uploaded image binaries.
actions/b2.js - Database · Database schema, migrations, and Prisma access layer.
prisma/schema.prisma
Shared platform
Global providers and reusable UI primitives used across route groups.
- App layout · Global app entry that wraps both public and protected areas.
app/layout.jsx - Providers · App-wide state, analytics, and toast wiring.
app/Provider.jsx - Analytics · PostHog integration for product analytics.
app/PosthogProvider.jsx - Toasts · Global toast container used by the app.
app/ToastContainerWrapper.jsx - UI primitives · Common inputs, loaders, buttons, images, tooltips, and helpers used across the app.
app/common
Connections 30
- App layout → Providers: wraps · Root layout mounts global providers.
- App layout → Public shell: contains · Root layout includes the public route group.
- App layout → Protected shell: contains · Root layout includes the protected route group.
- Providers → Analytics: includes · Providers wires analytics.
- Providers → Toasts: includes · Providers wires toast notifications.
- Middleware → Public shell: permits · Middleware keeps public routes accessible.
- Middleware → Protected shell: guards · Middleware protects authenticated pages.
- Public shell → Auth pages: hosts · Public layout renders onboarding and auth pages.
- Auth pages → Auth API: authenticates · Login/register pages rely on auth route integration.
- Auth pages → Actions: submits · Auth flows call server-side account mutations.
- Protected shell → Dashboard: navigates to · Protected shell frames the main dashboard.
- Protected shell → Gallery: navigates to · Protected shell frames the gallery browser.
- Protected shell → Album detail: navigates to · Protected shell frames album workspaces.
- Protected shell → New album: navigates to · Protected shell frames album creation.
- Protected shell → Settings: navigates to · Protected shell frames account settings.
- Protected shell → Preferences state: provides · Protected area shares user preference state.
- Album detail → Album state: uses · Album pages rely on selected album context.
- Album detail → Modal & select: uses · Album interactions use modal and selection state.
- Album detail → Actions: mutates · Album pages create, update, delete albums and photos.
- Album detail → Zip download: exports · Album/gallery UI can request zip downloads.
- New album → Actions: creates · New album flow submits create-album mutations.
- Settings → Actions: updates · Settings pages update user and preference records.
- Photo upload → B2 storage: stores · Upload flow sends binaries to object storage.
- Photo upload → Actions: persists · Upload flow records photo and metadata via actions.
- Photo upload → UI primitives: uses · Upload UI builds on shared inputs and helpers.
- Gallery → UI primitives: uses · Gallery relies on reusable image and card components.
- Album detail → UI primitives: uses · Album workspace relies on shared UI primitives.
- Actions → Database: reads/writes · Actions are the main database mutation layer.
- Actions → B2 storage: integrates · Actions coordinate file storage and deletion.
- Actions → Auth API: supports · Actions support authentication and account lifecycle flows.