Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

💬 InstaText

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.

InstaTextNode.jsReactPostgreSQL

✨ Features

  • 🚀 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

🛠️ Tech Stack

Frontend

  • React 18 - Modern UI library
  • Next.js 14 - Full-stack React framework
  • Tailwind CSS - Utility-first CSS framework
  • WebSocket Client - Real-time communication

Backend

  • Node.js - JavaScript runtime
  • Express.js - Web application framework
  • WebSocket (ws) - Real-time bidirectional communication
  • PostgreSQL - Relational database

📁 Project Structure

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

🚀 Quick Start

Prerequisites

Make sure you have the following installed:

1. Clone and Install

# Clone the repository
git clone <your-repo-url>cd instatext
# Install all dependencies (root, server, and client)
npm run install:all

2. Database Setup

  1. Start PostgreSQL service on your machine

  2. Create a database named instatext:

    CREATEDATABASEinstatext;
  3. Configure environment variables (optional): Create a .env file in the server/ directory:

    DB_USER=postgresDB_HOST=localhostDB_NAME=instatextDB_PASSWORD=your_passwordDB_PORT=5432

3. Run the Application

Option A: Run Everything Together (Recommended)

npm run dev

Option B: Run Separately

# Terminal 1 - Backend Server
npm run dev:server
# Terminal 2 - Frontend Client
npm run dev:client

4. Access the Application

5. How to Use

  1. Open the app in your browser
  2. Select a user from the list to start texting
  3. Type messages and press Enter or click Send
  4. Messages appear instantly in real-time across all open tabs
  5. Check connection status - green dot means connected, red means disconnected

📡 API Endpoints

MethodEndpointDescription
GET/healthHealth check endpoint
GET/api/messages/conversationGet conversation between users
POST/api/messagesCreate a new message
GET/api/usersGet all users

WebSocket Events

EventDescriptionData
connectionClient connects to server{ type: 'connection', message: string, clientId: string }
chatSend/receive text messages{ type: 'chat', from: number, to: number, content: string, timestamp: string }
pingConnection health check{ type: 'ping' }
pongServer response to ping{ type: 'pong', timestamp: string }
disconnectClient disconnects-

🎯 Available Scripts

ScriptDescription
npm run devStart both frontend and backend
npm run dev:serverStart only the backend server
npm run dev:clientStart only the frontend client
npm run install:allInstall dependencies for all packages

🔧 Development

Adding New Features

  1. Frontend Components: Add new React components in client/components/
  2. API Routes: Create new endpoints in server/routes/
  3. WebSocket Events: Extend the WebSocket handler in server/ws.js
  4. Database: Add new tables and queries in server/db/

Code Style

  • Use ES6+ features
  • Follow React best practices
  • Use Tailwind CSS for styling
  • Implement proper error handling

🚧 Roadmap

  • 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

🤝 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

📝 License

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


Happy Texting! 💬

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages