ProjectsFriendBook
← Projects

FriendBook

A social network web app with accounts, friend requests, friend suggestions, real-time chat and an admin dashboard. It started as a command-line program in C.

  • JavaScript 58%
  • HTML 23%
  • CSS 17%
  • Shell 2%

live from github.com/the-wilful-youth/FriendBook, refreshed daily

Year
2025
Team and role
Team ADAPT (DS-III-T005): Tanishk Gupta, Prajjwal Singh, Divyanshi Singh and me.
Built with
Node.jsExpressSQLiteTursoSocket.IO
See it
Code ↗

What it does

People register, send and accept friend requests, chat with each other, and get suggestions for people they might know. An admin dashboard handles user management. Passwords are hashed with bcrypt and sessions use JWTs.

The first version was a C program that ran in the terminal. That version is still on the legacy-cli branch. The web version is a rewrite in JavaScript.

Architecture

An Express server exposes a JSON API and serves the front end. Chat runs over Socket.IO, with each user in their own room so a message goes only to its recipient. Data lives in Turso (LibSQL) when it's configured and falls back to a local SQLite file when it isn't, so the app still runs on a laptop with no setup.

One engineering decision

Friend suggestions are a weighted score rather than a plain list of friends-of-friends. A candidate scores higher for each mutual friend (that carries about half the weight), and for network distance and activity. The server returns the top 12.

The mutual-friend count is computed in SQL, so database indexes do most of the work. The cost grows with the number of users times their average number of friends, which is fine at the scale this runs at and would need rethinking well beyond it.

A bug worth writing down

At one point, a sent message never appeared for the recipient until they refreshed. The server was emitting the event correctly. The client had no listener for it. The fix was a new_message handler that renders the message only when that conversation is open.