A full-stack student project for creating private notes and collaborating with other registered users through Viewer and Editor permissions.
- 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.
- Register, log in, validate the current session, and log out
- Hash passwords with
bcryptjsand 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
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
- The user enters account details in a Vue form. The frontend sends them to the authentication API.
- On registration, the backend hashes the password with bcrypt and stores the user record. It does not store the original password.
- On login, the backend compares the submitted password with the stored hash. If it matches, it returns a JWT.
- 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.
- The user enters a title and content, then selects Save.
- Vue sends the data to Express. The controller passes it to the note service.
- The service checks the input. The owner ID comes from the verified login, so the request cannot simply choose another owner.
- The repository inserts the note into PostgreSQL using query parameters.
- 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.
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.
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.
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.
users: account name, email, password hash, and creation datenotes: owner, title, content, and creation/update datesnote_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.
| 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.
/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.
POST /api/auth/registerPOST /api/auth/loginGET /api/auth/me
GET /api/notes?search=titlePOST /api/notesGET /api/notes/:idPUT /api/notes/:idDELETE /api/notes/:id
GET /api/shared?search=titleGET /api/notes/:id/sharesPOST /api/notes/:id/sharePUT /api/notes/:noteId/share/:shareIdDELETE /api/notes/:noteId/share/:shareId
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.sqlThe schema is additive: it uses CREATE TABLE IF NOT EXISTS and does not delete existing users or data.
Copy-Item server/.env.example server/.env
Copy-Item client/.env.example client/.envSet 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
cd server
pnpm install
pnpm run devThe backend runs at http://localhost:5000.
In a second PowerShell window:
cd client
pnpm install
pnpm run devOpen http://localhost:5173.
Run the automated authentication and permission tests:
cd server
pnpm testBuild the Vue frontend:
cd client
pnpm run build- 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$3parameters. - Note ownership comes from the authenticated JWT, not from request body data.
- Real
.envfiles, dependencies, build output, and logs are ignored by Git.
Real local application screens. The dashboard uses demonstration content only.
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.
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.
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.
Shanjidul Hasan Rohan | GitHub



