Skip to content
Alaqmar-YousufPublic

About

A full-stack MERN note-taking application with JWT authentication, secure CRUD operations, and a responsive React frontend.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

9 Commits

Folders and files

Repository files navigation

πŸ““ iNotebook β€” Your Cloud-Powered Notebook

React Vite Node.js MongoDB Bootstrap License: ISC

iNotebook is a full-stack MERN application that enables users to securely create, read, edit, and delete notes in the cloud. Equipped with JSON Web Token (JWT) authentication, password hashing, and real-time state management via the React Context API.


πŸ“‘ Table of Contents


✨ Key Features

  • πŸ” Robust Authentication & Security:

    • Secure user registration and login with salt-hashed passwords via bcryptjs.
    • Stateless session authorization using JSON Web Tokens (JWT).
    • Protected API routes verified via custom fetchuser middleware.
    • User-isolated data: each user can strictly access and modify their own notes.
  • πŸ“ Full CRUD Note Management:

    • Create: Add notes with title, description, and custom tags.
    • Read: Fetch and display notes belonging exclusively to the authenticated user.
    • Update: Modal-based in-place editing with live state synchronization.
    • Delete: Instant deletion of notes with confirmation feedback.
  • ⚑ Modern Frontend Experience:

    • Built with React 19 and bundled using Vite for ultra-fast Hot Module Replacement (HMR).
    • State management powered by React Context API (NoteContext) to prevent prop drilling.
    • Client-side routing with react-router-dom (v7), including automatic redirects for unauthenticated routes.
    • Responsive, clean UI designed with Bootstrap 5 and FontAwesome iconography.
    • Interactive dismissible alert banners for user actions.
  • πŸ›  Developer Productivity:

    • Unified script using concurrently to boot up both the Vite frontend and Express nodemon backend with a single command.

πŸ›  Tech Stack

Frontend

Backend

  • Runtime: Node.js
  • Framework: Express 5
  • Database & ODM: MongoDB with Mongoose 9
  • Security & Validation:
    • jsonwebtoken β€” Session tokens
    • bcryptjs β€” Password hashing
    • express-validator β€” Request body sanitization and validation
    • cors β€” Cross-Origin Resource Sharing

πŸ— System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   React 19 Frontend                    β”‚
β”‚  (Vite Dev Server :5173 | Context API | React Router) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
               HTTP Requests (CORS Enabled)
               Header: auth-token: <JWT>
                            β”‚
                            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Express.js Backend                    β”‚
β”‚                      (Port 5000)                       β”‚
β”‚                                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   /api/auth Routes   β”‚    β”‚   /api/notes Routes  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚             β”‚                           β”‚              β”‚
β”‚             β–Ό                           β–Ό              β”‚
β”‚     [bcryptjs & JWT]             [fetchuser MW]        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚                           β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚    MongoDB Database    β”‚
               β”‚  (Users & Notes Docs)  β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Directory Structure

inotebook/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── fetchuser.js       # JWT extraction and verification middleware
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ Notes.js           # Mongoose schema for Notes
β”‚   β”‚   └── User.js            # Mongoose schema for Users
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ auth.js            # Authentication routes (/createuser, /login, /getuser)
β”‚   β”‚   └── notes.js           # CRUD routes (/fetchallnotes, /addnote, /updatenote, etc.)
β”‚   β”œβ”€β”€ db.js                  # MongoDB connection setup
β”‚   β”œβ”€β”€ index.js               # Express server entry point
β”‚   └── package.json           # Backend dependencies and scripts
β”œβ”€β”€ public/                    # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ assets/                # Images and illustrations
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ About.jsx          # About page component
β”‚   β”‚   β”œβ”€β”€ AddNote.jsx        # Form to add new notes
β”‚   β”‚   β”œβ”€β”€ Alert.jsx          # Dynamic alert feedback component
β”‚   β”‚   β”œβ”€β”€ Home.jsx           # Main home dashboard component
β”‚   β”‚   β”œβ”€β”€ Login.jsx          # User login view
β”‚   β”‚   β”œβ”€β”€ Navbar.jsx         # Responsive navigation bar
β”‚   β”‚   β”œβ”€β”€ NoteItem.jsx       # Individual note card component
β”‚   β”‚   β”œβ”€β”€ Notes.jsx          # Note list & edit modal container
β”‚   β”‚   └── Signup.jsx         # User registration view
β”‚   β”œβ”€β”€ context/
β”‚   β”‚   └── notes/
β”‚   β”‚       β”œβ”€β”€ noteContext.jsx # React Context creation
β”‚   β”‚       └── NoteState.jsx   # Global note state provider and API dispatchers
β”‚   β”œβ”€β”€ App.css
β”‚   β”œβ”€β”€ App.jsx                # Application root with routing & alerts
β”‚   β”œβ”€β”€ index.css
β”‚   └── main.jsx               # React DOM entry point
β”œβ”€β”€ index.html                 # Main HTML template
β”œβ”€β”€ package.json               # Root scripts and frontend dependencies
β”œβ”€β”€ vercel.json                # Single-page application rewrites for deployment
└── vite.config.js             # Vite configuration

