A real-time messaging application built with React, Node.js, Express, MongoDB, and WebSockets.
- Real-time messaging with WebSocket support
- User authentication with JWT tokens
- Private chats between users
- Group chats with multiple participants
- User management - view all users, create chats
- Leave/Join groups functionality
- Responsive design for desktop and mobile
- Modern UI with clean design
- React 19 - Modern React with hooks
- Redux - State management
- React Router - Client-side routing
- Axios - HTTP client
- React Use WebSocket - WebSocket integration
- Vite - Build tool and dev server
- CSS3 - Custom styling
- Node.js - JavaScript runtime
- Express.js - Web framework
- MongoDB with Mongoose - Database
- WebSocket (ws) - Real-time communication
- JWT - Authentication
- CORS - Cross-origin requests
- dotenv - Environment variables
fullstack-messenger/
├── client/ # Frontend React application
│ ├── src/
│ │ ├── components/ # React components
│ │ │ ├── auth/ # Login/Register components
│ │ │ ├── chats/ # Chat-related components
│ │ │ ├── groups/ # Group management components
│ │ │ ├── layout/ # Layout components
│ │ │ └── messages/ # Message components
│ │ ├── redux/ # Redux store, actions, reducers
│ │ ├── services/ # API and WebSocket services
│ │ └── styles/ # CSS stylesheets
│ ├── index.html
│ └── package.json
├── server/ # Backend Node.js application
│ ├── handlers/ # WebSocket and message handlers
│ ├── middleware/ # Express middleware
│ ├── models/ # MongoDB models
│ ├── repositories/ # Data access layer
│ ├── routes/ # Express routes
│ ├── services/ # Business logic
│ ├── configs/ # Database configuration
│ ├── .env # Environment variables
│ └── package.json
└── README.md
- Node.js (v16 or higher)
- MongoDB (local installation or MongoDB Atlas)
- npm or yarn
-
Clone the repository
git clone https://github.com/SaraRuthSofer/fullstack-messenger.git cd fullstack-messenger -
Install server dependencies
cd server npm install -
Install client dependencies
cd ../client npm install
-
Set up environment variables
In the
serverdirectory, update the.envfile:# JWT Configuration JWT_SECRET=your-super-secret-jwt-key-change-this-in-production JWT_EXPIRES_IN=24h # Database Configuration MONGODB_URI=mongodb://localhost:27017/fullstack-messenger # Server Configuration PORT=3000
-
Start MongoDB Make sure MongoDB is running on your system:
# For local MongoDB installation mongod
-
Start the backend server
cd server npm start # or for development with auto-restart: npm run dev
The server will run on
http://localhost:3000 -
Start the frontend development server
cd client npm run devThe client will run on
http://localhost:5173 -
Open your browser Navigate to
http://localhost:5173to use the application.
- Register a new account or Login with existing credentials
- View all users to start new conversations
- Create private chats by selecting a user
- Create group chats by selecting multiple users
- Send messages in real-time
- Manage groups - view members, leave groups
POST /auth/login- User loginPOST /auth/register- User registration
GET /users- Get all users
GET /chats- Get all chatsGET /chats/:memberId- Get chats by member IDPOST /chats- Create new chatPUT /chats/:chatId/:userId- Leave chat/group
GET /messages- Get all messagesGET /messages/:chatId- Get messages by chat ID
chat_message- Send/receive chat messagesnew_chat- Notify users of new chatsnew_user- Notify of new user registrations
npm start # Start the server
npm test # Run tests (placeholder)npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint# Install all dependencies (run from project root)
npm run install-all
# Start both server and client concurrently
npm run dev
# Build client for production
npm run build- 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
- React team for the amazing framework
- Express.js community
- MongoDB team
- All open source contributors
⭐ Star this repository if you found it helpful!