Skip to content

About

Full-stack AI prompt-sharing platform built with Next.js, MongoDB, and NextAuth for discovering, creating, searching, and managing AI prompts.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

14 Commits

Folders and files

Repository files navigation

πŸš€ Promptopia β€” Discover & Share AI-Powered Prompts

Promptopia Logo

An open-source, full-stack AI prompt-sharing platform built with Next.js 13 (App Router), React, Tailwind CSS, MongoDB, and NextAuth.

Stars Badge Forks Badge License

Next.js React Tailwind CSS MongoDB Mongoose NextAuth.js


πŸ“– Table of Contents


🌟 Overview

Promptopia is a collaborative platform designed for modern AI enthusiasts, prompt engineers, and developers to explore, publish, and exchange creative prompts for generative AI models (ChatGPT, Midjourney, Claude, Gemini, etc.).

Powered by Next.js 13 App Router and serverless API route handlers, Promptopia delivers server-side rendering, seamless client-side interactivity, authenticated user profiles, real-time prompt search, and effortless copy-to-clipboard functionality.


✨ Key Features

  • πŸ” Seamless OAuth Authentication: Integrated with Google OAuth via NextAuth.js for fast, secure, one-click sign-in and session persistence.
  • ⚑ Smart Username Sanitization: Automatic normalization, special-character cleaning, regex validation, and collision-handling for unique user accounts.
  • πŸ“ Full CRUD Operations: Authenticated users can create, read, edit, and delete their own AI prompts with customized tags.
  • πŸ‘€ Personalized Profile Pages: Dedicated profile dashboards displaying each user's submitted prompts with quick edit/delete actions.
  • 🏷️ Categorization & Tags: Organize prompts with intuitive hashtags (#webdevelopment, #idea, #coding, #design) for fast discovery.
  • πŸ“‹ One-Click Copy-to-Clipboard: Copy any prompt instantly with an animated status indicator providing immediate visual confirmation.
  • πŸ“± Fully Responsive Design: Built with Tailwind CSS, offering a mobile-first, fluid layout with custom gradients and modern aesthetics.
  • πŸƒ High-Performance MongoDB Integration: Persistent caching patterns and DNS optimizations (node:dns) ensuring reliable database connectivity across serverless environments.

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 13 (App Router, Server Components & Client Components)
  • UI Library: React 18
  • Styling: Tailwind CSS 3 with custom typography and CSS utility classes
  • Icons & Assets: Custom SVG icons and modular illustrations

Backend & APIs

  • Route Handlers: Next.js App Router API Routes (/app/api/...)
  • Authentication: NextAuth.js v4 (Google Provider)
  • Database: MongoDB (Atlas or self-hosted)
  • ODM: Mongoose

πŸ“‚ Project Architecture & Structure

Promptopia/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”‚   └── [...nextauth]/route.js   # NextAuth Google OAuth handler & user persistence
β”‚   β”‚   β”œβ”€β”€ prompt/
β”‚   β”‚   β”‚   β”œβ”€β”€ route.js                 # GET all prompts
β”‚   β”‚   β”‚   β”œβ”€β”€ new/route.js             # POST create a new prompt
β”‚   β”‚   β”‚   └── [id]/route.js            # GET, PATCH, DELETE prompt by ID
β”‚   β”‚   └── users/
β”‚   β”‚       └── [id]/posts/route.js      # GET prompts created by a specific user
β”‚   β”œβ”€β”€ create-prompt/
β”‚   β”‚   └── page.jsx                     # Create prompt page
β”‚   β”œβ”€β”€ profile/
β”‚   β”‚   └── page.jsx                     # User profile dashboard
β”‚   β”œβ”€β”€ update-prompt/
β”‚   β”‚   └── page.jsx                     # Edit prompt page
β”‚   β”œβ”€β”€ layout.jsx                       # Root layout (Provider, Nav, global styling)
β”‚   └── page.jsx                         # Home page (Hero section & feed)
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ Feed.jsx                         # Main feed component with search & card list
β”‚   β”œβ”€β”€ Form.jsx                         # Reusable prompt creation & edit form
β”‚   β”œβ”€β”€ Nav.jsx                          # Responsive desktop & mobile navigation bar
β”‚   β”œβ”€β”€ Profile.jsx                      # User profile presentation layout
β”‚   β”œβ”€β”€ PromptCard.jsx                   # Individual prompt card (copy, edit, delete, tags)
β”‚   └── Provider.jsx                     # NextAuth session context provider
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ prompt.js                        # Mongoose schema for prompts
β”‚   └── user.js                          # Mongoose schema for users with regex validation
β”œβ”€β”€ public/
β”‚   └── assets/                          # Static logos, icons, and background patterns
β”œβ”€β”€ styles/
β”‚   └── globals.css                      # Tailwind imports & custom utility classes
β”œβ”€β”€ utils/
β”‚   └── database.js                      # MongoDB connection pool & DNS fallback helper
β”œβ”€β”€ next.config.js                       # Next.js configuration (images domain, topLevelAwait)
β”œβ”€β”€ package.json                         # Project dependencies and npm scripts
└── tailwind.config.js                   # Tailwind CSS theme configuration

πŸš€ Getting Started

Follow these instructions to get a local copy up and running.

Prerequisites

Ensure you have the following installed on your machine:

  • Node.js: v18.0.0 or higher (Download Node.js)
  • npm, yarn, or pnpm
  • MongoDB: A free cluster on MongoDB Atlas or a local MongoDB instance
  • Google Cloud Console Account: For configuring Google OAuth 2.0 Client credentials

Installation

  1. Clone the repository:

    git clone https://github.com/Alaqmar-Yousuf/Promptopia.git
    cd Promptopia
  2. Install project dependencies:

    npm install
    # or
    yarn install
    # or
    pnpm install

Environment Variables

  1. Create a .env file in the root directory:

    touch .env
  2. Add your credentials to .env:

    Variable Description Example / Default
    GOOGLE_ID Google OAuth Client ID your_client_id.apps.googleusercontent.com
    GOOGLE_CLIENT_SECRET Google OAuth Client Secret GOCSPX-your_client_secret
    MONGODB_URI MongoDB Connection String mongodb+srv://<user>:<password>@cluster.mongodb.net/?retryWrites=true&w=majority
    NEXTAUTH_URL Base URL of your application http://localhost:3000
    NEXTAUTH_URL_INTERNAL Internal NextAuth server URL http://localhost:3000
    NEXTAUTH_SECRET Random 32+ char secret for JWT encryption Generate via openssl rand -base64 32

Tip

Setting up Google OAuth Credentials:

  1. Visit the Google Cloud Console.
  2. Create a new project and configure the OAuth consent screen.
  3. Create Credentials β†’ OAuth client ID β†’ Web application.
  4. Under Authorized JavaScript origins, add: http://localhost:3000.
  5. Under Authorized redirect URIs, add: http://localhost:3000/api/auth/callback/google.
  6. Copy your Client ID and Client Secret into your .env.

Running the App

Start the development server:

npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 in your browser to view the application.


πŸ”Œ API Endpoints Reference

Method Endpoint Description Auth Required
GET /api/prompt Fetch all public prompts (populates creator details) No
POST /api/prompt/new Create a new prompt (prompt, tag, userId) Yes
GET /api/prompt/:id Fetch a single prompt by its ID No
PATCH /api/prompt/:id Update an existing prompt's text and tag Yes (Author)
DELETE /api/prompt/:id Delete a prompt by its ID Yes (Author)
GET /api/users/:id/posts Fetch all prompts created by a specific user No
GET / POST /api/auth/[...nextauth] NextAuth authentication handlers & session handling No

πŸ—„οΈ Database Schema

User

{
  email: String (required, unique),
  username: String (required, unique, regex validated 3-30 chars),
  image: String
}

Prompt

{
  creator: ObjectId (ref: "User", required),
  prompt: String (required),
  tag: String (required)
}

🚒 Deployment

The simplest way to deploy Promptopia is using the Vercel Platform:

  1. Push your latest code to GitHub.
  2. Import your repository into Vercel.
  3. Add your environment variables (GOOGLE_ID, GOOGLE_CLIENT_SECRET, MONGODB_URI, NEXTAUTH_URL, NEXTAUTH_SECRET) in the Vercel project settings.
    • Set NEXTAUTH_URL to your production domain (e.g., https://your-domain.vercel.app).
  4. Update the Authorized redirect URIs in your Google Cloud Console to include your production callback:
    • https://your-domain.vercel.app/api/auth/callback/google
  5. Click Deploy.

🀝 Contributing

Contributions, issues, and feature requests are welcome!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'feat: Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


πŸ‘€ Author

Alaqmar Yousuf


Made with ❀️ for the AI and Open Source Community.

About

Full-stack AI prompt-sharing platform built with Next.js, MongoDB, and NextAuth for discovering, creating, searching, and managing AI prompts.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages