Skip to content

Latest commit

Β 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Notes Web Application

A full-stack web application for creating, managing, and sharing notes. Built with React, TypeScript, Node.js, Express, and PostgreSQL.

Features

  • πŸ” User Authentication - Secure signup and login with JWT tokens
  • πŸ“ Note Management - Create, read, update, and delete notes
  • πŸ” Search Functionality - Search notes by title or content
  • πŸ”— Note Sharing - Generate shareable links for your notes
  • πŸŒ“ Dark/Light Mode - Toggle between themes
  • πŸ’Ύ Persistent Storage - PostgreSQL database with Prisma ORM
  • πŸ”’ Secure - Password hashing with bcrypt and JWT authentication

Tech Stack

Frontend

  • React 18 - UI library
  • TypeScript - Type safety
  • Vite - Build tool and dev server
  • Tailwind CSS - Styling
  • Zustand - State management
  • React Router - Navigation
  • NextUI - UI components
  • Axios - HTTP client
  • Framer Motion - Animations

Backend

  • Node.js - Runtime environment
  • Express - Web framework
  • Prisma - ORM for database management
  • PostgreSQL - Database
  • JWT - Authentication tokens
  • bcrypt - Password hashing
  • CORS - Cross-origin resource sharing

Project Structure

notes-web-app/
β”œβ”€β”€ Backend/
β”‚   β”œβ”€β”€ index.js          # Express server and API routes
β”‚   β”œβ”€β”€ package.json      # Backend dependencies
β”‚   └── prisma/
β”‚       β”œβ”€β”€ schema.prisma # Database schema
β”‚       └── migrations/   # Database migrations
└── Frontend/
    └── notes-application/
        β”œβ”€β”€ src/
        β”‚   β”œβ”€β”€ App.tsx        # Main app component
        β”‚   β”œβ”€β”€ Login.tsx      # Login page
        β”‚   β”œβ”€β”€ Signup.tsx     # Signup page
        β”‚   β”œβ”€β”€ MainPage.tsx   # Main notes page
        β”‚   β”œβ”€β”€ Note.tsx       # Note component
        β”‚   β”œβ”€β”€ AddNote.tsx    # Add note component
        β”‚   └── store.jsx      # Zustand store
        β”œβ”€β”€ package.json       # Frontend dependencies
        └── vite.config.ts     # Vite configuration

Prerequisites

  • Node.js (v14 or higher)
  • PostgreSQL database
  • npm or yarn

Installation

1. Clone the repository

git clone <repository-url>
cd notes-web-app

2. Backend Setup

cd Backend
npm install

3. Database Setup

  1. Create a PostgreSQL database
  2. Create a .env file in the Backend directory with the following variables:
DATABASE_URL="postgresql://username:password@localhost:5432/database_name"
DIRECT_URL="postgresql://username:password@localhost:5432/database_name"
JWT_SECRET="your-secret-key-here"
  1. Run Prisma migrations:
npx prisma migrate dev
  1. Generate Prisma Client:
npx prisma generate

4. Frontend Setup

cd Frontend/notes-application
npm install

Running the Application

Start the Backend Server

cd Backend
node index.js

The backend server will run on http://localhost:2000

Start the Frontend Development Server

cd Frontend/notes-application
npm run dev

The frontend will run on http://localhost:5173

API Endpoints

Authentication

  • POST /user/create - Create a new user account

    • Body: { name, email, password }
  • POST /user/login - Login user

    • Body: { email, password }
    • Returns: JWT token

Notes

  • GET /notes - Get all notes for authenticated user

    • Headers: Authorization: Bearer <token>
  • POST /note/create - Create a new note

    • Headers: Authorization: Bearer <token>
    • Body: { title, content }
  • PUT /notes/:id - Update a note

    • Headers: Authorization: Bearer <token>
    • Body: { title, content }
  • DELETE /notes/:id - Delete a note

    • Headers: Authorization: Bearer <token>
  • GET /notes/search?query=<search_term> - Search notes

    • Headers: Authorization: Bearer <token>
  • GET /notes/:id/share - Generate shareable link for a note

    • Headers: Authorization: Bearer <token>
  • GET /notes/shared/:id?token=<share_token> - Access shared note (public)

Database Schema

User

  • id - Integer (Primary Key)
  • email - String (Unique)
  • name - String (Optional)
  • password - String (Hashed)

Note

  • id - Integer (Primary Key)
  • title - String
  • content - String
  • createdAt - DateTime
  • userId - Integer (Foreign Key)

Development

Frontend Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run preview - Preview production build
  • npm run lint - Run ESLint

Backend

The backend uses Express and Prisma. Make sure to run migrations after schema changes:

npx prisma migrate dev
npx prisma generate

Security Features

  • Passwords are hashed using bcrypt before storage
  • JWT tokens for authentication
  • Token-based authorization for protected routes
  • User-specific note access (users can only access their own notes)
  • Shareable links expire after 24 hours

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License.
See the LICENSE file for details.

Author

Adham Kiwan

About

Notes web app using SQL database and JWT token for authentication.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages