Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Social API – Reusable Social Media Backend

A multi-tenant REST API that provides plug-and-play social features (auth, feeds, caching, media) for applications that need social functionality without building it from scratch.

Built: March 2026

✨ Features

  • Multi-tenant architecture — designed for reuse across multiple client applications
  • Authentication & Authorization — OAuth 2.0 and JWT-based authentication
  • Rate limiting — Redis-backed rate limiting to protect endpoints from abuse
  • Cached feed system — Redis-cached social feed with automatic cache invalidation on writes
  • Media handling — Cloudinary integration for image/media uploads
  • Request validation — Schema validation using Zod
  • Pagination — Built-in pagination for list endpoints
  • API documentation — Interactive Swagger docs
  • Containerized — Dockerized for consistent local and production environments

🛠️ Tech Stack

Layer Technology
Runtime / Framework Node.js, Express
Database MongoDB
Cache / Rate limiting Redis
Auth JWT, OAuth 2.0
Media storage Cloudinary
Validation Zod
Docs Swagger
Containerization Docker
Deployment Railway

🚀 Deployment Notes

This project was initially deployed on Railway. The live deployment has since expired after the free trial and included credits ran out, so the hosted link is no longer active. The project can still be run locally or redeployed by following the setup steps below.

API: https://social-api-production-4d9d.up.railway.app Docs: https://social-api-production-4d9d.up.railway.app/api-docs

📦 Getting Started

Prerequisites

  • Node.js (LTS recommended)
  • Docker & Docker Compose (optional, for containerized setup)
  • MongoDB instance (local or Atlas)
  • Redis instance (local or hosted)
  • Cloudinary account (for media uploads)

Installation

# Clone the repository
git clone <your-repo-url>
cd social-api

# Install dependencies
npm install

# Copy environment variables
cp .env.example .env

Environment Variables

PORT=5000
MONGO_URI=your_mongodb_connection_string
REDIS_URL=your_redis_connection_string
JWT_SECRET=your_jwt_secret
OAUTH_CLIENT_ID=your_oauth_client_id
OAUTH_CLIENT_SECRET=your_oauth_client_secret
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

Running Locally

# Development
npm run dev

# With Docker
docker-compose up --build

API Documentation

Once running, Swagger docs are available at:

http://localhost:<PORT>/api-docs

📖 API Overview

  • Auth — Register, login, OAuth 2.0 flow, JWT issuance/refresh
  • Feed — Cached, paginated social feed with cache invalidation on new content
  • Media — Upload and manage media via Cloudinary
  • Rate Limiting — Redis-based request throttling per user/IP

(Expand this section with your actual route list, e.g. POST /auth/register, GET /feed, POST /media/upload, etc.)

🏗️ Architecture Highlights

  • Multi-tenant design allows the API to serve multiple client apps with isolated data/config
  • Redis sits in front of MongoDB for feed reads, with invalidation triggered on relevant writes to keep cache consistency
  • Zod schemas validate all incoming requests before they hit controller logic
Phase 1   →  Express + MongoDB + Redis + Docker
Phase 2  →  OAuth 2.0 auth system
Phase 3   →  Users + Follow system
Phase 4   →  Posts + Media uploads
Phase 5   →  Likes + Comments
Phase 6   →  Feed with Redis caching
Phase 7   →  Rate limiting + Validation + Pagination
Phase 8   →  Swagger Docs + Railway Deployment

About

A reusable social media backend API service

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages