A secure terminal-based chat application built with Go and Firebase Realtime Database.
- Create or join chat rooms via terminal
- Secure communication with Firebase backend
- Colored usernames for easy identification
- Real-time participant tracking
- Clean, intuitive terminal UI
- Cross-platform compatibility (Windows, macOS, Linux)
- Persistent user profiles
- Command-based interface for easy navigation
- Real-time typing indicators
- Activity status tracking for participants
Bluelink is built with a modular architecture using Go:
- Config Module: Handles user configuration and persistent storage
- Firebase Module: Manages all interactions with Firebase Realtime Database
- UI Module: Implements the terminal user interface using Bubble Tea
- Main Module: Coordinates application flow and handles command-line arguments
The application uses Firebase Realtime Database for:
- User presence management
- Real-time messaging
- Activity tracking
- Room persistence
Bluelink uses a polling mechanism to provide real-time updates from Firebase:
- Messages are retrieved using Firebase queries with timestamp filtering
- Participant updates are monitored by tracking activity timestamps
- Regular polling intervals ensure timely updates (500ms for messages, 1s for participants)
- This approach provides compatibility with the Firebase Go Admin SDK while maintaining responsiveness
The project uses GitHub Actions for continuous integration and delivery:
# .github/workflows/go.yml
name: Go
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23.8'
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...- Go 1.16 or later
- Firebase Project with Realtime Database enabled
- Terminal with Unicode support for best experience
- Create a Firebase project at firebase.google.com
- Enable Realtime Database
- Go to Build → Realtime Database
- Create database in test mode initially
- Set up service account credentials:
- Go to Project Settings → Service Accounts
- Select "Firebase Admin SDK"
- Click "Generate new private key" (JSON format)
- Save the JSON file securely
- Configure Database Rules for security:
{ "rules": { "rooms": { "$roomid": { ".read": true, ".write": true, "messages": { ".indexOn": "timestamp" }, "participants": { ".indexOn": "lastActive" } } } } }
# Clone the repository
git clone https://github.com/vrushank/bluelink.git
cd bluelink
# Build and install
go install ./cmd/bluelinkgo install github.com/vrushank/bluelink/cmd/bluelink@latest# Clone the repository
git clone https://github.com/vrushank/bluelink.git
cd bluelink
# Build for your platform
go build -o bluelink ./cmd/bluelink
# Move to a directory in your PATH (optional)
sudo mv bluelink /usr/local/bin/Before using Bluelink, set up your Firebase credentials:
export FIREBASE_CREDENTIALS=/path/to/your-firebase-credentials.json
export FIREBASE_DATABASE_URL=https://your-project-id.firebaseio.comAdd these to your shell profile (.bashrc, .zshrc, etc.) for persistence.
Place your Firebase credentials in your current working directory as firebase-credentials.json.
On first run, Bluelink will:
- Ask for your name
- Generate a unique user ID
- Assign a persistent color for your messages
- Store this information in
~/.bluelink/config.json
bluelinkThis will generate a random 8-digit room ID and display it in the UI.
bluelink ROOM_IDReplace ROOM_ID with the 8-digit room ID you want to join.
/help- Show available commands/clear- Clear chat history/exit- Leave the room
Tab- Toggle between chat history and input areaEnter- Send messageCtrl+C- Exit application
The Bluelink interface consists of:
- Room header showing current room ID
- Main chat area with colored messages
- Participant list with activity status
- Input area for typing messages
- Help section (toggle with
/help)
- All communication passes through Firebase Realtime Database
- User data is stored locally in
~/.bluelink/config.json - Room IDs are randomly generated 8-digit numbers
- Consider implementing end-to-end encryption for production use
- Set appropriate Firebase Database Rules for your use case
If you're having trouble connecting to Firebase:
- Verify your credentials file is correctly formatted
- Check that
FIREBASE_DATABASE_URLis set correctly - Ensure your Firebase project has Realtime Database enabled
- Check your network connection and firewall settings
For terminal display issues:
- Ensure your terminal supports Unicode characters
- Try adjusting your terminal window size
- Check that your terminal supports ANSI color codes
If you encounter build errors related to Firebase:
- Ensure you're using a compatible Go version (1.16+)
- The Firebase Go Admin SDK has some limitations regarding real-time listeners
- Bluelink uses a polling mechanism for compatibility with all Firebase SDK versions
Common error messages and solutions:
- "Firebase credentials not found": Set
FIREBASE_CREDENTIALSenvironment variable or placefirebase-credentials.jsonin your working directory - "Room does not exist": Verify the room ID is correct and the room has not been deleted
- "Error initializing Firebase app": Check your credentials and database URL
bluelink/
├── cmd/
│ └── bluelink/ # Main application
│ └── main.go
├── pkg/
│ ├── config/ # Configuration management
│ │ └── config.go
│ ├── firebase/ # Firebase integration
│ │ └── firebase.go
│ └── ui/ # Terminal UI
│ └── ui.go
├── .github/
│ └── workflows/ # CI/CD workflows
│ └── go.yml # GitHub Actions workflow
├── go.mod # Go module definition
├── go.sum # Go module checksums
├── firebase-credentials.json # Firebase credentials (example)
├── LICENSE # MIT License
└── README.md # This file
# Clone the repository
git clone https://github.com/vrushank/bluelink.git
cd bluelink
# Install dependencies
go mod download
# Build
go build -o bluelink ./cmd/bluelinkgo test ./...Possible extensions for the project:
- End-to-end encryption for messages
- File sharing capabilities
- Custom room names
- User authentication
- Message history retrieval
- Notification system
- Offline message caching
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Here's how you can contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please make sure to update tests as appropriate and follow the existing code style.
- Bubble Tea for the terminal UI framework
- Firebase for the real-time database