Skip to content

Upal02/Note-Taker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ Notes Management Dashboard

A full-stack Notes Management application with secure authentication, role-based access control, and complete CRUD functionality for managing notes.


πŸš€ Tech Stack

Layer Technologies
Frontend React.js (Vite), Redux Toolkit, React Router DOM, Tailwind CSS, Axios
Backend Node.js, Express.js, Sequelize ORM
Database PostgreSQL
Auth & Security JWT, bcryptjs, Joi Validation

✨ Features

Backend

  • JWT-based authentication & authorization
  • Password hashing with bcryptjs
  • Role-based access control β€” User / Analyst / Admin
  • RESTful API with versioning (/api/v1)
  • Input validation using Joi
  • Centralized error handling
  • PostgreSQL integration via Sequelize ORM

Frontend

  • Login & Registration UI
  • Protected dashboard routes
  • Role-based navigation
  • Notes CRUD functionality
  • Toast notifications
  • Responsive UI with Tailwind CSS

πŸ“ Project Structure

project/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ validations/
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ seeders/
β”‚   β”‚   └── app.js
β”‚   β”œβ”€β”€ .env.example
β”‚   β”œβ”€β”€ package.json
β”‚   └── server.js
β”‚
└── frontend/
    β”œβ”€β”€ src/
    β”œβ”€β”€ .env.example
    β”œβ”€β”€ index.html
    β”œβ”€β”€ tailwind.config.js
    β”œβ”€β”€ vite.config.js
    └── package.json

βš™οΈ Prerequisites

Make sure you have the following installed before running the project:


πŸ› οΈ Installation & Setup

1. Clone the Repository

git clone <your-repository-url>
cd project

2. Set Up PostgreSQL Database

Open your PostgreSQL client and run:

CREATE DATABASE notes_management;

3. Configure Backend Environment

cd backend
cp .env.example .env

Open .env and fill in your values:

PORT=5000
DB_HOST=localhost
DB_PORT=5432
DB_NAME=notes_management
DB_USER=your_postgres_username
DB_PASSWORD=your_postgres_password
JWT_SECRET=your_jwt_secret_key

4. Install & Run Backend

# Inside /backend
npm install
npm run dev

The backend runs at: http://localhost:5000


5. Seed the Database

# Inside /backend
npm run seed

This creates demo users (User, Analyst, Admin roles) and sample notes automatically.


6. Configure Frontend Environment

cd ../frontend
cp .env.example .env

Open .env and set:

VITE_API_BASE_URL=http://localhost:5000/api/v1

7. Install & Run Frontend

# Inside /frontend
npm install
npm run dev

The frontend runs at: http://localhost:5173


πŸ” Demo Credentials

πŸ‘€ User Accounts

Email Password
upal@example.com Upal@123
mihir@example.com Mihir@123
akshat@example.com Akshat@123

πŸ” Analyst Accounts

Email Password
aditya@example.com Aditya@123
jay@example.com Jay@123

πŸ›‘οΈ Admin Account

Email Password
umang@example.com Umang@123

πŸ“‘ API Overview

Base URL: http://localhost:5000/api/v1

Use Postman to test all endpoints. Set Authorization: Bearer <token> in the header for protected routes.


πŸ”‘ Auth Routes β€” /auth

Method Endpoint Description Auth Roles
POST /auth/register Register a new user No β€”
POST /auth/login Login and receive JWT token No β€”
GET /auth/me Get current logged-in user Yes All
POST /auth/logout Logout (stateless confirmation) Yes All

POST /auth/register β€” Request Body:

{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "John@123",
  "role": "user"
}

POST /auth/login β€” Request Body:

{
  "email": "john@example.com",
  "password": "John@123"
}

πŸ“ Notes Routes β€” /notes

Method Endpoint Description Auth Roles
GET /notes Get notes (own for user, all for admin/analyst) Yes All
GET /notes/my-notes Get only the logged-in user's notes Yes All
GET /notes/:id Get a single note by ID Yes All
POST /notes Create a new note Yes User, Admin
PUT /notes/:id Update a note Yes User, Admin
DELETE /notes/:id Delete a note Yes User, Admin

POST /notes β€” Request Body:

{
  "title": "My Note Title",
  "description": "Note content goes here"
}

PUT /notes/:id β€” Request Body (partial update allowed):

{
  "title": "Updated Title",
  "description": "Updated content"
}

πŸ‘₯ User Routes β€” /users

Method Endpoint Description Auth Roles
GET /users Get all users Yes Admin
GET /users/stats Get user count by role Yes Admin, Analyst
GET /users/:id Get a user by ID Yes All
PUT /users/:id Update user details Yes All (own) / Admin
DELETE /users/:id Delete a user Yes Admin

πŸ“Š Analytics Routes β€” /analytics

Method Endpoint Description Auth Roles
GET /analytics/overview Total notes, users, recent activity Yes Analyst, Admin
GET /analytics/notes-per-user Note count grouped by user Yes Analyst, Admin
GET /analytics/timeline Notes created over last 30 days Yes Analyst, Admin
GET /analytics/recent-activity 10 most recent notes Yes Analyst, Admin
GET /analytics/user-activity Activity metrics per user Yes Analyst, Admin

πŸ”§ Postman Setup Tips

  1. Create an Environment in Postman with variable base_url = http://localhost:5000/api/v1
  2. After login, copy the token from the response and set it as environment variable token
  3. Add to Auth header on protected requests: Authorization: Bearer {{token}}
  4. Use Content-Type: application/json header on all POST/PUT requests

πŸ”’ Security

  • JWT tokens for stateless authentication
  • Passwords hashed with bcryptjs
  • Protected routes via middleware
  • Role-based authorization (User / Analyst / Admin)
  • Request body validation with Joi
  • Environment variables for sensitive configuration

πŸ§‘β€πŸ’» Author

Developed by Upal Vasava


πŸ“„ License

This project is for educational/demo purposes. Feel free to fork and build upon it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors