Skip to content

Baladitya123/socioWeb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 SocialHub - Microservices Social Media Platform

A modern, scalable social media platform built with microservices architecture.

Architecture Frontend Backend Database License

🏗️ Architecture

┌─────────────────┐
│   React Client  │
└─────────┬───────┘
          │
┌─────────▼─────────┐
│   API Gateway     │
│   Port: 3000      │
└─────────┬─────────┘
          │
    ┌─────┼─────┐
    │     │     │
┌───▼─┐ ┌─▼──┐ ┌▼───┐
│User │ │Post│ │Media│
│3001 │ │3002│ │3003 │
└─────┘ └────┘ └─────┘

Services:

  • API Gateway: Central routing, authentication, rate limiting
  • User Service: Authentication, user management, profiles
  • Post Service: Content creation, CRUD operations, social features
  • Media Service: File upload, Cloudinary integration, media optimization

🛠️ Tech Stack

Frontend: React 18, TypeScript, Vite, Tailwind CSS, Framer Motion
Backend: Node.js, Express.js, JWT Authentication
Database: MongoDB Atlas, Redis (Caching)
Storage: Cloudinary (Media)
DevOps: Docker, GitHub Actions

✨ Features

  • 🔐 JWT Authentication with refresh tokens
  • 👥 User registration, login, and profile management
  • 📱 Create, read, update, delete posts
  • 🖼️ Media upload with Cloudinary optimization
  • 🔍 Post search functionality
  • ⚡ Redis caching for performance
  • 🔄 Event-driven architecture with RabbitMQ
  • 📊 Real-time updates and interactions

🚀 Quick Start

Prerequisites

  • Node.js 18+
  • MongoDB
  • Redis
  • Cloudinary account

Installation

# Clone repository
git clone https://github.com/Baladitya123/socialhub.git
cd socialhub

# Install frontend dependencies
cd frontend && npm install

# Install backend dependencies
cd ../backend
for service in api-gateway user-service post-service media-service search-service; do
  cd $service && npm install && cd ..
done

Environment Setup

Create .env files in each backend service:

# Database
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/socialhub

# Authentication
JWT_SECRET=your-secret-key
JWT_REFRESH_SECRET=your-refresh-secret

# Redis & RabbitMQ
REDIS_URL=redis://localhost:6379
RABBITMQ_URL=amqp://localhost:5672

# Cloudinary (media-service only)
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

# Service URLs
USER_SERVICE_URL=http://localhost:3001
POST_SERVICE_URL=http://localhost:3002
MEDIA_SERVICE_URL=http://localhost:3003
SEARCH_SERVICE_URL=http://localhost:3004

Frontend .env:

VITE_API_BASE_URL=http://localhost:3000

Start Development

# Terminal 1: API Gateway
cd backend/api-gateway && npm start

# Terminal 2: User Service
cd backend/user-service && npm start

# Terminal 3: Post Service
cd backend/post-service && npm start

# Terminal 4: Media Service
cd backend/media-service && npm start

# Terminal 5: Search Service
cd backend/search-service && npm start

# Terminal 6: Frontend
cd frontend && npm run dev

Access: http://localhost:5173

� API Endpoints

Authentication

  • POST /v1/auth/register - User registration
  • POST /v1/auth/login - User login
  • GET /v1/auth/me - Get current user

Posts

  • GET /v1/posts/get-posts - Get all posts (paginated)
  • POST /v1/posts/create-post - Create new post
  • DELETE /v1/posts/:id - Delete post

Media

  • POST /v1/media/upload - Upload media file
  • GET /v1/media/:id - Get media by ID

Search

  • GET /v1/search/posts?query= - Search posts

🐳 Deployment

Docker

cd backend
docker-compose up -d

Production

  • Frontend: Deploy to Vercel/Netlify
  • Backend: Deploy to Heroku/Railway
  • Database: MongoDB Atlas
  • Cache: Redis Cloud

🤝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❤️ by Baladitya123

⭐ Star this repository if you found it helpful!

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published