Social
A Real-Time Social Platform for Developers — Connection Graphs, Encrypted Messaging, and a Personal Knowledge Workspace in One App
Table of Contents
- Overview
- Platform Architecture
- Core Features
- Real-Time Messaging & Encryption
- Database Schema
- Technology Stack
- Project Screenshots
- Local Development Setup
- Environment Variables
- Current Status & Known Tradeoffs
- Roadmap
- Author
Overview
Social is a full-stack social networking platform built for developers and technical communities — combining a content feed, a bidirectional connection graph, end-to-end encrypted real-time messaging, and a personal notes/file workspace into a single application.
Most social-platform side projects stop at "posts + likes + comments." Social goes further into the systems that actually make a platform feel alive:
| Capability | How it's handled |
|---|---|
| Real-time 1:1 messaging | Socket.io with per-message AES-256-GCM encryption |
| Social graph visualization | An interactive 3D connection globe (three-globe + @react-three/fiber) alongside a traditional follow/request model |
| Personal workspace | A notes + file system with folders and an in-app PDF viewer, separate from the public feed |
| Engagement | Likes, threaded comments, saves, and archiving, all rate-limited per user/action |
| Retention insight | Session-time tracking with daily/weekly usage analytics |
| Discovery | A lightweight recommendation engine for suggested connections |
The system is built around a scalable feed and social-graph architecture, with a strong emphasis on component reuse, typed API contracts, and clear service-layer boundaries between routes and data access.
Platform Architecture

