ParsChat
A feature-rich chat application with a WhatsApp-like UI, built with Go and Server-Sent Events for real-time communication.
Install / Use
/learn @parvvaresh/ParsChatREADME
TCP Chat Application
WARNING - CRITICAL INFRASTRUCTURE
This repository is designed to facilitate communication for Iranian citizens during protests and internet shutdowns. It operates on domestic servers to maintain connectivity when external internet access is restricted or censored. Use responsibly and ensure secure deployment in sensitive environments.
A feature-rich chat application with a WhatsApp-like UI, built with Go and Server-Sent Events for real-time communication.
Screenshots

Modern WhatsApp-like interface with real-time messaging, groups, and media sharing
Features
Authentication and Security
- User Registration and Login - Complete authentication system
- Password Hashing - Using SHA256
- Secure Sessions - User management with SSE
- User Blocking - Block/unblock unwanted users
- Mutual Contact System - Two-way contact addition
Messaging
- Private Chat - One-on-one messaging with privacy controls
- Group Chats - Create and manage groups with members
- Leave Group - Exit from groups you no longer want to be in
- File Sharing - Send images, videos, and files
- Voice Messages - Record and send voice messages
- Media Filtering - Filter messages by type (images/files/audio)
- Typing Indicator - Shows when user is typing
- Real-time Messaging - Using Server-Sent Events
- Message Blocking - Blocked users cannot send you messages
User Management
- Username Search - Find and add users by username
- Contact Management - Add/remove contacts easily
- Block List - View and manage blocked users
- Group Member Management - Add members from your contacts
User Interface
- WhatsApp-like Design - Modern and familiar UI
- Dark Mode - Eye-comfortable dark theme
- Responsive - Works on desktop and mobile
- Media Preview - Display images and videos in chat
- Audio Player - Built-in player for voice messages
- Media Filter Tabs - Quick access to specific media types
- Smooth Animations - Professional user experience
- Loading States - Clear feedback during operations
Technical
- SQLite Database - Data storage
- Server-Sent Events - Real-time communications
- RESTful API - Modern architecture
- Docker - Ready for deployment
- Offline Capability - Works on local networks without internet
Project Structure
chatApp/
├── cmd/
│ └── server/
│ └── main.go # Main server with SSE and API
├── public/
│ ├── index.html # Web UI
│ └── app.js # Frontend logic
├── uploads/ # Uploaded files
├── chat.db # SQLite database
├── Dockerfile # Docker image
├── docker-compose.yml # Service configuration
├── go.mod # Go dependencies
└── README.md # This file
Quick Start
Prerequisites
- Go 1.21 or later
- Docker and Docker Compose (optional)
- Modern web browser
Running Locally
1. Install Dependencies
go mod download
2. Run Server
go run cmd/server/main.go
Server runs on http://localhost:8080
3. Open in Browser
Go to http://localhost:8080 and:
- Register or login
- Search for other users
- Start chatting!
Running with Docker
Build and Run
docker-compose up --build
Access the Application
Go to http://localhost:8080
Stop Services
docker-compose down
Usage Guide
Registration and Login
- Open the login page
- Click "Register"
- Enter username, full name, and password
- After registration, login
Starting a Private Chat
- Click the chat button
[C](New Chat) - Option A - Search by Username:
- Type a username in the search box
- Click "Search"
- Click "Add Contact" if found
- Option B - Select from List:
- Browse all users below
- Click "Add" to add as contact
- Click on contact to start chatting
Blocking/Unblocking Users
- Open a private chat
- Click the block button
[X]in chat header - To unblock, click the
[✓]button
Filtering Messages by Media Type
In private chats:
- Use the filter tabs: All | Images | Files | Audio
- View only specific types of shared media
Sending Voice Messages
- Press and hold the microphone button
[🎤] - Record your voice message
- Release to send automatically
Creating a Group
- Click the group button
[G](New Group) - Enter group name
- Select members from your contacts
- Click "Create Group"
Leaving a Group
- Open a group chat
- Click the
[Leave]button in chat header - Confirm to leave the group
Sending Media
- Click the attachment button in the input area
- Select an image or video
- File is automatically uploaded and sent
Additional Features
- Search: Use the search box to find contacts
- Typing: When you type, the other party sees it
- Online Status: See online status indicator
API Endpoints
Authentication
POST /api/register- Register new userPOST /api/login- User login
Users and Contacts
GET /api/users- Get user listGET /api/contacts?userId={id}- Get user's contactsPOST /api/contacts- Add contact (mutual)DELETE /api/contacts- Remove contact
Blocking
POST /api/block- Block a userPOST /api/unblock- Unblock a userGET /api/blocked?userId={id}- Get blocked users listGET /api/isblocked?blockerId={id}&blockedId={id}- Check if blocked
Groups
GET /api/groups?userId={id}- Get user's groupsPOST /api/groups- Create new groupPOST /api/groups/leave- Leave a group
Messages
GET /api/messages?userId={id}&contactId={id}- Get private messagesGET /api/messages?userId={id}&contactId={id}&mediaFilter={type}- Get filtered messagesGET /api/messages?userId={id}&groupId={id}- Get group messagesPOST /api/send- Send messagePOST /api/typing- Send typing indicatorGET /events?userId={id}- SSE connection
Media
POST /api/upload- Upload file (images/videos/audio/voice)GET /uploads/{filename}- Get uploaded file
Database Schema
users table
- id (INTEGER PRIMARY KEY)
- username (TEXT UNIQUE)
- full_name (TEXT)
- password (TEXT - SHA256 hash)
- created_at (DATETIME)
contacts table
- user_id (INTEGER)
- contact_id (INTEGER)
- added_at (DATETIME)
- PRIMARY KEY(user_id, contact_id)
blocked_users table
- blocker_id (INTEGER)
- blocked_id (INTEGER)
- blocked_at (DATETIME)
- PRIMARY KEY(blocker_id, blocked_id)
groups table
- id (INTEGER PRIMARY KEY)
- name (TEXT)
- creator_id (INTEGER)
- created_at (DATETIME)
group_members table
- group_id (INTEGER)
- user_id (INTEGER)
- joined_at (DATETIME)
messages table
- id (INTEGER PRIMARY KEY)
- from_user (INTEGER)
- to_user (INTEGER, nullable)
- group_id (INTEGER, nullable)
- content (TEXT, nullable)
- media_url (TEXT, nullable)
- media_type (TEXT, nullable - image/video/file/audio/voice)
- timestamp (DATETIME)
Production Deployment
Environment Variables
PORT=8080 # Server port
Security Notes
- Use HTTPS in production
- Enforce strong passwords
- Implement rate limiting
- Regular database backups
- Input validation and sanitization
Development
x] ~~Voice messages~~ ✅ Completed
- [x] ~~User blocking~~ ✅ Completed
- [x] ~~Username search~~ ✅ Completed
- [x] ~~Media filtering~~ ✅ Completed
- [x] ~~Leave group~~ ✅ Completed
- [ ] JWT authentication
- [ ] End-to-end encryption
- [ ] Voice/video calls
- [ ] Push notifications
- [ ] Emoji reactions
- [ ] Location sharing
- [ ] Message read receipt
Dependencies
github.com/mattn/go-sqlite3- SQLite driver
TODO / Future Improvements
- [ ] JWT authentication
- [ ] End-to-end encryption
- [ ] Voice/video calls
- [ ] Push notifications
- [ ] Emoji reactions
- [ ] Location sharing
- [ ] Voice messages
- [ ] Custom themes
- [ ] Mobile app (React Native)
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
This project is released under the MIT License.
Ethical Use
This tool is designed to help free communication during critical times. Please:
- Use responsibly and legally
- Respect user privacy
- Avoid misuse
- Be aware of security requirements
Support
For issues, questions, or feature requests:
- Create an Issue on GitHub
- Join discussions
Built for free communication
