A web social platform designed to connect people in real-time, fostering seamless communication and interaction within groups.
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.
- 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
- 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
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
- Node.js (v14 or higher)
- MongoDB (v4 or higher)
- npm or yarn package manager
- Clone the repository
git clone https://github.com/yourusername/real-time-social-platform.git
cd real-time-social-platform- Install dependencies
npm install- Environment configuration
cp .env.example .envUpdate the .env file with your configuration:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/social_platform
JWT_SECRET=your_jwt_secret_key
NODE_ENV=development- Start MongoDB
# If using local MongoDB
mongod
# Or using Docker
docker run -d -p 27017:27017 --name mongodb mongo:latest- Run the application
# Development mode with auto-reload
npm run dev
# Production mode
npm start- Access the application
Open your browser and navigate to
http://localhost:3000
- Set environment variables
NODE_ENV=production
MONGODB_URI=your_production_mongodb_uri
JWT_SECRET=your_secure_jwt_secret- Build for production
npm run build- 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| 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 |
| 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 |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/messages/:groupId |
Get group messages |
| POST | /api/messages |
Send new message |
| DELETE | /api/messages/:id |
Delete message |
- 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
- 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
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- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the established code style
- Write tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
MongoDB Connection Error
# Check if MongoDB is running
sudo systemctl status mongod
# Or
ps aux | grep mongodWebSocket 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
- 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
- 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)
This project is licensed under the MIT License - see the LICENSE file for details.
- 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