-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Welcome to OpenChat! This guide will walk you through setting up a local development environment from scratch.
OpenChat is an open-source, self-hosted team collaboration platform built with:
- Backend: Rust (Actix Web) with PostgreSQL and Redis
- Frontend: Next.js 16 with React 19 and TypeScript
- Authentication: TitaniumVault SSO
Before you begin, install the following:
| Tool | Version | Purpose |
|---|---|---|
| Rust | 1.83+ | Backend development |
| Node.js | 20+ | Frontend development |
| PostgreSQL | 14+ | Database |
| Redis | 7+ | Caching & Pub/Sub |
| Docker | Latest | Running dependencies |
| sqlx-cli | Latest | Database migrations |
cargo install sqlx-cli --no-default-features --features postgres# HTTPS
git clone https://github.com/ZerosAndOnesLLC/OpenChat.git
cd OpenChat
# Or SSH
git clone git@github.com:ZerosAndOnesLLC/OpenChat.git
cd OpenChatUse Docker Compose to start PostgreSQL and Redis:
docker-compose up -d postgres redisOr if you have PostgreSQL and Redis installed locally, ensure they're running.
cd api
cp .env.example .envEdit .env with your settings:
# Database
DATABASE_URL=postgres://username:password@localhost/openchat
# Redis
REDIS_URL=redis://localhost:6379
# TitaniumVault (for SSO)
TV_API_URL=https://api.titanium-vault.com
OAUTH_CLIENT_ID=your-client-id
OAUTH_CLIENT_SECRET=your-client-secret
OAUTH_REDIRECT_URI=http://localhost:3000/sso/callback/
# Server
PORT=9876
HOST=0.0.0.0
# JWT
JWT_SECRET=your-development-secret-key
# Logging
RUST_LOG=info,openchat_api=debug# Source .env for database connection
source .env
# Create the database
sqlx database create
# Run all migrations
sqlx migrate runcargo runThe API will be available at http://localhost:9876
curl http://localhost:9876/health
# Should return: {"status":"ok"}cd ../ui
cp .env.example .env.localEdit .env.local:
NEXT_PUBLIC_API_URL=http://localhost:9876
NEXT_PUBLIC_WS_URL=ws://localhost:9876/api/ws
NEXT_PUBLIC_TV_API_URL=https://api.titanium-vault.com
NEXT_PUBLIC_OAUTH_CLIENT_ID=your-client-idnpm install
npm run devThe UI will be available at http://localhost:3000
OpenChat uses TitaniumVault for authentication. To test locally:
-
Register an OAuth client in TitaniumVault:
- Client ID:
openchat-local - Redirect URI:
http://localhost:3000/sso/callback/ - Grant types:
authorization_code,refresh_token
- Client ID:
-
Access OpenChat through TitaniumVault:
- Log into TitaniumVault at https://titanium-vault.com
- Navigate to Applications
- Click on OpenChat
This initiates the OAuth flow and authenticates you automatically.
- Open the UI: http://localhost:3000
- Authenticate through TitaniumVault
- Create a channel and send a test message
- Check real-time updates by opening a second browser tab
openchat/
├── api/ # Rust backend
│ ├── src/
│ │ ├── main.rs # Entry point
│ │ ├── config.rs # Configuration
│ │ ├── handlers/ # Request handlers
│ │ ├── models/ # Database models
│ │ ├── services/ # Business logic
│ │ └── websocket/ # WebSocket handlers
│ └── migrations/ # SQL migrations
│
├── ui/ # Next.js frontend
│ ├── app/ # Pages (App Router)
│ ├── components/ # React components
│ └── lib/ # Utilities & API client
│
└── windows/ # Tauri desktop app (optional)
cd api
# Run development server
cargo run
# Type checking
cargo check
# Run tests
cargo test
# Linting
cargo clippy -- -D warnings
# Format code
cargo fmt
# Create new migration
sqlx migrate add -r migration_namecd ui
# Development server
npm run dev
# Production build
npm run build
# Linting
npm run lint
# Start production build
npm start- API Reference - Explore available endpoints
- Architecture Overview - Understand how components interact
- Contributing Guide - Learn how to contribute
- Deployment Guide - Deploy to production
Ensure PostgreSQL is running and DATABASE_URL is correct:
source .env
psql $DATABASE_URL -c "SELECT 1"Check Redis is running:
redis-cli ping
# Should return: PONG- Verify the API is running on the correct port
- Check
NEXT_PUBLIC_WS_URLmatches your API URL - Ensure no firewall is blocking WebSocket connections
# Reset and recreate database
sqlx database drop
sqlx database create
sqlx migrate run- GitHub Issues: Report bugs or request features
- Discussions: Ask questions
- Email: mackman42@outlook.com