dedachat

module
v0.0.0-...-dcec038 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: MIT

README

ci badge Go Report Card

DEDA Chat

An open-source real-time messaging system built in Go.

DEDA Chat is a self-hostable, open-source messaging system designed to be simple, extensible, and production-ready out of the box. It provides everything you need to run your own real-time chat platform: authentication, friend management, WebSocket-based messaging, and a terminal client, all in one place.

dedachat_gif_main-ezgif com-video-to-gif-converter

Motivation

I built DEDA Chat to better understand how real-time messaging works under the hood, synchronization between clients, instant message delivery, and terminal-to-terminal communication. The result is a minimal, working foundation that others can fork and use to build their own messenger.

Features

  • Real-time messaging using Gorilla WebSocket
  • Type-safe database queries via sqlc with migrations managed by Goose
  • JWT — based authentication
  • argon2id — password hashing
  • Terminal client — a fully interactive TUI built with Bubble Tea and Lipgloss
  • PostgreSQL — for data storage
  • Containerized — runs out of the box with Docker and Docker Compose
  • Friend system — users can send, accept, and remove friends
  • Notifications — unread message counts and pending friend requests
  • Online/offline status tracking
  • Chat history

Try It Now

A public server is running at https://dedachat-production.up.railway.app. No setup needed, just run the client and connect:

> SERVER_ADDR=https://dedachat-production.up.railway.app go run ./cmd/client

Requirements

Quick Start

  1. Clone and cd to the repository.
> git clone https://github.com/denisnosik/dedachat
> cd cli-messenger
  1. Rename the .env.example file to .env and fill it in with your own values.
.env.example contains:

SECRET=your_secret_here
DB_URL=postgres://postgres:postgres@db:5432/messenger?sslmode=disable
GOOSE_DRIVER=postgres
GOOSE_DBSTRING=postgres://postgres:postgres@db:5432/messenger?sslmode=disable
GOOSE_MIGRATION_DIR=sql/schema
  1. Start the server and database using Docker Compose in detached mode:
> docker-compose up --build -d
  1. Run the client:
> go run ./cmd/client

Or you can build the client:

> go build -o messenger ./cmd/client
> ./messenger

Architecture

The backend follows a simple modular structure. Each feature (auth, chats, friends) is isolated into its own handler and service layer. All database access is handled through type-safe code generated by sqlc.

The WebSocket chat system uses concurrent goroutines for reading and writing, with all state changes managed exclusively through channels. A context-based cancellation pattern ensures clean goroutine shutdown on disconnect.

The terminal client is built with Bubble Tea following the Elm architecture — each screen (auth, menu, chat) is an independent model with its own Init, Update, and View.

Usage/Examples

The client uses the Bubble Tea TUI for visual convenience; just use the commands to navigate through the application.

register                       create a new account
login                          sign in using your nickname and password
chat <nickname>                open a chat with a friend
friends <nickname>             send a friend request to a user
friends --delete <nickname>    remove a user from your friends list
friends --list                 display a list of all your friends
notifications                  display unread messages and friend requests
Create a new user and login

To create a new account, enter the command

>  register

After you have a user, you can log in using the command:

>  login
Friendship
deda_friends_gif-ezgif com-video-to-gif-converter

To start chatting, you need to add friends first.

Enter the following command to send a friend request:

> friends <nickname>

You must wait until the other user accepts your friend request.

To remove a user from your friends list, use the --delete flag:

> friends --delete <nickname>

To display a list of all your friends, use the --list flag:

> friends --list
Chat
dedachat_chat_gif-ezgif com-video-to-gif-converter (1)

To open a chat, use the command

> chat <nickname>

After entering the command, a simple chat window will open where you can communicate with your friend.

Contributing

Contributions are always welcome!

If you have suggestions, ideas, or find any issues, feel free to open an issue or submit a pull request.

API

Authentication
POST /api/register              - create account
POST /api/login                 - sign in, returns JWT token
Friends
GET  /api/friends               - get friends list
POST /api/friends               - send friend request
DELETE /api/friends             - remove friend
Chats
POST /api/chats                 - create or get existing chat
GET  /api/chats/ws              - connect to chat via WebSocket
POST /api/chats/{chat_id}/read  - mark messages as read
Notifications
GET  /api/notifications         - get unread messages and friend requests
Status
POST /api/online                - set user online
POST /api/offline               - set user offline

Directories

Path Synopsis
cmd
client command
server command
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL