Skip to content

aditya-2129/PromptWhiz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PROMPTWHIZ.GIT

❯ Empower your creativity with prompts.

license last-commit repo-top-language repo-language-count

Built with the tools and technologies:

JavaScript PostCSS Autoprefixer React MongoDB JSON NextAuth


πŸ”— Table of Contents

πŸ“ Overview

PromptWhiz is a platform designed to help users create, share, and explore creative prompts. Whether you're a writer, artist, or developer, PromptWhiz can spark inspiration and facilitate collaboration. With user authentication, prompt creation, and profile management, PromptWhiz makes it easy for the community to contribute and explore.


πŸ‘Ύ Features

  • User authentication and authorization via NextAuth.
  • OAuth support for multiple providers (Google, GitHub, etc.).
  • Create, update, and manage prompts.
  • View other users' profiles and their prompts.
  • Responsive design with Tailwind CSS.
  • MongoDB integration for storing user and prompt data.
  • Efficient API routes for managing prompts.
  • Secure database management with Mongoose.

πŸ“‚ Repository Structure

└── PromptWhiz.git/
    β”œβ”€β”€ README.md
    β”œβ”€β”€ app
    β”‚   β”œβ”€β”€ api
    β”‚   β”‚   β”œβ”€β”€ auth
    β”‚   β”‚   β”‚   └── [...nextauth]
    β”‚   β”‚   β”‚       └── route.js
    β”‚   β”‚   β”œβ”€β”€ prompt
    β”‚   β”‚   β”‚   β”œβ”€β”€ [id]
    β”‚   β”‚   β”‚   β”‚   └── route.js
    β”‚   β”‚   β”‚   β”œβ”€β”€ new
    β”‚   β”‚   β”‚   β”‚   └── route.js
    β”‚   β”‚   β”‚   └── route.js
    β”‚   β”‚   └── users
    β”‚   β”‚       └── [id]
    β”‚   β”‚           └── posts
    β”‚   β”œβ”€β”€ create-prompt
    β”‚   β”‚   └── page.jsx
    β”‚   β”œβ”€β”€ layout.jsx
    β”‚   β”œβ”€β”€ page.jsx
    β”‚   β”œβ”€β”€ profile
    β”‚   β”‚   β”œβ”€β”€ [id]
    β”‚   β”‚   β”‚   └── page.jsx
    β”‚   β”‚   β”œβ”€β”€ loading.jsx
    β”‚   β”‚   └── page.jsx
    β”‚   └── update-prompt
    β”‚       └── page.jsx
    β”œβ”€β”€ components
    β”‚   β”œβ”€β”€ Feed.jsx
    β”‚   β”œβ”€β”€ Form.jsx
    β”‚   β”œβ”€β”€ Nav.jsx
    β”‚   β”œβ”€β”€ Profile.jsx
    β”‚   β”œβ”€β”€ PromptCard.jsx
    β”‚   └── Provider.jsx
    β”œβ”€β”€ jsconfig.json
    β”œβ”€β”€ models
    β”‚   β”œβ”€β”€ prompt.js
    β”‚   └── user.js
    β”œβ”€β”€ next.config.js
    β”œβ”€β”€ package-lock.json
    β”œβ”€β”€ package.json
    β”œβ”€β”€ postcss.config.js
    β”œβ”€β”€ public
    β”‚   └── assets
    β”‚       β”œβ”€β”€ icons
    β”‚       β”‚   β”œβ”€β”€ copy.svg
    β”‚       β”‚   β”œβ”€β”€ link.svg
    β”‚       β”‚   β”œβ”€β”€ loader.svg
    β”‚       β”‚   β”œβ”€β”€ menu.svg
    β”‚       β”‚   └── tick.svg
    β”‚       └── images
    β”‚           β”œβ”€β”€ grid.svg
    β”‚           β”œβ”€β”€ logo-text.svg
    β”‚           β”œβ”€β”€ logo.png
    β”‚           └── logo.svg
    β”œβ”€β”€ styles
    β”‚   └── globals.css
    β”œβ”€β”€ tailwind.config.js
    └── utils
        └── database.js