πŸ”Œ API Reference

Base URL: http://localhost:5000

1. Authentication Endpoints (/api/auth)

Method Endpoint Description Auth Required Request Body
POST /api/auth/createuser Register a new user account ❌ No { "name", "email", "password" }
POST /api/auth/login Log in and receive JWT token ❌ No { "email", "password" }
POST /api/auth/getuser Fetch current user profile βœ… Yes (auth-token) None

Sample Response (/api/auth/login):

{
  "success": true,
  "authToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

2. Notes Endpoints (/api/notes)

All notes routes require the auth-token header containing a valid JWT.

Method Endpoint Description Header Required Request Body
GET /api/notes/fetchallnotes Retrieve all notes for logged-in user auth-token: <TOKEN> None
POST /api/notes/addnote Add a new note auth-token: <TOKEN> { "title", "description", "tag" }
PUT /api/notes/updatenote/:id Update an existing note by ID auth-token: <TOKEN> { "title"?, "description"?, "tag"? }
DELETE /api/notes/deletenote/:id Delete an existing note by ID auth-token: <TOKEN> None

πŸš€ Getting Started

Follow these steps to set up and run iNotebook locally on your machine.

Prerequisites

Ensure you have the following installed:

  • Node.js (v18.x or later recommended)
  • npm (bundled with Node.js)
  • MongoDB installed and running locally on port 27017 (or a MongoDB Atlas connection string)

Installation

  1. Clone the repository:

    git clone https://github.com/Alaqmar-Yousuf/iNotebook.git
    cd inotebook
  2. Install root & frontend dependencies:

    npm install
  3. Install backend dependencies:

    cd backend
    npm install
    cd ..

Environment Configuration

The backend connects to MongoDB via backend/db.js. By default, it targets:

const mongoUri = "mongodb://localhost:27017/inotebook";

Ensure MongoDB service is active:

  • Windows: Start the MongoDB service via services.msc or net start MongoDB.
  • macOS / Linux: brew services start mongodb-community or sudo systemctl start mongod.

(Optional) You can customize your JWT Secret inside backend/routes/auth.js or migrate to a .env configuration file for production security.


Running the Application

You can launch both the frontend and backend simultaneously or independently.

Option A: Run Both Concurrently (Recommended)

From the project root:

npm run both

This boots:

  • Client: http://localhost:5173
  • Server: http://localhost:5000

Option B: Run Individually

  1. Start the backend server:

    cd backend
    npx nodemon index.js
  2. Start the frontend development server:

    # From the root directory
    npm run dev
  3. Open http://localhost:5173 in your browser.


πŸ“¦ Building & Deployment

Build Frontend

To generate an optimized production bundle:

npm run build

The output will be created inside the dist/ directory.

Deployment (e.g., Vercel)

The project includes a vercel.json configured with SPA rewrites to ensure clean client-side routing on platforms like Vercel:

{
  "rewrites": [
    {
      "source": "/(.*)",
      "destination": "/index.html"
    }
  ]
}

πŸ“„ License & Author

About

A full-stack MERN note-taking application with JWT authentication, secure CRUD operations, and a responsive React frontend.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages