Open sourceBackend API implementation

social media api

A backend API for social interactions, profiles, friend requests, comments, and authentication.

Social Media API

Problem

Social apps need many related workflows: users, relationships, comments, and protected actions. The goal was to design a clear REST API around those moving parts.

Architecture

  • Express exposes REST endpoints for users, profiles, friend requests, and comments.
  • MongoDB stores user and social graph data.
  • JWT protects authenticated routes.
  • Password hashing and auth middleware secure account flows.

Key decisions

  • Separated route concerns by social domain to keep the API easier to scan.
  • Used middleware for authentication instead of repeating checks in controllers.
  • Modeled friend requests separately from accepted relationships.

Tradeoffs

  • REST keeps the API straightforward, but graph-heavy queries can become complex over time.
  • MongoDB supports flexible documents, but relationship modeling still needs discipline.

What I learned

  • Social APIs become complicated at the boundaries: permissions, pending states, and duplicate actions.
  • Clear controller structure matters once endpoints multiply.

Stack

ExpressJSMongoDBJWTREST APIPassword HashingAuthentication
Open project