🧩 Modules

Configuration Files
File Summary
jsconfig.json Configuration for JavaScript project paths and aliases.
next.config.js Configuration for Next.js settings.
postcss.config.js PostCSS configuration for managing CSS processing.
package.json Contains project dependencies and scripts.
tailwind.config.js Tailwind CSS configuration file.
Components
File Summary
PromptCard.jsx Displays individual prompts.
Provider.jsx Context provider for managing global states.
Form.jsx Form component for creating or updating prompts.
Feed.jsx Displays a feed of prompts.
Profile.jsx User profile component showing user information and prompts.
Nav.jsx Navigation bar for the application.
Models
File Summary
prompt.js Mongoose model for managing prompt data.
user.js Mongoose model for managing user data.

πŸ” Authentication

PromptWhiz uses NextAuth.js to handle authentication and user management. It supports multiple OAuth providers like Google and GitHub. Here's how authentication is integrated:

Features of Authentication:

  • OAuth 2.0 providers (Google, GitHub, etc.) for seamless login.
  • Session Management: Users remain logged in across sessions.
  • Custom User Model: Integrated with MongoDB to store and manage user information.
  • Secure Routes: Protect certain pages and actions (e.g., creating or updating prompts) to authorized users only.
  • API Authentication: Secure API routes that ensure only authenticated users can interact with the backend.

How It Works:

  1. Authentication Route: The main authentication route is located at app/api/auth/[...nextauth]/route.js, where NextAuth.js handles the provider callbacks and session management.

  2. Session Management: A global provider is used to keep track of whether a user is authenticated, utilizing NextAuth's session mechanism. This ensures users can interact with the app based on their session state.

  3. Protected Pages: Pages like creating or updating prompts (create-prompt/page.jsx and `

update-prompt/page.jsx`) are protected. If a user is not authenticated, they are redirected to the login page.

  1. OAuth Providers Configuration: In next.config.js, we have configured multiple OAuth providers like Google and GitHub for seamless login.

Environment Variables:

To configure OAuth providers, make sure to add the following variables to your .env.local:

NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key

GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret

Example of Usage:

import { useSession, signIn, signOut } from "next-auth/react";

const Navbar = () => {
  const { data: session } = useSession();

  return (
    <nav>
      {session ? (
        <>
          <p>Welcome, {session.user.name}!</p>
          <button onClick={() => signOut()}>Sign Out</button>
        </>
      ) : (
        <button onClick={() => signIn("google")}>Sign In with Google</button>
      )}
    </nav>
  );
};

πŸš€ Getting Started

πŸ”– Prerequisites

Make sure you have the following installed:

πŸ“¦ Installation

  1. Clone the repository:

    git clone https://github.com/leonardoo210399/PromptWhiz.git
    cd PromptWhiz.git
  2. Install dependencies:

    npm install
  3. Create .env.local file and add the necessary environment variables:

    NEXTAUTH_URL=http://localhost:3000
    NEXTAUTH_SECRET=your-secret-key
  4. Start the development server:

    npm run dev

πŸ€– Usage

  • Prompt Feed: Explore a variety of prompts created by the community.
  • Authentication: Sign in with Google or GitHub to create and manage prompts.
  • Create Prompts: After signing in, navigate to the create prompt page and share your ideas.
  • Profile Management: View your profile to see all the prompts you've created.

πŸ§ͺ Tests

To run tests, use the following command:

npm run test

πŸ“Œ Project Roadmap

  • Add more OAuth providers for authentication.
  • Implement dark mode support.
  • Allow users to comment on prompts.
  • Add search functionality for prompts.
  • Enhance the analytics dashboard for user profiles.

🀝 Contributing

We welcome contributions from the community! Feel free to fork the repo and submit pull requests. Please see our CONTRIBUTING.md for more information.


πŸŽ— License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™Œ Acknowledgments

Special thanks to all contributors, the open-source community, and tools that helped build this project.
Logo design from Icons8.


This section now includes comprehensive details about the authentication system, how it's implemented, and how to configure and use it. Let me know if you need more changes!

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors