Skip to content

About

A notes app where Vue sends requests to an Express API and PostgreSQL stores users, notes and sharing permissions. Owners manage access; editors can update notes and viewers can read them.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Collaborative Notes Application

A full-stack student project for creating private notes and collaborating with other registered users through Viewer and Editor permissions.

Technology Stack

  • Frontend: Vue 3, Vite, Vue Router, JavaScript, and plain CSS
  • Backend: Node.js, Express.js, and JavaScript
  • Database: PostgreSQL with pg
  • Authentication: JWT and bcryptjs

The frontend uses native fetch() and stores the educational JWT session in localStorage under authToken.

Completed Features

  • Register, log in, validate the current session, and log out
  • Hash passwords with bcryptjs and create one-day JWTs
  • Create, list, open, edit, delete, and search owned notes
  • Share a note with a registered user by email
  • Assign or change Viewer and Editor permissions
  • Remove another user's access
  • View notes on a Shared With Me page
  • Enforce note permissions in the backend

How a request moves through the application

The frontend is the part the user sees. The backend receives requests and applies the rules. The database keeps the records after the browser is closed.

flowchart LR
    A[Vue pages and forms] -->|HTTP request with JSON| B[Express API]
    B --> C[Controller]
    C --> D[Service checks data and permissions]
    D --> E[Repository runs parameterized SQL]
    E --> F[(PostgreSQL)]
    F --> E
    E --> D
    D --> C
    C -->|JSON response| A
Loading

Register and log in

  1. The user enters account details in a Vue form. The frontend sends them to the authentication API.
  2. On registration, the backend hashes the password with bcrypt and stores the user record. It does not store the original password.
  3. On login, the backend compares the submitted password with the stored hash. If it matches, it returns a JWT.
  4. The frontend stores the token in localStorage and includes it in the Authorization header of later protected requests. The backend verifies it before accepting those requests.

Create and save a note

  1. The user enters a title and content, then selects Save.
  2. Vue sends the data to Express. The controller passes it to the note service.
  3. The service checks the input. The owner ID comes from the verified login, so the request cannot simply choose another owner.
  4. The repository inserts the note into PostgreSQL using query parameters.
  5. The saved record travels back through the API as JSON. Vue uses the response to show the saved note or displays an error when the request fails.

Share and edit a note

The owner selects another registered user by email and assigns viewer or editor access. The backend checks ownership before saving a row in note_shares. Later requests check the note's owner and sharing records. A viewer can read, an editor can read and edit, and the owner can also delete the note and manage sharing. Hiding a button in Vue is not the permission check; the backend enforces the rule.

How the data is connected

The users table identifies accounts. Each notes record points to its owner. Each note_shares record connects one note to another user and stores that user's permission. Foreign keys keep these relationships consistent, and a uniqueness rule prevents duplicate shares for the same note and user.

OOP Structure

The backend follows this flow:

Controller -> Service -> Repository -> PostgreSQL
  • Models represent safe application data.
  • Repositories contain parameterized SQL queries.
  • Services validate data and enforce access rules.
  • Controllers translate service results into consistent HTTP responses.

Authentication uses AuthController -> AuthService -> UserRepository. Notes and sharing use the same structure with NoteController, ShareController, NoteService, ShareService, NoteRepository, and ShareRepository.

Database Tables

  • users: account name, email, password hash, and creation date
  • notes: owner, title, content, and creation/update dates
  • note_shares: shared user, Viewer/Editor permission, and creation date

The schema uses foreign keys with ON DELETE CASCADE, restricts permissions to viewer or editor, and prevents duplicate sharing rows for the same note and user.

Permission Rules

Role View Edit Delete Share and manage access
Owner Yes Yes Yes Yes
Editor Yes Yes No No
Viewer Yes No No No

These rules are enforced by the Express services even if someone sends API requests manually.

Frontend Routes

  • /login
  • /register
  • /notes
  • /notes/new
  • /notes/:id
  • /shared

All note routes use a Vue Router navigation guard that validates the token with GET /api/auth/me.

API Endpoints

Authentication

  • POST /api/auth/register
  • POST /api/auth/login
  • GET /api/auth/me

Notes

  • GET /api/notes?search=title
  • POST /api/notes
  • GET /api/notes/:id
  • PUT /api/notes/:id
  • DELETE /api/notes/:id

Sharing

  • GET /api/shared?search=title
  • GET /api/notes/:id/shares
  • POST /api/notes/:id/share
  • PUT /api/notes/:noteId/share/:shareId
  • DELETE /api/notes/:noteId/share/:shareId

Local Setup

1. Create or update the database tables

Create a PostgreSQL database named collaborative_notes if it does not already exist. From the project root, run:

psql -U postgres -d collaborative_notes -f database/schema.sql

The schema is additive: it uses CREATE TABLE IF NOT EXISTS and does not delete existing users or data.

2. Configure environment files

Copy-Item server/.env.example server/.env
Copy-Item client/.env.example client/.env

Set DB_HOST, DB_PORT, DB_NAME and DB_USER for your local PostgreSQL database. Set PORT to the backend port and CLIENT_URL to the local frontend origin. Set the real PostgreSQL password and a long JWT secret only in server/.env. Do not commit real environment files. Set the local client API URL:

VITE_API_URL=http://localhost:5000/api

3. Start the backend

cd server
pnpm install
pnpm run dev

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

4. Start the frontend

In a second PowerShell window:

cd client
pnpm install
pnpm run dev

Open http://localhost:5173.

Checks

Run the automated authentication and permission tests:

cd server
pnpm test

Build the Vue frontend:

cd client
pnpm run build

Security Notes

  • Password hashes are never returned by the API.
  • JWT and database secrets come from server/.env.
  • User input is passed to PostgreSQL with $1, $2, and $3 parameters.
  • Note ownership comes from the authenticated JWT, not from request body data.
  • Real .env files, dependencies, build output, and logs are ignored by Git.

Screenshots

Real local application screens. The dashboard uses demonstration content only.

Notes workspace Sharing controls Login Registration

Validation

Four backend tests passed, including authentication and owner/editor/viewer permission checks. The Vue production build passed. Local PostgreSQL connectivity, browser login and saving a note were checked on 18 September 2026. The automated API tests use test repositories, so they do not replace a full PostgreSQL integration suite.

Limitations and future work

JWTs are stored in localStorage in this educational implementation. Consider HttpOnly cookie sessions, stronger abuse controls, database integration tests and conflict handling for simultaneous edits before using it for sensitive data. Sharing is permission-based; there is no real-time collaborative editor.

Learning topics

The controller/service/repository structure separates HTTP handling, permission decisions and SQL. The project is useful for explaining parameterized queries, password hashing, JWT verification and server-side authorization.

Author

Shanjidul Hasan Rohan | GitHub

About

A notes app where Vue sends requests to an Express API and PostgreSQL stores users, notes and sharing permissions. Owners manage access; editors can update notes and viewers can read them.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages