PRODIGY_FS_01

Next.js Authentication System

A modern, secure, and user-friendly authentication system built with Next.js, Tailwind CSS, and MongoDB.

Home Page

Features

πŸ“Έ Screenshots

Login Page

Login Page

Registration Page

Registration Page

Dashboard

Dashboard

πŸ› οΈ Technologies Used

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

πŸš€ Getting Started

  1. Clone the repository:
git clone https://github.com/wassimOubaziz/PRODIGY_FS_01.git
  1. Install dependencies:
npm install

or

yarn install
  1. Set up environment variables: Create a .env.local file in the root directory and add the following:
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
  1. Run the development server:
npm run dev

or

yarn dev
  1. Open https://tanmaymulay.github.io/PRODIGY_FS_01/ in your browser to see the application.

πŸ“ Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ page.js
β”‚   β”œβ”€β”€ layout.js
β”‚   └── globals.css
β”œβ”€β”€ pages/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── auth/
β”‚   β”‚       β”œβ”€β”€ login.js
β”‚   β”‚       β”œβ”€β”€ register.js
β”‚   β”‚       └── logout.js
β”‚   β”œβ”€β”€ login.js
β”‚   β”œβ”€β”€ register.js
β”‚   └── dashboard.js
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ Layout.js
β”‚   β”œβ”€β”€ Navbar.js
β”‚   β”œβ”€β”€ ClientNavbar.js
β”‚   β”œβ”€β”€ AuthForm.js
β”‚   β”œβ”€β”€ Button.js
β”‚   └── Input.js
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ mongodb.js
β”‚   └── auth.js
β”œβ”€β”€ models/
β”‚   └── User.js
└── middleware/
└── authMiddleware.js

πŸ”’ Authentication Flow

  1. Registration: Users can create an account by providing a username, email, and password. Passwords are hashed using bcrypt before being stored in the database.

mongodb

  1. Login: Users can log in using their email and password. Upon successful authentication, a JWT token is generated and stored in the browser’s local storage.

  2. Protected Routes: Certain routes (e.g., dashboard) are protected and can only be accessed by authenticated users. The JWT token is used to verify the user’s identity.

https://github.com/user-attachments/assets/3d9230f4-bfe6-4306-b150-c7a8cf09ca93

  1. Logout: Users can log out, which removes the JWT token from local storage and redirects them to the login page.

🎨 UI Components

πŸ” Security Considerations

πŸš€ Deployment

This application can be easily deployed to platforms like Vercel or Netlify. Make sure to set up the required environment variables in your deployment platform.

🀝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

πŸ‘€ Author

Tanmay Mulay

πŸ™ Acknowledgements