ChatAPI#

A lightweight, multitenant chat service built in Go with SQLite, WebSocket support, and durable message delivery.

πŸš€ Key Features#

  • Multitenant Architecture: API key-based tenancy with per-tenant rate limiting
  • Real-time Messaging: WebSocket connections for instant chat delivery
  • Durable Delivery: Store-then-send with at-least-once guarantees and retry logic
  • Message Sequencing: Per-room message ordering with client acknowledgments
  • Room Types: Support for DMs, groups, and channels
  • SQLite Backend: WAL mode for concurrent reads/writes
  • Graceful Shutdown: Clean connection draining and state persistence

πŸ“– Quick Start#

Prerequisites#

  • Go 1.21+
  • SQLite3 (optional, for CGO builds)

Installation#

# Clone the repository
git clone https://github.com/Byabasaija/chatapi.git
cd chatapi

# Install dependencies
go mod download

# Build the binary
go build -o bin/chatapi ./cmd/chatapi

Run#

# Set environment variables
export LISTEN_ADDR=":8080"
export DATABASE_DSN="file:chatapi.db?_journal_mode=WAL&_busy_timeout=5000"

# Start the server
./bin/chatapi

πŸ“š Documentation Sections#


ChatAPI is designed for modern chat applications requiring reliable, real-time messaging with multi-tenant support. Built with performance and simplicity in mind.