An open-source, full-stack AI prompt-sharing platform built with Next.js 13 (App Router), React, Tailwind CSS, MongoDB, and NextAuth.
- Overview
- Key Features
- Tech Stack
- Project Architecture & Structure
- Getting Started
- API Endpoints Reference
- Database Schema
- Deployment
- Contributing
- License
- Author
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.
- π 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.
- 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
- Route Handlers: Next.js App Router API Routes (
/app/api/...) - Authentication: NextAuth.js v4 (Google Provider)
- Database: MongoDB (Atlas or self-hosted)
- ODM: Mongoose
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 configurationFollow these instructions to get a local copy up and running.
Ensure you have the following installed on your machine:
- Node.js:
v18.0.0or 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
-
Clone the repository:
git clone https://github.com/Alaqmar-Yousuf/Promptopia.git cd Promptopia -
Install project dependencies:
npm install # or yarn install # or pnpm install
-
Create a
.envfile in the root directory:touch .env
-
Add your credentials to
.env:Variable Description Example / Default GOOGLE_IDGoogle OAuth Client ID your_client_id.apps.googleusercontent.comGOOGLE_CLIENT_SECRETGoogle OAuth Client Secret GOCSPX-your_client_secretMONGODB_URIMongoDB Connection String mongodb+srv://<user>:<password>@cluster.mongodb.net/?retryWrites=true&w=majorityNEXTAUTH_URLBase URL of your application http://localhost:3000NEXTAUTH_URL_INTERNALInternal NextAuth server URL http://localhost:3000NEXTAUTH_SECRETRandom 32+ char secret for JWT encryption Generate via openssl rand -base64 32
Tip
Setting up Google OAuth Credentials:
- Visit the Google Cloud Console.
- Create a new project and configure the OAuth consent screen.
- Create Credentials β OAuth client ID β Web application.
- Under Authorized JavaScript origins, add:
http://localhost:3000. - Under Authorized redirect URIs, add:
http://localhost:3000/api/auth/callback/google. - Copy your Client ID and Client Secret into your
.env.
Start the development server:
npm run dev
# or
yarn dev
# or
pnpm devOpen http://localhost:3000 in your browser to view the application.
| 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 |
{
email: String (required, unique),
username: String (required, unique, regex validated 3-30 chars),
image: String
}{
creator: ObjectId (ref: "User", required),
prompt: String (required),
tag: String (required)
}The simplest way to deploy Promptopia is using the Vercel Platform:
- Push your latest code to GitHub.
- Import your repository into Vercel.
- Add your environment variables (
GOOGLE_ID,GOOGLE_CLIENT_SECRET,MONGODB_URI,NEXTAUTH_URL,NEXTAUTH_SECRET) in the Vercel project settings.- Set
NEXTAUTH_URLto your production domain (e.g.,https://your-domain.vercel.app).
- Set
- Update the Authorized redirect URIs in your Google Cloud Console to include your production callback:
https://your-domain.vercel.app/api/auth/callback/google
- Click Deploy.
Contributions, issues, and feature requests are welcome!
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'feat: Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License β see the LICENSE file for details.
Alaqmar Yousuf
- GitHub: @Alaqmar-Yousuf