Nền tảng nhắn tin bảo mật, mã nguồn mở — xây dựng trên Matrix Protocol
🌐 Live Demo · 📖 Technical Docs · 🚀 Quick Start
PieChat là nền tảng nhắn tin thời gian thực (real-time messaging), được thiết kế cho tổ chức và nhóm nhỏ từ 1.000 - 5.000 người dùng. Dự án sử dụng Matrix Protocol làm nền tảng giao tiếp, mang lại khả năng federation, bảo mật end-to-end (E2EE), và khả năng mở rộng.
| Tiêu chí | PieChat | Giải pháp SaaS |
|---|---|---|
| Quyền kiểm soát dữ liệu | ✅ Self-hosted, toàn quyền | ❌ Lưu trên server bên thứ 3 |
| Chi phí | ✅ Miễn phí (chỉ trả hosting) | ❌ Trả phí theo user |
| Tùy biến | ✅ Mã nguồn mở, tuỳ chỉnh UI/UX | ❌ Giới hạn bởi vendor |
| Tích hợp Bot/API | ✅ Matrix API chuẩn, dễ tích hợp | |
| Federation | ✅ Kết nối với Matrix network | ❌ Hệ thống đóng |
- Chat 1-1 (Direct Message) với hệ thống kết bạn & danh bạ
- Nhóm chat (Group) với phân quyền admin/member
- Kênh (Channel) — tổ chức nhiều nhóm dưới 1 kênh
- Tin nhắn chờ — quản lý tin nhắn từ người lạ
- Stickers & Emoji Reactions — bộ sticker tuỳ chỉnh
- Typing indicator — hiển thị khi đối phương đang gõ
- Đọc/chưa đọc — badge unread count chính xác
- Reply/Edit/Delete — trả lời, sửa, xóa tin nhắn
- Forward — chuyển tiếp tin nhắn sang phòng khác hoặc tạo nhóm mới trong kênh
- Drag & Drop — kéo thả file/folder vào chat, preview + tuỳ chọn caption
- Pin conversations — ghim hội thoại quan trọng
- Tìm kiếm người dùng theo số điện thoại
- Smart Copy — nút sao chép thông minh theo nội dung: SĐT, OTP, số TK, URL, script
- Lên lịch gửi tin — hẹn giờ gửi tin nhắn
- Paste script widget — paste trực tiếp vào ô chat bằng tiền tố
//widget:{JSON} - Chart widget — biểu đồ bar/line/area/pie/doughnut (SVG thuần, không cần CDN)
- Table widget — bảng dữ liệu có sort, stripe
- Code widget — highlight code với nút Copy
- Progress widget — thanh tiến trình
- Custom widget — HTML/CSS/JS tuỳ ý trong sandbox iframe
- Tuỳ chỉnh kích thước —
width: 500(px) hoặcwidth: "80%"(phần trăm)
- Gọi thoại (Voice Call) — giao diện xanh lá
- Gọi video (Video Call) — giao diện tím
- Audio visualization — hiển thị tín hiệu mic/loa realtime
- Chọn thiết bị — mic/loa selector
- Âm thanh cuộc gọi — ringtone, dialing, hangup sounds
- Đăng nhập bằng SĐT + Mật khẩu với OTP 2FA
- QR Code Login — quét từ mobile để đăng nhập web
- Trusted Device — bỏ qua OTP cho thiết bị tin cậy
- Rate limiting — chống brute-force password & OTP
- Login audit — lịch sử đăng nhập, cảnh báo bất thường
- Dark mode mặc định, giao diện premium
- Custom theme — chọn màu accent hoặc nhập mã HEX tuỳ ý
- Preset themes — Xanh dương, Cam, Xanh lá, Tím, Hồng, Đỏ
- Custom icons — icon sidebar tuỳ chỉnh
- Responsive — desktop & mobile
- Đa ngôn ngữ — Tiếng Việt & English
- Hệ thống Assistant tích hợp sẵn
- Hỗ trợ cấu hình model AI (OpenAI, Groq, Ollama...)
- Giao diện quản lý bot trong Settings
- PWA — cài đặt như app native
- Web — truy cập qua trình duyệt
- Android (Capacitor) — đang phát triển
- Desktop (Tauri) — planned
- Push notification qua Service Worker
- Click notification → mở đúng phòng chat
- Badge count cho tin nhắn chưa đọc
┌─────────────┐ ┌──────────────────┐ ┌────────────────┐
│ Frontend │────▶│ Nginx Proxy │────▶│ Dendrite │
│ (Next.js) │ │ (SSL/Routing) │ │ (Matrix Server)│
│ Port: 3000 │ │ Port: 80/443 │ │ Port: 8008 │
└─────────────┘ └──────────────────┘ └────────────────┘
│
┌───────▼────────┐
│ Auth Service │
│ (Express.js) │
│ Port: 4000 │
└────────────────┘
| Layer | Công nghệ |
|---|---|
| Frontend | Next.js 15, React 19, TypeScript, TailwindCSS |
| State Management | Zustand |
| Real-time | Matrix Client-Server API (polling) |
| Voice/Video | WebRTC (peer-to-peer) |
| Backend | Dendrite (Matrix Homeserver, Go) |
| Auth | Express.js, OTP via SMS webhook |
| Proxy | Nginx with Let's Encrypt SSL |
| Deploy | Docker Compose |
| Hosting | Oracle Cloud (Free Tier compatible) |
- Docker & Docker Compose
- Domain name (cho production)
- Node.js 22+ (cho development)
git clone https://github.com/Monkez/PieChat.git
cd PieChat
cp .env.example .env
# Sửa .env: DOMAIN, MATRIX_SERVER_NAME, SSL_EMAIL# Terminal 1: Backend (Dendrite)
cd backend
go run ./cmd/dendrite-monolith-server
# Terminal 2: Auth Service
cd auth-service
npm install && npm run dev
# Terminal 3: Frontend
cd frontend
npm install && npm run devTruy cập: http://localhost:3000
docker compose up -d --buildHệ thống sẽ tự động:
- Khởi tạo Dendrite (Matrix server)
- Chạy Auth Service (OTP + QR Login)
- Build & serve Frontend (Next.js)
- Cấu hình Nginx reverse proxy
- Cấp SSL certificate (Let's Encrypt)
# Trong container Dendrite
docker exec -it piechat-dendrite \
/usr/bin/create-account -config /etc/dendrite/dendrite.yaml \
-username alice -password Pass@12345PieChat/
├── frontend/ # Next.js Frontend
│ ├── app/ # Pages (App Router)
│ │ ├── chat/ # Chat layout & rooms
│ │ ├── login/ # Đăng nhập
│ │ ├── register/ # Đăng ký
│ │ └── settings/ # Cài đặt
│ ├── components/ # UI Components
│ │ ├── chat/ # Chat-specific (call overlay, message list...)
│ │ └── ui/ # Design system (button, dialog, input...)
│ ├── hooks/ # Custom hooks (useWebRTC...)
│ ├── lib/
│ │ ├── services/ # API clients (matrix-service, sticker-service)
│ │ └── store/ # Zustand stores
│ └── public/ # Static assets
│ ├── call-sounds/ # Ringtone, dialing, hangup
│ ├── menubar-icons/ # Custom sidebar icons
│ └── stickers/ # Chat stickers
├── auth-service/ # Express.js Auth Microservice
│ └── src/
│ ├── routes/ # API routes (OTP, QR, devices)
│ └── services/ # Business logic (phone-otp, redis)
├── backend/ # Dendrite (forked Matrix homeserver)
├── deploy/ # Prod deployment configs
│ ├── nginx/ # Nginx configuration
│ ├── setup-server.sh # Server setup script
│ └── dendrite-production.yaml
├── assets/ # Source assets (icons, images)
├── docker-compose.yml # Production stack
└── .env.example # Environment template
- Fork repo
- Tạo branch:
git checkout -b feature/ten-tinh-nang - Commit:
git commit -m "feat: mô tả" - Push:
git push origin feature/ten-tinh-nang - Tạo Pull Request
MIT License — Xem file LICENSE để biết chi tiết.
Made with ❤️ by Monkez