Chia tiền nhậu dễ dàng, vui vẻ, không còn tranh cãi! 🍺
SplitBuddy là ứng dụng web giúp nhóm bạn chia tiền sau mỗi buổi nhậu một cách công bằng và minh bạch. Không còn tình trạng "ai trả bao nhiêu", "ai nợ ai" - SplitBuddy lo hết!
- Quản lý Session - Tạo buổi nhậu, thêm người tham gia (user hoặc guest)
- Chia bill thông minh - Chia đều, chia theo %, hoặc custom amount
- Theo dõi nợ - Ai nợ ai, bao nhiêu, trạng thái thanh toán
- Cấn trừ nợ tự động - Smart netting giảm số giao dịch cần thiết
- Nhóm bạn nhậu - Quản lý nhóm bạn thường xuyên đi nhậu
- Mini Games - Truth or Dare, Never Have I Ever, Challenges, Spin Wheel, Kings Cup
- Music Player - Phát nhạc trong khi nhậu với playlist từ YouTube
- Avatar & Achievements - Gamification với XP, levels, badges
- Wrapped Stats - Thống kê hoạt động theo năm
- AI Chat - Chat với AI để được tư vấn
| Layer | Technology |
|---|---|
| Frontend | React 18, TypeScript, Vite, TailwindCSS, shadcn/ui, TanStack Query |
| Backend | Rust (Nightly), Axum 0.7, SQLx |
| Database | PostgreSQL 16 |
| Auth | JWT + Argon2 |
| AI | Google Gemini API |
| Deploy | Heroku (Docker) |
| CI/CD | GitHub Actions (optimized with path filtering & caching) |
- Node.js 20+
- Rust (stable for development, nightly for Docker build)
- Docker & Docker Compose
- PostgreSQL (hoặc dùng Docker)
git clone https://github.com/trungtaottn/SplitBuddy.git
cd SplitBuddy# Cài đặt git hooks để auto-format code trước khi commit
make setup# Start PostgreSQL + Redis với Docker
docker-compose up -d
# Verify services are running
docker ps
# Should show: splitbuddy-db (postgres) and splitbuddy-redis (redis)cd backend
cp .env.example .env
# Cài SQLx CLI
cargo install sqlx-cli --no-default-features --features postgres
# Chạy migrations
sqlx database create
sqlx migrate run
# Start server
cargo runBackend sẽ chạy tại http://localhost:8080
cd frontend
npm install
# Start dev server
npm run devFrontend sẽ chạy tại http://localhost:5173
- Frontend: http://localhost:5173
- Backend API: http://localhost:8080/api
- Health Check: http://localhost:8080/api/health
make setup # Cài đặt git hooks
make install # Cài đặt dependencies
make format # Format tất cả code (Rust + TypeScript)
make check # Check tất cả giống CI (lint, build, test)
make check-backend # Check backend only
make check-frontend # Check frontend only
make dev-backend # Chạy backend dev server
make dev-frontend # Chạy frontend dev server
make docker-build # Build Docker image
make clean # Dọn dẹp build artifactsSplitBuddy/
├── backend/ # Rust Axum API
│ ├── src/
│ │ ├── api/ # Route handlers (auth, sessions, debts, games, etc.)
│ │ ├── domain/ # Business logic & models
│ │ ├── repository/ # Database layer (SQLx queries)
│ │ └── middleware/ # Auth middleware
│ ├── migrations/ # SQL migrations
│ └── .sqlx/ # SQLx offline query cache
│
├── frontend/ # React SPA
│ ├── src/
│ │ ├── components/ # UI components (shadcn/ui customized)
│ │ ├── pages/ # Page components
│ │ ├── contexts/ # React contexts (Auth, Theme, Music, Mood)
│ │ ├── hooks/ # Custom hooks
│ │ ├── types/ # TypeScript types
│ │ └── lib/ # Utilities (axios, queryClient)
│ └── public/
│
├── docs/ # Documentation
│ ├── DEPLOYMENT.md # Deployment guide
│ ├── SETUP.md # Setup guide
│ ├── PROJECT_GUIDELINES.md
│ └── ...
│
├── .github/workflows/ # GitHub Actions CI/CD
│ └── ci.yml # Optimized CI/CD pipeline
│
├── .githooks/ # Git hooks
│ ├── pre-commit # Auto-format code before commit
│ └── setup.sh # Setup script
│
├── Dockerfile # Multi-stage Docker build (5 stages)
├── docker-compose.yml # Local development (PostgreSQL)
├── Makefile # Development commands
└── heroku.yml # Heroku deployment config
| Document | Description |
|---|---|
| Backend README | Backend API documentation, endpoints, setup |
| Frontend README | Frontend documentation, components, routes |
| Contributing | How to contribute to this project |
| Deployment | Deployment & CI/CD guide |
| Setup | Detailed setup guide |
| Project Guidelines | Coding conventions & standards |
| Architecture | System architecture overview |
main # Production - auto deploy to Heroku
└── revert # Last known good state (auto-synced)
└── dev # Development - CI checks, PR target
└── feature/xxx # Feature branches
Branches:
main- Production code, auto-deploy khi mergerevert- Giữ last known good state, tự động sync với main khi deploy thành côngdev- Development branch, tạo PR từ đây vào main
Quy tắc:
- KHÔNG merge trực tiếp dev → main bằng
git merge - Luôn tạo Pull Request từ dev → main
- Đợi CI pass trước khi merge
- Heroku auto-deploy từ main
- Nếu deploy fail, dùng
revertbranch để rollback
type(scope): message
# Types: feat, fix, refactor, docs, style, test, chore
# Examples:
# feat(sessions): add participant management
# fix(debts): correct netting calculation
# docs(readme): update API endpoints
GitHub Actions tự động chạy khi push:
Path-based job execution:
test-backend- Chỉ chạy khi thay đổibackend/**test-frontend- Chỉ chạy khi thay đổifrontend/**deploy- Chỉ chạy trênmainbranch
Features:
- ✅ Auto-cancel in-progress runs on new commits
- ✅ Intelligent caching (Rust dependencies, npm)
- ✅ Path filtering (skip irrelevant jobs)
- ✅ Security scanning with Trivy
- ✅ Auto-sync
revertbranch - ✅ Health check verification after deploy
Pre-commit hook tự động:
- Format Rust code (
cargo fmt) - Fix ESLint issues (
eslint --fix) - Check clippy warnings
- Verify build
# Setup (chỉ cần chạy 1 lần)
make setupKhi thêm/sửa SQL query, cần update cache:
cd backend
cargo sqlx prepare
git add .sqlx/
git commit -m "chore: update sqlx cache"# Database
DATABASE_URL=postgres://user:pass@localhost:5432/splitbuddy
# Redis (optional - for WebSocket scaling)
REDIS_URL=redis://localhost:6379
# JWT
JWT_SECRET=your-secret-key
JWT_EXPIRATION_HOURS=24
# Server
HOST=0.0.0.0
PORT=8080
RUST_LOG=debug
# Push Notifications (generate at https://vapidkeys.com)
VAPID_PRIVATE_KEY=your-base64-private-key
VAPID_SUBJECT=mailto:admin@splitbuddy.com
# AI Features
GEMINI_API_KEY=your-api-key # OptionalVITE_API_URL=http://localhost:8080
VITE_VAPID_PUBLIC_KEY=your-base64-public-key # For push notificationsRequired Addons:
# Add Heroku Postgres (if not already added)
heroku addons:create heroku-postgresql:essential-0 -a splitbuddy
# Add Heroku Redis (for WebSocket Pub/Sub and caching)
heroku addons:create heroku-redis:mini -a splitbuddy
# Set environment variables
heroku config:set VAPID_PRIVATE_KEY=your-key -a splitbuddy
heroku config:set VAPID_SUBJECT=mailto:admin@splitbuddy.com -a splitbuddyDeployment Flow:
- Push to
mainbranch - CI runs tests (path-filtered, parallel jobs)
- Docker image built with 5-stage build (cargo-chef + BuildKit)
- Image pushed to Heroku Container Registry
- Health check verification
revertbranch synced
# Nếu cần rollback về version trước
git checkout main
git reset --hard origin/revert
git push origin main --force# Chỉ khi có bug critical
heroku container:push web -a splitbuddy
heroku container:release web -a splitbuddy# Check tất cả (giống CI)
make check
# Backend tests
cd backend && cargo test
# Frontend type check
cd frontend && npm run type-check
# Frontend lint
cd frontend && npm run lint:fix- Fork repo
- Clone và
make setupđể cài git hooks - Tạo branch từ
dev:git checkout -b feature/your-feature - Commit changes (auto-formatted bởi pre-commit hook)
- Push và tạo PR về
dev - Đợi review và CI pass
Xem CONTRIBUTING.md để biết thêm chi tiết.
MIT License - Xem LICENSE để biết thêm chi tiết.
Made with 🍺 and code by the SplitBuddy team
Last Updated: January 2026