← All projects

Full-stack web application

Phreddit

A discussion platform with threaded conversations, reputation-based voting, live updates, and moderation. Built across the interface, API, database, tests, and deployment.

React · Express · MongoDB · Socket.IO

  • 37 HTTP endpoints
  • 117 automated tests
  • 23× local feed throughput
Phreddit illustrated overview

01 / Problem

The constraint

Keep discussions, voting, moderation, and account deletion consistent across related records while maintaining a fast feed as the dataset grows.

02 / Structure

Architecture at a glance

  1. React interface + routed pages
  2. Express API + Mongo-backed sessions
  3. MongoDB + Socket.IO post rooms

03 / Implementation

Engineering decisions

  1. Replaced per-post comment aggregation in the Active feed with indexed activity metadata maintained alongside comment writes. Added compound keyset pagination for Newest, Oldest, and Active feeds.
  2. Used conditional vote updates and MongoDB transactions to coordinate reputation, memberships, moderation, and cascade deletion across related records.
  3. Hardened Mongo-backed sessions with login ID regeneration, trusted-origin checks, session-bound CSRF tokens, private-field filtering, and request rate limits.
  4. Fetched comments as a flat, capped collection and assembled the tree iteratively. Socket.IO rooms notify readers when a post changes.
  5. Built three CI jobs for lint/unit checks, replica-set integration tests, and Playwright browser flows, with failure artifacts for diagnosis.

04 / Results

Testing & performance

A recorded local benchmark on an Apple M2 Pro used 2,000 posts, 6,000 comments, and 50 workers for 15 seconds. After materializing post activity metadata, Active-feed throughput rose from 40 to 947–1,000 successful requests per second; p99 fell from 1,788.7 ms to 69.1–98.9 ms. The benchmark used loopback HTTP and predates the later cursor-pagination work. The repository contains 117 automated tests across server, client, integration, and browser suites.

Read the validation notes ↗

05 / Trade-offs

Design trade-offs

  • The published throughput numbers measure a local endpoint workload; hosted network and database latency are additional costs.
  • Comment responses disclose a 5,000-record cap. The standalone MongoDB fallback is nontransactional; replica sets provide the multi-document transaction path.
  • Context-bound cursors avoid deep offset scans, but mutable feeds do not provide snapshot isolation. Search and membership ranking still perform additional work.