Skip to content

itang06/InstaText

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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.

InstaText Node.js React PostgreSQL

✨ 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:

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

    DB_USER=postgres
    DB_HOST=localhost
    DB_NAME=instatext
    DB_PASSWORD=your_password
    DB_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

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

WebSocket Events

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 -

🎯 Available Scripts

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

πŸ”§ 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

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors