A modern, full-stack web application for creating, managing, and organizing your digital notes with authentication and cloud storage.
β¨ Core Features:
- π Secure Authentication - JWT-based login/registration with bcrypt password hashing
- π Create & Edit Notes - Rich note creation with title and content
- π Advanced Search - Search notes by title or content (case-insensitive)
- ποΈ Organize Notes - View all notes sorted by latest update
- π‘οΈ Private Access - Only authorized users can access their own notes
- π¨ Modern UI - Beautiful, responsive design with Tailwind CSS
- βοΈ Cloud Storage - All data persisted in MongoDB Atlas
Technical Highlights:
- β‘ Fast Development - Vite for instant HMR during development
- π Auto-reload - Nodemon for automatic backend restart
- π― Production Ready - Optimized build for deployment
- π± Fully Responsive - Works seamlessly on desktop, tablet, and mobile
digital-notebook/
βββ backend/ # Node.js + Express server
β βββ controllers/ # Business logic
β β βββ authController.js # Auth related endpoints
β β βββ notesController.js # Notes CRUD operations
β βββ middleware/
β β βββ auth.js # JWT verification middleware
β βββ models/ # MongoDB schemas
β β βββ User.js # User model
β β βββ Note.js # Note model
β βββ routes/ # API endpoints
β β βββ auth.js
β β βββ notes.js
β βββ .env # Environment variables (git ignored)
β βββ .env.example # Template for environment setup
β βββ package.json
β βββ server.js # Express app entry point
β
βββ frontend/ # React + Vite SPA
β βββ src/
β β βββ api/
β β β βββ axios.js # Axios instance with JWT interceptor
β β βββ components/ # Reusable React components
β β β βββ NoteCard.jsx
β β β βββ NoteModal.jsx
β β β βββ ProtectedRoute.jsx
β β βββ context/
β β β βββ AuthContext.jsx # Global auth state management
β β βββ pages/ # Page components
β β β βββ DashboardPage.jsx
β β β βββ LoginPage.jsx
β β β βββ RegisterPage.jsx
β β βββ App.jsx
β β βββ main.jsx
β β βββ index.css # Global styles + Tailwind
β βββ tailwind.config.js
β βββ vite.config.js
β βββ package.json
β βββ index.html
β
βββ package.json # Root package.json
βββ .gitignore # Git ignore rules
βββ README.md # This file
- Node.js 18+ (Download)
- npm or yarn (comes with Node.js)
- MongoDB Atlas account (Sign up free)
-
Clone the repository
git clone https://github.com/Rana-Haseeb/digital-notebook.git cd digital-notebook -
Setup Backend
cd backend npm installCreate
.envfile in thebackend/directory (use.env.exampleas template):PORT=5000 MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/dbname JWT_SECRET=your_strong_random_secret_key_here
-
Setup Frontend
cd ../frontend npm install -
Start Development Servers
Terminal 1 - Backend:
cd backend npm run devBackend runs on:
http://localhost:5000Terminal 2 - Frontend:
cd frontend npm run devFrontend runs on:
http://localhost:5173 -
Open in Browser
http://localhost:5173
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/api/auth/register |
Register a new user | β |
POST |
/api/auth/login |
Login user and get JWT | β |
GET |
/api/auth/me |
Get current user profile | β |
Request/Response Examples:
Register:
POST /api/auth/register
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "securePassword123"
}Response (201):
{
"message": "User registered successfully",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"email": "john@example.com"
}
}| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/api/notes |
Get all user's notes | β |
GET |
/api/notes?search=keyword |
Search notes | β |
GET |
/api/notes/:id |
Get single note | β |
POST |
/api/notes |
Create new note | β |
PUT |
/api/notes/:id |
Update note | β |
DELETE |
/api/notes/:id |
Delete note | β |
Example - Create Note:
POST /api/notes
Authorization: Bearer <your_jwt_token>
Content-Type: application/json
{
"title": "My First Note",
"content": "This is the content of my note"
}- Runtime: Node.js
- Framework: Express.js 4.19
- Database: MongoDB 8.4 with Mongoose ODM
- Authentication: JWT (jsonwebtoken) + bcryptjs
- CORS: Enabled for frontend communication
- Dev Tools: Nodemon for auto-restart
- Library: React 18.3
- Build Tool: Vite 5.3
- Routing: React Router DOM 6.24
- HTTP Client: Axios 1.7
- Styling: Tailwind CSS 3.4
- Runtime: ES Modules
- Push to GitHub
- Visit vercel.com
- Import project β Set root directory to
frontend - Add environment variable:
VITE_API_URL=your_backend_url/api - Deploy (auto-deploys on push)
- Visit render.com
- Create Web Service from GitHub
- Build Command:
cd backend && npm install - Start Command:
cd backend && npm start - Add environment variables (PORT, MONGO_URI, JWT_SECRET)
β Implemented:
- JWT tokens for stateless authentication
- bcryptjs for password hashing (10 rounds)
- HTTP-only token storage
- Protected routes with middleware
- Input validation on backend
- CORS configured
.envfiles in.gitignore(never commit secrets!)
π Best Practices:
- Always use strong JWT_SECRET in production
- Rotate secrets periodically
- Monitor MongoDB Atlas activity
- Use HTTPS in production
- Implement rate limiting (recommended for production)
Problem: "Token is invalid or expired"
- Clear browser localStorage β Logout β Login again
- Check JWT_SECRET consistency between backend and
.env
Problem: MongoDB connection failed
- Verify connection string in
.env - Check IP whitelist in MongoDB Atlas (add 0.0.0.0/0 for development)
- Ensure MongoDB user has correct password
Problem: Frontend can't reach backend
- Verify backend is running on port 5000
- Check
VITE_API_URLin frontend.env - CORS errors? Check backend
server.jsCORS config
Problem: Changes not reflecting
- Frontend: Vite has HMR, wait 1-2 seconds or manual refresh
- Backend: Nodemon watches for changes, may need to save again
PORT=5000 # Server port
MONGO_URI=... # MongoDB connection string
JWT_SECRET=... # Private key for signing JWTs (use strong random)VITE_API_URL=https://your-api.com/apiVITE_API_URL=http://localhost:5000/apiThis project is licensed under the ISC License - see the LICENSE file for details.
Muhammad Haseeb Rajpoot
- GitHub: @Rana-Haseeb
- Email: rajpootmuhammadhaseeb@gmail.com
Contributions are welcome!
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Note categories/tags
- Rich text editor
- Note sharing functionality
- Dark mode
- Export notes (PDF, Markdown)
- Mobile app (React Native)
- Collaborative real-time editing
- Note reminders/scheduled notes
Made with β€οΈ by Rana-Haseeb
β If you find this helpful, please star the repository!