A modern, real-time text messaging application built with cutting-edge web technologies. InstaText provides instant messaging capabilities with a clean, responsive interface and real-time communication powered by WebSockets.
- π Real-time messaging with WebSocket connections
- π» Modern UI built with React and Tailwind CSS
- π Live connection status indicators with visual feedback
- π± Responsive design for all devices
- ποΈ PostgreSQL database for message persistence
- β‘ Fast development with hot reloading
- π‘οΈ CORS enabled for cross-origin requests
- π About modal with app information
- π― Simplified user experience - no login required
- React 18 - Modern UI library
- Next.js 14 - Full-stack React framework
- Tailwind CSS - Utility-first CSS framework
- WebSocket Client - Real-time communication
- Node.js - JavaScript runtime
- Express.js - Web application framework
- WebSocket (ws) - Real-time bidirectional communication
- PostgreSQL - Relational database
instatext/
βββ π client/ # Next.js frontend application
β βββ π components/ # Reusable React components
β β βββ About.jsx # About modal component
β β βββ ConnectionStatus.jsx
β β βββ MessageBubble.jsx
β βββ pages/ # Next.js pages
β β βββ _app.jsx
β β βββ index.jsx
β βββ styles/ # Global styles
β β βββ globals.css
β βββ π package.json
βββ π server/ # Express + WebSocket backend
β βββ db/ # Database configuration
β β βββ index.js
β βββ routes/ # API route handlers
β β βββ messages.js
β β βββ users.js
β βββ index.js # Express server entry point
β βββ ws.js # WebSocket server setup
β βββ π package.json
βββ π package.json # Root package configuration
βββ π README.md
Make sure you have the following installed:
- Node.js (v16 or higher) - Download here
- PostgreSQL (v13 or higher) - Download here
- npm or yarn package manager
# Clone the repository
git clone <your-repo-url>
cd instatext
# Install all dependencies (root, server, and client)
npm run install:all-
Start PostgreSQL service on your machine
-
Create a database named
instatext:CREATE DATABASE instatext;
-
Configure environment variables (optional): Create a
.envfile in theserver/directory:DB_USER=postgres DB_HOST=localhost DB_NAME=instatext DB_PASSWORD=your_password DB_PORT=5432
npm run dev# Terminal 1 - Backend Server
npm run dev:server
# Terminal 2 - Frontend Client
npm run dev:client- π Frontend: http://localhost:3000 (or 3001 if 3000 is in use)
- π§ Backend API: http://localhost:4000
- β€οΈ Health Check: http://localhost:4000/health
- π WebSocket:
ws://localhost:4000
- Open the app in your browser
- Select a user from the list to start texting
- Type messages and press Enter or click Send
- Messages appear instantly in real-time across all open tabs
- Check connection status - green dot means connected, red means disconnected
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check endpoint |
GET |
/api/messages/conversation |
Get conversation between users |
POST |
/api/messages |
Create a new message |
GET |
/api/users |
Get all users |
| Event | Description | Data |
|---|---|---|
connection |
Client connects to server | { type: 'connection', message: string, clientId: string } |
chat |
Send/receive text messages | { type: 'chat', from: number, to: number, content: string, timestamp: string } |
ping |
Connection health check | { type: 'ping' } |
pong |
Server response to ping | { type: 'pong', timestamp: string } |
disconnect |
Client disconnects | - |
| Script | Description |
|---|---|
npm run dev |
Start both frontend and backend |
npm run dev:server |
Start only the backend server |
npm run dev:client |
Start only the frontend client |
npm run install:all |
Install dependencies for all packages |
- Frontend Components: Add new React components in
client/components/ - API Routes: Create new endpoints in
server/routes/ - WebSocket Events: Extend the WebSocket handler in
server/ws.js - Database: Add new tables and queries in
server/db/
- Use ES6+ features
- Follow React best practices
- Use Tailwind CSS for styling
- Implement proper error handling
- Real-time messaging with WebSockets
- Message persistence in database
- Connection status indicators
- About modal with app information
- User authentication and authorization
- User profiles and avatars
- File/image sharing
- Message encryption
- Push notifications
- Mobile app (React Native)
- Docker containerization
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
Happy Texting! π¬