Skip to main content
Reading progress: 0%

Practical Project 2: Personal Bookmark & Reading Vault

Difficulty: Beginner → Intermediate
Estimated Effort: 2 weekends
Core Skills Practiced: Multi-user accounts (login vs. ownership checks), setting up a real database (PostgreSQL), validating web links safely, search/filtering, permission tests, and production database migrations.


Overview​

In this walkthrough, you will build a Personal "Read Later" Bookmark Vault—a private web app where you save articles, tutorials, and videos you want to read later, organize them with simple topic tags, and check them off once you've read them.

Think of it as your own clean, private alternative to leaving 40 browser tabs open or texting links to yourself in a chat app so you can open them on another device later:

  • You open your website from either your laptop or your phone and log into your account.
  • You paste a link (like a recipe, a coding guide, or a YouTube talk), give it a short title and an optional tag (like cooking or career), and save it.
  • You can filter your list to show only Unread links or search by keyword, and mark items Read when finished.

How this differs from Project 1: Project 1 had no login—one person used one simple list. Project 2 introduces multiple private users, which teaches you how login works, how to connect two database tables (users and bookmarks), and how to guarantee User B can never see or delete User A's saved links.


Phase 1: Idea & Product Thinking​

The Everyday Scenario​

Imagine it is Tuesday afternoon. On your phone at lunch, you spot a great 10-minute article about negotiating a job offer. You open it, realize you don't have time right now, and either leave the tab buried among 25 other phone tabs or message the link to yourself. By Saturday morning on your laptop, you have forgotten where you saved it—or whether you already read it.

Problem Statement​

Busy learners and working professionals regularly find useful articles and videos across their phone and laptop, but leave them scattered across open browser tabs, screenshots, and self-sent chat messages—making it frustrating to find a specific link later or know what they still haven't read.

Challenging AI Assumptions​

  • AI initially suggested: "Auto-scrape every webpage for preview images, generate AI summaries of each article, build a Chrome extension, and add public profile sharing!"
  • Your engineering decision: Automatically fetching arbitrary URLs from a server breaks constantly on paywalled/anti-bot websites and introduces serious security risks (such as SSRF—where an attacker tricks your server into calling private internal URLs). For MVP, letting the user paste a link and type a short title + tag is fast, reliable, and safe.

MVP Scope​

  • Essential (In Scope for v1):
    1. Sign up, log in, and log out with your own private account.
    2. Save a bookmark (url, title, and optional tag).
    3. View your saved bookmarks, filter by Unread / Read or search by title/tag.
    4. Mark a bookmark Read/Unread and delete a bookmark.
  • Out of Scope (Later): Webpage scraping, AI article summaries, browser extensions, shared team folders, password-reset emails (keep v1 focused on core accounts + vault).

Phase 2: Requirements & Planning​

Key User Stories & Acceptance Criteria​

  • Story 1 (Private Account & Data Isolation): As a registered user, I want to log into my vault so only I can see or change my saved links.
    • Invalid login shows a generic message ("Invalid email or password", never revealing which one was wrong).
    • Anyone who is not logged in requesting /api/bookmarks gets 401 Unauthorized.
    • User B cannot view, toggle, or delete User A's bookmark—even by guessing its ID in the URL.
  • Story 2 (Save a Link): As a user, I want to save a web link with a title and optional tag so I can find it later from any device.
    • Only valid http:// or https:// links are accepted (javascript:... or malformed text is rejected with 400).
    • The newly saved bookmark appears at the top of the list and stays saved after refreshing or logging back in.
  • Story 3 (Find & Track Reading): As a user, I want to filter unread links, search by keyword/tag, and mark links as read.
    • Filtering or searching updates the list cleanly and shows a clear message when zero matches are found.
    • Toggling Read/Unread persists after refreshing the page.

Phase 3: UI/UX & Design​

Screen Inventory (2 Clean Flows)​

  1. /login & /signup (Auth Screen): Simple centered card with email, password, inline error message area, and a link switching between Log In and Sign Up.
  2. / (My Vault Screen): Header with app name + "Log out", a compact "Save a Link" form at the top (URL, Title, Tag), a search + All / Unread / Read filter bar, and a clean vertical list of saved links.

(Putting the "Save a Link" form right at the top of / avoids needing a separate /add page!)

Text Wireframe (/ My Vault Screen)​

