An open API service indexing awesome lists of open source software.

https://github.com/aadityapanda/userregistration

This is a Full Stack-based user registration application that allows users to sign up, receive email verification, and log in. It includes user registration functionality with email verification using Nodemailer for sending verification emails.
https://github.com/aadityapanda/userregistration

expressjs full-stack js mysql nodejs react-hooks react-router react-router-dom reactjs sql user-registration

Last synced: 2 months ago
JSON representation

This is a Full Stack-based user registration application that allows users to sign up, receive email verification, and log in. It includes user registration functionality with email verification using Nodemailer for sending verification emails.

Awesome Lists containing this project

README

          

# ๐Ÿ” User Registration App

![Screenshot 2025-01-13 144947](https://github.com/user-attachments/assets/a9e8af7a-d56b-4f82-805a-4a5e73796090)

**A comprehensive Node.js user registration system with admin dashboard and email verification**

[![Node.js](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white)](https://nodejs.org/)
[![Express.js](https://img.shields.io/badge/express.js-%23404d59.svg?style=for-the-badge&logo=express&logoColor=%2361DAFB)](https://expressjs.com/)
[![React](https://img.shields.io/badge/react-%2320232a.svg?style=for-the-badge&logo=react&logoColor=%2361DAFB)](https://reactjs.org/)
[![MySQL](https://img.shields.io/badge/mysql-4479A1.svg?style=for-the-badge&logo=mysql&logoColor=white)](https://mysql.com/)
[![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E)](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
[![CSS3](https://img.shields.io/badge/css3-%231572B6.svg?style=for-the-badge&logo=css3&logoColor=white)](https://www.w3.org/Style/CSS/Overview.en.html)

---

## ๐Ÿ“– Overview

This is a full-stack Node.js application that provides a complete user registration system with email verification and an administrative dashboard. The application offers secure user management capabilities, allowing both regular users to register and authenticate, while providing administrators with comprehensive user management tools.

### ๐ŸŽฏ Key Capabilities

The application ensures secure user management and provides a seamless experience for both regular users and administrators through:

- **User Registration & Authentication** - Complete signup and login workflow
- **Email Verification System** - Automated email verification using Nodemailer
- **Administrative Dashboard** - Comprehensive user management interface
- **CRUD Operations** - Full create, read, update, and delete functionality
- **User Status Management** - Activate/deactivate user accounts
- **Automated Cleanup** - Scheduled removal of unverified accounts

---

## ๐Ÿ“‹ Table of Contents

- [๐Ÿš€ Features](#-features)
- [๐Ÿ› ๏ธ Tech Stack](#๏ธ-tech-stack)
- [๐Ÿ“ Project Structure](#-project-structure)
- [โš™๏ธ Setup](#๏ธ-setup)
- [๐Ÿ”ง Installation](#-installation)
- [๐Ÿ›ฃ๏ธ Routes Overview](#๏ธ-routes-overview)
- [๐Ÿงน Scheduled Cleanup](#-scheduled-cleanup)
- [๐Ÿ“„ License](#-license)
- [๐Ÿค Contributing](#-contributing)
- [๐Ÿ“ž Contact](#-contact)

---

## ๐Ÿš€ Features

### ๐Ÿ‘ฅ User Features
- โœ… **User Registration** - Secure account creation
- โœ… **Email Verification** - Automated verification emails
- โœ… **User Authentication** - Login/logout functionality
- โœ… **User Dashboard** - Personal account interface

### ๐Ÿ‘จโ€๐Ÿ’ผ Admin Features
- โœ… **Admin Dashboard** - Comprehensive management interface
- โœ… **User Management** - Create, edit, delete users
- โœ… **Account Control** - Activate/deactivate accounts
- โœ… **User Overview** - View all registered users

---

## ๐Ÿ› ๏ธ Tech Stack

### Backend
![Node.js](https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=node.js&logoColor=white)
![Express.js](https://img.shields.io/badge/Express.js-000000?style=for-the-badge&logo=express&logoColor=white)
![Nodemailer](https://img.shields.io/badge/Nodemailer-0F1419?style=for-the-badge&logo=nodemailer&logoColor=white)

### Frontend
![React](https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB)
![JavaScript](https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge&logo=javascript&logoColor=black)
![CSS3](https://img.shields.io/badge/CSS3-1572B6?style=for-the-badge&logo=css3&logoColor=white)

### Database & Tools
![MySQL](https://img.shields.io/badge/MySQL-4479A1?style=for-the-badge&logo=mysql&logoColor=white)
![Vite](https://img.shields.io/badge/Vite-646CFF?style=for-the-badge&logo=vite&logoColor=white)
![Git](https://img.shields.io/badge/Git-F05032?style=for-the-badge&logo=git&logoColor=white)

---

## ๐Ÿ“ Project Structure

๐Ÿ” Click to expand project structure

```
๐Ÿ“ฆ UserRegistration
โ”œโ”€โ”€ ๐Ÿ“ backend/
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ config/
โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“„ db.js # MySQL database connection
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ middleware/
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ isAdmin.js # Admin verification middleware
โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“„ requireLogin.js # Session check middleware
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ routes/
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ admin.js # Admin dashboard routes
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ dashboard.js # User dashboard routes
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ home.js # Home page routes
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ login.js # Authentication routes
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ logout.js # Session management
โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“„ signup.js # User registration routes
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ services/
โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“„ emailService.js # Email sending service
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ .env # Environment variables
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ .env.example # Environment template
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ cleanup.js # Automated cleanup task
โ”‚ โ””โ”€โ”€ ๐Ÿ“„ server.js # Main server file
โ”‚
โ””โ”€โ”€ ๐Ÿ“ frontend/your-project-name/
โ”œโ”€โ”€ ๐Ÿ“ src/
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ App.jsx # Main React component
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ main.jsx # React entry point
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ components/
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ AdminNavbar/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ AdminNavbar.css
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“„ AdminNavbar.jsx
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ AdminSidebar/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ AdminSidebar.css
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“„ AdminSidebar.jsx
โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ Navbar/
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ Navbar.css
โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“„ Navbar.jsx
โ”‚ โ”œโ”€โ”€ ๐Ÿ“ pages/
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ Admin.jsx # Admin dashboard
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ CreateUser.jsx # User creation
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ Dashboard.jsx # User dashboard
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ EditUser.jsx # User editing
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ Home.jsx # Landing page
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ Login.jsx # Authentication
โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ ManageUsers.jsx # User management
โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“„ Signup.jsx # Registration
โ”‚ โ””โ”€โ”€ ๐Ÿ“ styles/
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ Admin.css
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ CreateUser.css
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ Dashboard.css
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ EditUser.css
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ Home.css
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ Login.css
โ”‚ โ”œโ”€โ”€ ๐Ÿ“„ ManageUsers.css
โ”‚ โ””โ”€โ”€ ๐Ÿ“„ Signup.css
โ”œโ”€โ”€ ๐Ÿ“ public/
โ”œโ”€โ”€ ๐Ÿ“„ index.html
โ”œโ”€โ”€ ๐Ÿ“„ package.json
โ””โ”€โ”€ ๐Ÿ“„ vite.config.js
```

---

## โš™๏ธ Setup

### ๐Ÿ“‹ Prerequisites

Before you begin, ensure you have the following installed:

| Requirement | Version | Description |
|-------------|---------|-------------|
| ![Node.js](https://img.shields.io/badge/Node.js-339933?style=flat-square&logo=node.js&logoColor=white) | 14.x or above | JavaScript runtime |
| ![MySQL](https://img.shields.io/badge/MySQL-4479A1?style=flat-square&logo=mysql&logoColor=white) | Latest | Database server |
| ![Git](https://img.shields.io/badge/Git-F05032?style=flat-square&logo=git&logoColor=white) | Latest | Version control |
| ![React](https://img.shields.io/badge/React-20232A?style=flat-square&logo=react&logoColor=61DAFB) | Latest | Frontend framework |

---

## ๐Ÿ”ง Installation

### ๐Ÿ–ฅ๏ธ Backend Setup

๐Ÿ“ฅ Step 1: Clone the Repository

```bash
git clone https://github.com/AadityaPanda/UserRegistration.git
cd backend
```

๐Ÿ“ฆ Step 2: Install Dependencies

```bash
npm install
```

๐Ÿ”ง Step 3: Environment Configuration

Create your environment file:
```bash
cp .env.example .env
```

Configure your `.env` file with the following variables:

```env
# ๐Ÿ—„๏ธ Database Configuration
DB_HOST=your_database_host
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_NAME=your_database_name

# ๐Ÿ” Session Configuration
SESSION_SECRET=your_session_secret

# ๐ŸŒ Server Configuration
PORT=3000
BASE_URL=http://localhost:3000

# ๐Ÿ“ง SMTP Configuration
SMTP_HOST=your_smtp_host
SMTP_PORT=587
EMAIL_USER=your_email_address
EMAIL_PASS=your_email_password
SMTP_SECURE=false
```

### ๐Ÿ—„๏ธ Database Setup

๐Ÿ“Š Step 4: Database Configuration

Execute the following SQL commands to set up your database:

```sql
-- Create the database
CREATE DATABASE myform;

-- Switch to the database
USE myform;

-- Create the users table
CREATE TABLE users (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
middlename VARCHAR(30),
lastname VARCHAR(30) NOT NULL,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(64) NOT NULL,
mobile_no VARCHAR(15) NOT NULL,
email VARCHAR(50) NOT NULL UNIQUE,
isAdmin BOOLEAN DEFAULT FALSE,
verified BOOLEAN DEFAULT FALSE,
active BOOLEAN DEFAULT TRUE
);

-- Create an admin user
UPDATE users SET isAdmin = TRUE WHERE username = 'admin';

-- Reset auto-increment
ALTER TABLE users AUTO_INCREMENT = 1;
```

๐Ÿš€ Step 5: Start the Backend Server

```bash
npm start
```

โœ… Backend server will be running at `http://localhost:3000`

### ๐ŸŽจ Frontend Setup

โš›๏ธ Step 1: Create React Frontend

```bash
cd frontend
npm create vite@latest your-project-name -- --template react
cd your-project-name
```

๐Ÿ“ฆ Step 2: Install Frontend Dependencies

```bash
npm install
```

๐Ÿ—๏ธ Step 3: Build and Run

```bash
# Create production build
npm run build

# Start development server
npm run dev
```

โœ… Frontend will be running at `http://localhost:5173`

---

## ๐Ÿ›ฃ๏ธ Routes Overview

๐ŸŒ Route
๐Ÿ“ Description
๐Ÿ”’ Access

/
๐Ÿ  Landing page
๐ŸŒ Public

/signup
๐Ÿ“ User registration
๐ŸŒ Public

/login
๐Ÿ” User authentication
๐ŸŒ Public

/dashboard
๐Ÿ‘ค User dashboard
๐Ÿ”’ Authenticated

/admin
๐Ÿ‘จโ€๐Ÿ’ผ Admin homepage
๐Ÿ›ก๏ธ Admin only

/admin/user
๐Ÿ‘ฅ User management
๐Ÿ›ก๏ธ Admin only

/admin/create
โž• Create new user
๐Ÿ›ก๏ธ Admin only

/admin/edit/:id
โœ๏ธ Edit user details
๐Ÿ›ก๏ธ Admin only

---

## ๐Ÿงน Scheduled Cleanup

The application includes an automated cleanup system (`cleanup.js`) that:

- ๐Ÿ• **Runs every hour** to maintain database hygiene
- ๐Ÿ—‘๏ธ **Removes unverified users** whose verification tokens have expired
- ๐Ÿ“ง **Prevents spam registrations** by cleaning up abandoned accounts
- โšก **Optimizes database performance** by removing inactive records

This ensures your database stays clean and performs optimally over time.

---

## ๐Ÿ“„ License

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)

**This project is licensed under the MIT License**

Feel free to use, modify, and distribute it in your projects.

---

## ๐Ÿค Contributing

We welcome contributions! Here's how you can help improve this project:

### ๐Ÿ”ง Development Workflow

1. **๐Ÿด Fork the repository**
2. **๐ŸŒฟ Create a feature branch**
```bash
git checkout -b feature/YourFeatureName
```
3. **๐Ÿ’พ Commit your changes**
```bash
git commit -m "Add YourFeatureName"
```
4. **๐Ÿ“ค Push to the branch**
```bash
git push origin feature/YourFeatureName
```
5. **๐Ÿ”„ Open a pull request**

### ๐Ÿ“‹ Contribution Guidelines

- ๐Ÿงช Ensure all tests pass before submitting
- ๐Ÿ“ Update documentation for new features
- ๐ŸŽจ Follow the existing code style
- ๐Ÿ’ฌ Provide clear commit messages

Check [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.

---

## ๐Ÿ“ž Contact

**๐Ÿ‘จโ€๐Ÿ’ป Aaditya Panda**

[![Email](https://img.shields.io/badge/Email-aadityapanda23@gmail.com-red?style=for-the-badge&logo=gmail&logoColor=white)](mailto:aadityapanda23@gmail.com)
[![GitHub](https://img.shields.io/badge/GitHub-AadityaPanda-black?style=for-the-badge&logo=github&logoColor=white)](https://github.com/AadityaPanda)

---

๐Ÿ’ **Thank you for using the User Registration App!**

*If you found this project helpful, please consider giving it a โญ on GitHub!*