Social is structured as a modular full-stack application composed of several system layers.
Authentication Layer
Handles identity and session management using a custom JWT-based authentication system with access and refresh tokens.
Responsibilities:
- User registration and login with secure password hashing
- JWT access and refresh token issuance using HttpOnly cookies
- Session validation and route protection
- Authentication of API routes via server-side JWT verification
Content Management Layer
Responsible for post creation, editing, retrieval, and lifecycle.
Responsibilities:
- Post persistence, pagination, and feed generation
- Like/comment/save/archive state, each independently rate-limited
- Post metadata (media, timestamps, engagement counts)
Real-Time Communication Layer
Manages live, encrypted messaging between users.
Responsibilities:
- Socket.io connection lifecycle (join, message, read-receipt events)
- AES-256-GCM encryption/decryption of message payloads at rest
- Unread-count tracking and read-state synchronization across sessions
Social Graph Layer
Manages connections and discovery between users.
Responsibilities:
- Follow requests: send / accept / reject / cancel / unfollow
- Bidirectional connection state with cached request lists
- An interactive 3D visualization of a user's connection graph
- Lightweight recommendation logic for "people you may know"
Personal Workspace Layer
A private, non-social space for the user's own content.
Responsibilities:
- Folder-organized notes and file uploads
- In-app PDF rendering for uploaded documents
- Isolated from the public feed — visible only to its owner
Media Storage Layer
Handles file uploads and cloud asset delivery via Cloudinary.
Responsibilities:
- Media upload processing and optimization
- Secure delivery URLs and CDN distribution
Database Layer
Handles persistent application state via MongoDB / Mongoose.
Stores: user profiles, posts, comments, connections, notes, chat messages, notifications, stories, and usage records.
Core Features
Dynamic Social Feed
Text and media posts with likes, threaded comments, saves, and archiving — each action independently rate-limited to prevent abuse.
Connection System with 3D Visualization
A traditional follow/request/accept model paired with an interactive 3D globe rendering of a user's connection graph, built with three-globe and @react-three/fiber.
Encrypted Real-Time Messaging
Socket.io-powered 1:1 chat with AES-256-GCM encryption applied per message before persistence, plus read-receipts and live unread counts.
Personal Notes & File Workspace
A folder-based notes system with file uploads and an embedded PDF viewer — a private workspace layered on top of the social platform rather than a separate feature.
Notifications
Event-driven notifications for follow requests, accepted connections, and engagement, with a read/unread state.
Usage Analytics
Client-side session tracking (via navigator.sendBeacon on unload) feeding daily and weekly time-spent charts, rendered with recharts.
Recommendations
A lightweight "suggested connections" engine surfaced on the dashboard.
Events
User-created events with save/RSVP-style interactions.
Real-Time Messaging & Encryption
Message content is encrypted with AES-256-GCM before it's written to MongoDB — the database never holds plaintext message bodies. Socket.io handles delivery and presence; encryption/decryption happens at the application boundary, keyed off a server-held secret (CHAT_ENCRYPTION_KEY, a 32-byte key never exposed to the client).
Client A ──(plaintext)──▶ API/Socket layer ──AES-256-GCM encrypt──▶ MongoDB
MongoDB ──ciphertext──▶ API/Socket layer ──AES-256-GCM decrypt──▶ Client B
Database Schema
User ──────────┬──────────── Post ─────────────── Comment
│ firstName │ │ user → User │ post → Post
│ lastName │ │ content │ user → User
│ userId │ │ media │ textMessage
│ email │ │ likes[] → User
│ password │ │ savedPostsBy[]
│ bio │ │ isArchived
│ interests[] │
│ socialLinks │ Connection Notification
│ connections[] │──────────▶ │ requester → User │ userId → User
│ sentRequests[]│ │ recipient → User │ actorId → User
│ receivedReq[] │ │ status │ type
Chat Note Usage
│ sender → User │ user → User │ user → User
│ recipient → User │ fileUrl │ date
│ ciphertext (AES-256-GCM) │ description │ timeSpent
│ iv, authTag │ folder
│ read (bool)
Story Contact
│ user → User │ name, email, message
│ mediaUrl
│ expiresAt
Technology Stack
Frontend
| Technology | Purpose |
|---|---|
| Next.js (App Router) | Full-stack React framework |
| React | UI component library |
| TypeScript | Type-safe development |
| Tailwind CSS | Utility-first styling |
| Radix UI | Accessible unstyled primitives (dialogs, tabs, tooltips) |
| Framer Motion / Motion | UI animation |
| @react-three/fiber + three-globe | 3D connection graph visualization |
| Recharts | Usage analytics charts |
| React PDF Viewer | In-app document rendering |
Backend
| Technology | Purpose |
|---|---|
| Next.js API Routes | Serverless API endpoints |
| Socket.io | Real-time bidirectional messaging |
Node.js crypto | AES-256-GCM message encryption |
| JSON Web Tokens (JWT) | Custom authentication using access & refresh tokens |
Database & Storage
| Technology | Purpose |
|---|---|
| MongoDB + Mongoose | Primary document database |
| Cloudinary | Media upload, optimization, and CDN delivery |
Infrastructure
- In-memory rate limiting (per
user:actionkey) on write-heavy routes (likes, connections, notes) - In-memory request caching for hot read paths (e.g. pending connection requests)
- Vercel deployment target
Project Screenshots
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | |
Local Development Setup
Clone Repository
git clone https://github.com/AaryanBairagi/social.git
cd social
Install Dependencies
npm install
Start Development Server
npm run dev
Visit http://localhost:3000.
Environment Variables
Create a .env.local file:
# Authentication
JWT_ACCESS_SECRET=
JWT_REFRESH_SECRET=
# Database
MONGO_URI=
# Cloudinary
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
# Messaging encryption (64-char hex string = 32 bytes)
CHAT_ENCRYPTION_KEY=
Current Status & Known Tradeoffs
Built as a demonstration of end-to-end social-platform engineering — real-time systems, encryption, social-graph modeling, and 3D visualization — rather than a production-hardened deployment. In the interest of an honest project writeup:
| Feature | Status |
|---|---|
| Post feed, likes, comments, saves, archiving | ✅ Implemented |
| Follow/connection system with request states | ✅ Implemented |
| 3D connection graph visualization | ✅ Implemented |
| Real-time messaging (Socket.io) | ✅ Implemented |
| AES-256-GCM message encryption at rest | ✅ Implemented |
| Notes/file workspace with PDF viewer | ✅ Implemented |
| Usage analytics (daily/weekly) | ✅ Implemented |
| Per-action rate limiting | ✅ Implemented |
| Authentication | ✅ Custom JWT authentication (access & refresh tokens with HttpOnly cookies) |
| Socket.io connection authentication | ⚠️ Not yet enforced at the transport layer |
| Rate limiting / caching persistence | ⚠️ In-memory — resets on server restart, not multi-instance safe |
| Automated test coverage | ❌ Not yet implemented |
Roadmap
- Authenticate Socket.io connections using JWT handshake verification
- Move rate limiting and caching to Redis for multi-instance correctness
- Add automated tests around auth, messaging, and the connection request state machine
- Direct message read-receipts UI polish
- Post bookmarking collections
- Content recommendation ranking beyond simple suggestion logic
- Progressive Web App support
Author
Built by Aaryan Bairagi
Social was built to explore real-time system design, applied cryptography, social-graph data modeling, and 3D data visualization within a modern full-stack application.
GitHub: https://github.com/AaryanBairagi
License
Copyright © 2026 Aaryan Bairagi
All rights reserved. Unauthorized copying, modification, distribution, or commercial use of this software is prohibited without explicit permission.