+------------------------------------------------------------------+
| Reading Vault [Log out] |
+------------------------------------------------------------------+
| Save a Link: |
| [ https://... ] [ Title... ] [ Tag ] [ + Save Link ] |
+------------------------------------------------------------------+
| [ Search title or tag... ] [All] [Unread] [Read] |
+------------------------------------------------------------------+
| [Unread] Git Branching Guide #git [Del] |
| learngitbranching.js.org [Mark Read] |
|------------------------------------------------------------------|
| [Read] How HTTPS Works #web [Del] |
| howhttps.works [Mark Unread] |
+------------------------------------------------------------------+

Design Direction Rules​

  • Tone: Crisp digital bookshelf (#F8FAFC background, #FFFFFF cards, #0F172A text, #2563EB blue primary action).
  • Important UX & safety details: Show the clean website domain (e.g., developer.mozilla.org), open external links safely (target="_blank" rel="noopener noreferrer"), and use a clear pill badge for Unread vs. Read.

Phase 4: System Design & Architecture​

Chosen Stack​

  • Backend + Frontend: A mainstream full-stack framework or clean API Server (Node/Express or Python/FastAPI) + Frontend.
  • Database: PostgreSQL (recommended because users expect their saved links to sync across devices and stay stored reliably online).
  • Auth Approach (Critical Decision): Hash passwords using a well-tested library (bcrypt or argon2) and track logins with signed HTTP-only session cookies (never store plain-text passwords, and never invent custom encryption).

Relational Data Model​

  • users table:
    • id (primary key)
    • email (unique, lowercase, not null)
    • password_hash (text, not null — never store plain passwords!)
    • created_at (timestamp)
  • bookmarks table:
    • id (primary key)
    • user_id (foreign key referencing users.id, not null — connects every link to its owner)
    • url (text, not null)
    • title (text, not null)
    • tag (text, nullable)
    • is_read (boolean, default false)
    • created_at (timestamp)

Mandatory Authorization Rule​

Every query on bookmarks MUST filter by user_id = current_authenticated_user_id taken from the verified server session—never from a user_id sent by the browser.


Phase 5: Project Setup (Including Database Setup)​

(If you haven't set up a database before, read Lesson 5.3: Setting Up Your Database Locally first.)

  1. Initialize repo bookmark-vault, set up .gitignore (excluding .env, node_modules/, .venv/), and create .env.example:
    PORT=3000
    DATABASE_URL=postgresql://user:password@localhost:5432/bookmark_vault
    SESSION_SECRET=replace_with_a_long_random_string
  2. Provision your development PostgreSQL database (choose the simplest option for your computer):
    • Option A (Local PostgreSQL): Install PostgreSQL locally, start the service, and create one database (e.g., createdb bookmark_vault).
    • Option B (Free Cloud Dev Database — easiest if local installs give trouble): Create a free starter Postgres database in a hosting dashboard, copy its connection string, and paste it into your local .env as DATABASE_URL (keeping separate dev and production databases later!).
  3. Create the tables (Run Initial Schema Migration):
    • Ask your AI agent to generate a schema/migration script creating the users and bookmarks tables, run the migration command, and inspect the database to confirm both empty tables exist.
  4. Verify connectivity: Add a GET /api/health route that executes a tiny test query (like SELECT 1) against Postgres so you know your app truly connects to the database before building any features.
  5. Commit the clean starter skeleton to main.

Phase 6: AI-Assisted Implementation (Vertical Slices)​

Build strictly one slice at a time on separate feature branches:

  1. Branch 1 (feat/auth-sessions):
    • Implement POST /api/auth/signup, POST /api/auth/login, POST /api/auth/logout, GET /api/auth/me.
    • Verify yourself: Sign up with a test email, inspect the users table directly, and confirm password_hash is an unreadable hash (not your typed password!) and an HTTP-only cookie is set in Browser DevTools.
  2. Branch 2 (feat/create-list-bookmarks):
    • Implement POST /api/bookmarks (with strict http:///https:// URL validation!) and GET /api/bookmarks (scoped strictly to req.user.id).
    • Connect the "Save a Link" form and Vault list UI, handling empty, loading, and invalid-URL errors.
  3. Branch 3 (feat/filter-toggle-delete):
    • Add ?q= search & ?status=unread filtering in GET /api/bookmarks, plus PATCH /api/bookmarks/:id and DELETE /api/bookmarks/:id with AND user_id = current_user_id.

Phase 7: Debugging, Security & Quality​

Crucial Security Checks (Verify Every Single One!)​

  1. Cross-User Isolation Test: Sign up as User A and save a bookmark (say ID 1). Log in as User B in an Incognito window and try sending DELETE /api/bookmarks/1 or PATCH /api/bookmarks/1. Verify the server rejects it (404/403) and User A's bookmark is untouched.
  2. XSS / Unsafe URL Check: Try saving javascript:alert(1) as a bookmark URL. Verify the backend rejects non-http(s) protocols with 400 and the frontend never executes user text as HTML.
  3. SQL Injection Check: Inspect every database query in the diff—confirm 100% use parameterized placeholders ($1, $2 or ? or an ORM), zero string concatenation.
  4. Secret Leak Check: Search codebase (git grep -i secret / inspect files) to confirm SESSION_SECRET is read from environment variables with no weak hardcoded fallback in production.

Automated Integration Tests​

  • Signup with an already-registered email returns 409/400.
  • Unauthenticated GET /api/bookmarks returns 401.
  • Saving a javascript:alert(1) bookmark returns 400.
  • User B attempting to delete User A's bookmark fails and preserves User A's record.

Phase 8: Git & Collaboration​

  1. Review each PR diff on GitHub before merging (feat/auth-sessions, feat/create-list-bookmarks, feat/filter-toggle-delete).
  2. Keep commit messages clear (feat(auth): hash passwords with bcrypt and issue httpOnly session cookie).
  3. Run your full automated test suite after merging all slices into main.

Phase 9: Deployment & Verification​

  1. Provision a managed PostgreSQL database in your cloud host (separate from your local dev database).
  2. Add production environment variables (DATABASE_URL, a newly generated 64-character random SESSION_SECRET, NODE_ENV=production / app env).
  3. Run database migrations against the production database before or during app startup so users and bookmarks tables exist online.
  4. Check cookie security flags for production HTTPS (Secure, HttpOnly, SameSite=Lax).
  5. Incognito Live Smoke Test:
    • Sign up as a fresh user on https://...
    • Log out and log back in (verifies session cookies work over HTTPS!)
    • Save 2 bookmarks with tags, filter by tag, mark 1 read, refresh page, delete 1 -> confirm every state persists cleanly.
    • Test on your phone over mobile data.

Next Walkthrough: Project 3: RoomPulse — Real-Time Group Chat & Live Presence → | Practical Projects Index | Curriculum Index