Skip to content

devat-youtuber/nextjs_image_gallery_data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NextJS Image Gallery using MongoDB(mongoose) + Nextjs Server Actions + Pure CSS + Next-Auth + Cloudinary

I. Main functions.

  • SignIn with OAuth ( Google )
  • Update Profile
  • Middleware to secure certain pages
  • Upload multiple photos
  • Get all public photos
  • Paginate by _id and updatedAt
  • Search (photos + users)
  • Favorite photo
  • Follow user
  • Get all followings and followes by user
  • Get all public, private, favorite photos by user
  • Show modal photo by _id
  • Download image

II. Implementation Guide.

  1. Setup
  • npx create-next-app@latest
  • npm i mongoose next-auth cloudinary react-toastify
  • next.config.js
    • experimental: {
      serverActions: true
      },
      images: {
      domains: ['lh3.googleusercontent.com', 'res.cloudinary.com'],
      }
  • layout.js (font Faustina, metadata, , react-toastify, google icons)
  • globals.css
  • Public Images
  1. Setup Database
  • .env => MONGODB_URI
  • utils => database.js
  • models => userModel + photoModel
  1. Next Auth
  • .env => NEXTAUTH_URL, NEXTAUTH_SECRET, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET
  • openssl rand -base64 32
  • provider => AuthProvider.js
  • Nav component => Login, Logout Button
  • layout.js => AuthProvider, Nav
  • api/auth/[...nextauth]/route.js
    • Google Login
    • signInWithOAuth
    • getUserByEmail
  • utils => getServerUser.js
  • middleware basic (search, upload, profile)
  1. NavBar Component

  2. SearchForm Component

  3. Header Component

  4. Upload Page

  • Upload Form

    • handleInputFiles
    • validFiles
    • handleDrop
    • Optimization with React Memo
  • Upload Card

    • handleChangeTitle
    • validate
    • handleInputTags
    • handleRemoveTag
    • handleChangePublic
    • handleRemoveFile
    • Optimization with React Memo
  • handleUpload

    • count
    • handleUpload
    • uploadPhotos action
    • uploadPhotosToCloudinary
    • dynamicBlurDataURL
    • slugify
  • Loading Component

  1. Home Page
  • Get all public photos ( getPhotos )

    • generatePhotosMatch
    • generatePhotosPipeline
  • Error component

  • Gallery component

  • PhotoCard Component

  • Optimization with React Memo

  1. Download Image

  2. Infinite Scrolling Pagination

  • next_cursor
  • LoadMore
    • generateMatch
    • generatePipeline
  • hooks => useInView()
  1. Favorite Photo
  • handleFavoritePhoto
  • favoritePhoto Actions
  1. Profile Info
  • GetUserById
  • formatNumber
  1. Profile Edit
  • Edit Profile Modal
  • handleInputFiles
  • handleDrop
  • handleUpdateUser
  • updateUser actions
  • uploadToCloudinary
  • destroyFromCloudinary
  1. Profile Follow
  • followUser
  • getUsers
    • generateUsersMatch
    • generateUsersPipeline
  • ListOfUsers Component
  • UserCard Component
  • handleFollow
  • Optimization with React Memo
  1. Profile Menu
  • getPhotosCount (public, private, favorite)
  • generatePhotosMatch
  • generatePhotosCountPipeline
  1. Profile Gallery
  • getPhotos
  • middleware (private, favorite)
  1. Fix Error
  • Caching
  • LoadMore when "click to go back" on browser
  1. Edit + Delete Photo
  • updatePhoto Actions
  • deletePhoto Actions
  1. Search Page
  • Setup Search Mongodb Atlas
  1. Search Menu
  • generateMatch (users, photos)

  • generatePipeline (users, photos)

  • getPhotosCount

  • getUsersCount

  1. Search Gallery + Search Users

  2. Photo Detail Page

  • Photo Component
  • handleDownloadImage
  • handleFavoritePhoto
  • Share Photo ( photo page )
  • getPhotoById
  • generateMetadata
  1. Next, Prev Photo

  2. Deploy Vercel

  • npm i sharp
  • Run build => Test
  • Upload to Github
  • Deploy to Vercel
  • Change domain in dynamicBlurData
  • Setup .env => NEXTAUTH_URL
  • Setup Google Cloud Console
    • ..../api/auth/callback/google

📚 Materials/References:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published