Skip to content

Latest commit

ย 

History

504 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Real-Time Social Platform

A web social platform designed to connect people in real-time, fostering seamless communication and interaction within groups.

๐Ÿ“‹ Overview

This Node.js project delivers a dynamic social platform where users can create, join, and participate in real-time group interactions. Built with modern web technologies, it enables instant messaging, presence detection, and collaborative features that bring communities together.

๐Ÿš€ Features

  • Real-time Communication: Instant messaging and notifications using WebSocket technology
  • Group Management: Create, join, and moderate group conversations
  • User Presence: See who's online and active in real-time
  • Seamless Interaction: Rich text formatting, emoji support, and file sharing
  • User Authentication: Secure signup/login with JWT-based sessions
  • Responsive Design: Mobile-friendly interface accessible from any device
  • Activity Feed: Stay updated with group activities and member interactions

๐Ÿ› ๏ธ Tech Stack

Backend

  • Node.js - JavaScript runtime
  • Express.js - Web framework
  • Socket.io - Real-time bidirectional communication
  • MongoDB - NoSQL database with Mongoose ODM
  • JWT - JSON Web Tokens for authentication
  • Bcrypt - Password hashing

๐Ÿ“ Project Structure

real-time-social-platform/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ”œโ”€โ”€ database.js
โ”‚   โ”‚   โ””โ”€โ”€ socket.js
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ User.js
โ”‚   โ”‚   โ”œโ”€โ”€ Group.js
โ”‚   โ”‚   โ””โ”€โ”€ Message.js
โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”‚   โ”œโ”€โ”€ authController.js
โ”‚   โ”‚   โ”œโ”€โ”€ groupController.js
โ”‚   โ”‚   โ””โ”€โ”€ messageController.js
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ authRoutes.js
โ”‚   โ”‚   โ”œโ”€โ”€ groupRoutes.js
โ”‚   โ”‚   โ””โ”€โ”€ apiRoutes.js
โ”‚   โ”œโ”€โ”€ middleware/
โ”‚   โ”‚   โ”œโ”€โ”€ auth.js
โ”‚   โ”‚   โ””โ”€โ”€ errorHandler.js
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”œโ”€โ”€ socketService.js
โ”‚   โ”‚   โ””โ”€โ”€ groupService.js
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ”œโ”€โ”€ validators.js
โ”‚       โ””โ”€โ”€ helpers.js
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ unit/
โ”‚   โ””โ”€โ”€ integration/
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ package-lock.json
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ server.js

๐Ÿ”ง Installation & Setup

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (v4 or higher)
  • npm or yarn package manager

Step-by-Step Installation

  1. Clone the repository
git clone https://github.com/yourusername/real-time-social-platform.git
cd real-time-social-platform
  1. Install dependencies
npm install
  1. Environment configuration
cp .env.example .env

Update the .env file with your configuration:

PORT=3000
MONGODB_URI=mongodb://localhost:27017/social_platform
JWT_SECRET=your_jwt_secret_key
NODE_ENV=development
  1. Start MongoDB
# If using local MongoDB
mongod

# Or using Docker
docker run -d -p 27017:27017 --name mongodb mongo:latest
  1. Run the application
# Development mode with auto-reload
npm run dev

# Production mode
npm start
  1. Access the application Open your browser and navigate to http://localhost:3000

๐Ÿšข Deployment

Deploying to Production

  1. Set environment variables
NODE_ENV=production
MONGODB_URI=your_production_mongodb_uri
JWT_SECRET=your_secure_jwt_secret
  1. Build for production
npm run build
  1. Start with process manager
# Using PM2
npm install -g pm2
pm2 start server.js --name social-platform

# Using Docker
docker build -t social-platform .
docker run -p 3000:3000 --env-file .env social-platform

๐Ÿ“ API Documentation

Authentication Endpoints

Method Endpoint Description
POST /api/auth/register Register new user
POST /api/auth/login User login
POST /api/auth/logout User logout
GET /api/auth/verify Verify JWT token

Group Endpoints

Method Endpoint Description
GET /api/groups Get all groups
POST /api/groups Create new group
GET /api/groups/:id Get group details
PUT /api/groups/:id Update group
DELETE /api/groups/:id Delete group
POST /api/groups/:id/join Join a group
POST /api/groups/:id/leave Leave a group

Message Endpoints

Method Endpoint Description
GET /api/messages/:groupId Get group messages
POST /api/messages Send new message
DELETE /api/messages/:id Delete message

๐Ÿ”’ Security Features

  • JWT Authentication: Stateless authentication with token expiration
  • Password Hashing: Bcrypt encryption for user passwords
  • Input Validation: Sanitization and validation of all user inputs
  • CORS Protection: Configurable cross-origin resource sharing
  • Rate Limiting: Prevent abuse and DDoS attacks
  • WebSocket Authentication: Secure WebSocket connections with token validation

๐Ÿ“Š Real-time Features

  • Instant Messaging: Sub-second message delivery
  • Typing Indicators: Real-time typing status
  • Read Receipts: Message read status
  • Online Status: User presence detection
  • Group Notifications: Real-time group activity updates
  • File Sharing: Instant image and file sharing capabilities

๐Ÿงช Testing

Run the test suite:

# Run all tests
npm test

# Run unit tests
npm run test:unit

# Run integration tests
npm run test:integration

# Run tests with coverage
npm run test:coverage

๐Ÿค Contributing

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

Development Guidelines

  • Follow the established code style
  • Write tests for new features
  • Update documentation as needed
  • Ensure all tests pass before submitting PR

๐Ÿ” Troubleshooting

Common Issues

MongoDB Connection Error

# Check if MongoDB is running
sudo systemctl status mongod
# Or
ps aux | grep mongod

WebSocket Connection Failed

  • Ensure the socket server is running on the correct port
  • Check firewall settings
  • Verify client-side socket connection URL

Authentication Issues

  • Clear browser cookies and local storage
  • Verify JWT_SECRET in .env file
  • Check token expiration time

๐Ÿ“ˆ Performance Optimization

  • Database Indexing: Proper indexes for frequent queries
  • Message Pagination: Limit message loading for better performance
  • Socket Connection Pooling: Efficient WebSocket connection management
  • Caching: Redis implementation for frequently accessed data
  • Load Balancing: Support for horizontal scaling

๐Ÿ”ฎ Future Enhancements

  • Video and audio calling integration
  • Emoji reactions and message threads
  • Advanced user profiles and customization
  • Push notifications for mobile devices
  • AI-powered moderation tools
  • Analytics and user engagement metrics
  • Multi-language support (i18n)

๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

  • Special thanks to all contributors and testers
  • Built with โค๏ธ using open-source technologies
  • Inspired by modern social platforms and communication tools

Made with โค๏ธ | Connecting People in Real-Time

About

A web social platform designed to connect people in real-time, fostering seamless communication and interaction within groups.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages