Skip to content

ehsan-torabi/EMR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EmergencyChatRoom

A self-hosted chat application for staying connected when phone calls, SMS, and internet services are blocked in Iran. Run your own server on a VPS or local network, share a room key with friends and family, and communicate freely.

Why This Exists

During internet shutdowns and communication blackouts, traditional messaging apps become unusable. This project provides a minimal, self-contained alternative:

  • You deploy it on a server you control (outside Iran or on a local network)
  • Users connect via any web browser -- no app install needed
  • Room keys act as invite codes -- share them privately to join a conversation
  • No third-party dependencies for messaging -- just your server and SQLite

Features

  • Self-Hosted -- You own the server, no one can shut it down for you
  • No App Required -- Works in any browser, even restricted ones
  • Room Keys -- Share a simple key to let someone join your chat
  • Device Binding -- Each device gets one account to prevent spam
  • HTTPS Support -- Encrypt traffic to avoid local network inspection
  • Lightweight -- Single Go binary, SQLite database, zero external services
  • Persian UI -- Full Farsi interface with Vazir font

Quick Start

go build -o ChatTest
./ChatTest

Open http://localhost:8080 (or your server's IP).

Deploy on a VPS

  1. Get a VPS outside Iran (e.g., Germany, Finland, Netherlands)
  2. Build and upload the binary:
    GOOS=linux GOARCH=amd64 go build -o ChatTest
    scp ChatTest user@your-vps:/home/user/
  3. SSH into the VPS and run:
    ./ChatTest
  4. Share your server IP and port with people you trust
  5. They open http://YOUR-VPS-IP:8080 in their browser

Deploy on a Local Network (LAN)

If you have devices on the same network but no internet:

  1. Run ./ChatTest on one machine
  2. Other devices on the same network connect via http://LOCAL-IP:8080
  3. Works on home routers, office networks, or any LAN setup

Running with HTTPS

# Generate self-signed cert (for local/LAN use)
openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -nodes

# Run on port 443
ChatPort=443 ./ChatTest

For production, use a real certificate from Let's Encrypt.

API Endpoints

Method Endpoint Description Auth
POST /api/auth/register Register a new user No
POST /api/auth/login Login No
PUT /api/auth/profile Update display name Yes
GET /api/rooms/my List rooms owned by user Yes
POST /api/rooms Create a new room Yes
PUT /api/rooms/:key Update a room (owner only) Yes
DELETE /api/rooms/:key Delete a room (owner only) Yes
GET /api/chat/:key Get room info and messages No
POST /api/chat/:key Send a message Yes
PUT /api/chat/message/:id Edit a message (sender only) Yes
DELETE /api/chat/message/:id Delete a message (sender only) Yes

How It Works

  1. One person creates a room and gets a 24-character key
  2. Share that key privately (in person, over the phone, on paper)
  3. Others enter the key to join the room
  4. Everyone in the room can send and read messages
  5. Messages are stored on the server -- no external services involved

Project Structure

.
├── main.go          # Server, routes, handlers, database
├── message.go       # Message struct
├── go.mod / go.sum  # Dependencies
├── server.crt/key   # TLS certificate
├── templates/
│   ├── index.html   # Web UI
│   ├── script.js    # Frontend logic
│   ├── style.css    # Styles
│   └── Vazir-FD-WOL.ttf  # Persian font
└── sqliteTest.db    # SQLite database (auto-created)

License

MIT License. See LICENSE for details.

About

A self-hosted chat application for staying connected when phone calls, SMS, and internet services are blocked in Iran.

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors